REVIEW: eliminate makedev(9) use from syscons.

From: Poul-Henning Kamp <phk_at_phk.freebsd.dk>
Date: Sat, 07 Feb 2004 23:21:42 +0100
http://phk.freebsd.dk/patch/syscons.patch

This patch eliminates the use of makedev(9) in syscons.

Index: syscons.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/syscons/syscons.c,v
retrieving revision 1.411
diff -u -r1.411 syscons.c
--- syscons.c	5 Feb 2004 01:56:42 -0000	1.411
+++ syscons.c	7 Feb 2004 22:16:40 -0000
_at__at_ -389,9 +389,11 _at__at_
 			      (void *)(uintptr_t)unit, SHUTDOWN_PRI_DEFAULT);
 
     for (vc = 0; vc < sc->vtys; vc++) {
-	dev = make_dev(&sc_cdevsw, vc + unit * MAXCONS,
-	    UID_ROOT, GID_WHEEL, 0600, "ttyv%r", vc + unit * MAXCONS);
-	sc->dev[vc] = dev;
+	if (sc->dev[vc] == NULL) {
+		dev = make_dev(&sc_cdevsw, vc + unit * MAXCONS,
+		    UID_ROOT, GID_WHEEL, 0600, "ttyv%r", vc + unit * MAXCONS);
+		sc->dev[vc] = dev;
+	}
 	/*
 	 * The first vty already has struct tty and scr_stat initialized
 	 * in scinit().  The other vtys will have these structs when
_at__at_ -2730,7 +2732,8 _at__at_
 	sc->vtys = MAXCONS;		/* XXX: should be configurable */
 	if (flags & SC_KERNEL_CONSOLE) {
 	    sc->dev = main_devs;
-	    sc->dev[0] = makedev(CDEV_MAJOR, unit*MAXCONS);
+	    sc->dev[0] = make_dev(&sc_cdevsw, unit * MAXCONS,
+	        UID_ROOT, GID_WHEEL, 0600, "ttyv%r", unit * MAXCONS);
 	    sc->dev[0]->si_tty = &main_tty;
 	    ttyregister(&main_tty);
 	    scp = &main_console;
_at__at_ -2745,7 +2748,8 _at__at_
 	} else {
 	    /* assert(sc_malloc) */
 	    sc->dev = malloc(sizeof(dev_t)*sc->vtys, M_DEVBUF, M_WAITOK|M_ZERO);
-	    sc->dev[0] = makedev(CDEV_MAJOR, unit*MAXCONS);
+	    sc->dev[0] = make_dev(&sc_cdevsw, unit * MAXCONS,
+	        UID_ROOT, GID_WHEEL, 0600, "ttyv%r", unit * MAXCONS);
 	    sc->dev[0]->si_tty = ttymalloc(sc->dev[0]->si_tty);
 	    scp = alloc_scp(sc, sc->first_vty);
 	}
-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk_at_FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
Received on Sat Feb 07 2004 - 13:54:29 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:42 UTC