From 06a8bb906c1eee09ebce808466ff6a72f6c3a913 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Sun, 9 Mar 2003 10:28:05 +0000 Subject: [PATCH] Add one little hack to allow us to make MAJOR_AUTO be zero: Let the console driver ask for major 256 and magically change this to mean zero. --- sys/kern/kern_conf.c | 2 ++ sys/kern/tty_cons.c | 19 +++++++------------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index 4606fd6c8e01..2f06fa64ebc7 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -295,6 +295,8 @@ make_dev(struct cdevsw *devsw, int minor, uid_t uid, gid_t gid, int perms, const devsw->d_maj = i; reserved_majors[i] = i; } else { + if (devsw->d_maj == 256) /* XXX: tty_cons.c is magic */ + devsw->d_maj = 0; KASSERT(devsw->d_maj >= 0 && devsw->d_maj < 256, ("Invalid major (%d) in make_dev", devsw->d_maj)); if (reserved_majors[devsw->d_maj] != devsw->d_maj) { diff --git a/sys/kern/tty_cons.c b/sys/kern/tty_cons.c index cd5c84f7d855..89bed410fed2 100644 --- a/sys/kern/tty_cons.c +++ b/sys/kern/tty_cons.c @@ -69,7 +69,6 @@ static d_ioctl_t cnioctl; static d_poll_t cnpoll; static d_kqfilter_t cnkqfilter; -#define CDEV_MAJOR 0 static struct cdevsw cn_cdevsw = { .d_open = cnopen, .d_close = cnclose, @@ -78,7 +77,12 @@ static struct cdevsw cn_cdevsw = { .d_ioctl = cnioctl, .d_poll = cnpoll, .d_name = "console", - .d_maj = CDEV_MAJOR, + .d_maj = 256, + /* + * XXX: We really want major #0, but zero here means + * XXX: allocate a major number automatically. + * XXX: kern_conf.c knows what to do when it sees 256. + */ .d_flags = D_TTY, .d_kqfilter = cnkqfilter, }; @@ -171,6 +175,7 @@ cninit(void) * Make the best console the preferred console. */ cnselect(best_cn); + make_dev(&cn_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "console"); } void @@ -582,13 +587,3 @@ cndbctl(int on) if (on) refcount++; } - -static void -cn_drvinit(void *unused) -{ - - make_dev(&cn_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, - "console"); -} - -SYSINIT(cndev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,cn_drvinit,NULL)