From owner-freebsd-current@FreeBSD.ORG Sat Feb 7 14:54:29 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3798016A4CE for ; Sat, 7 Feb 2004 14:54:29 -0800 (PST) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id A30D043ECB for ; Sat, 7 Feb 2004 14:21:44 -0800 (PST) (envelope-from phk@phk.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.10/8.12.10) with ESMTP id i17MLgbj012882 for ; Sat, 7 Feb 2004 23:21:42 +0100 (CET) (envelope-from phk@phk.freebsd.dk) To: current@freebsd.org From: Poul-Henning Kamp Date: Sat, 07 Feb 2004 23:21:42 +0100 Message-ID: <12881.1076192502@critter.freebsd.dk> Subject: REVIEW: eliminate makedev(9) use from syscons. X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Feb 2004 22:54:29 -0000 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.