Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 07 Feb 2004 23:21:42 +0100
From:      Poul-Henning Kamp <phk@phk.freebsd.dk>
To:        current@freebsd.org
Subject:   REVIEW: eliminate makedev(9) use from syscons.
Message-ID:  <12881.1076192502@critter.freebsd.dk>

next in thread | raw e-mail | index | archive | help

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
@@ -389,9 +389,11 @@
 			      (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
@@ -2730,7 +2732,8 @@
 	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;
@@ -2745,7 +2748,8 @@
 	} 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@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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?12881.1076192502>