From 7e760e148a2caa4873b7aeddbeab49b52b74b1ac Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Sun, 19 Jan 2003 11:03:07 +0000 Subject: Originally when DEVFS was added, a global variable "devfs_present" was used to control code which were conditional on DEVFS' precense since this avoided the need for large-scale source pollution with #include "opt_geom.h" Now that we approach making DEVFS standard, replace these tests with an #ifdef to facilitate mechanical removal once DEVFS becomes non-optional. No functional change by this commit. --- sys/kern/init_main.c | 30 +++++++++++++++--------------- sys/kern/kern_conf.c | 7 ++++--- sys/kern/kern_descrip.c | 12 +++++++----- sys/kern/tty_tty.c | 7 +------ 4 files changed, 27 insertions(+), 29 deletions(-) (limited to 'sys/kern') diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 354536fd6a32..74424ccd41b2 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -554,21 +554,21 @@ start_init(void *dummy) mac_create_root_mount(td->td_ucred, TAILQ_FIRST(&mountlist)); #endif - if (devfs_present) { - /* - * For disk based systems, we probably cannot do this yet - * since the fs will be read-only. But a NFS root - * might be ok. It is worth a shot. - */ - error = kern_mkdir(td, "/dev", UIO_SYSSPACE, 0700); - if (error == EEXIST) - error = 0; - if (error == 0) - error = kernel_vmount(0, "fstype", "devfs", - "fspath", "/dev", NULL); - if (error != 0) - init_does_devfs = 1; - } +#ifndef NODEVFS + /* + * For disk based systems, we probably cannot do this yet + * since the fs will be read-only. But a NFS root + * might be ok. It is worth a shot. + */ + error = kern_mkdir(td, "/dev", UIO_SYSSPACE, 0700); + if (error == EEXIST) + error = 0; + if (error == 0) + error = kernel_vmount(0, "fstype", "devfs", + "fspath", "/dev", NULL); + if (error != 0) + init_does_devfs = 1; +#endif /* * Need just enough stack to hold the faked-up "execve()" arguments. diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index 6b04b45d6323..0a98a343f6fa 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -62,7 +62,6 @@ static LIST_HEAD(, cdev) dev_free; devfs_create_t *devfs_create_hook; devfs_destroy_t *devfs_destroy_hook; -int devfs_present; static int ready_for_devs; @@ -81,9 +80,11 @@ devsw(dev_t dev) disk_dev_synth(dev); if (dev->si_devsw) return (dev->si_devsw); - if (devfs_present) - return (NULL); +#ifndef NODEVFS + return (NULL); +#else return(cdevsw[major(dev)]); +#endif } /* diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index cf802ab28611..835ec39e9642 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -2152,13 +2152,15 @@ fildesc_drvinit(void *unused) make_dev_alias(dev, "stdout"); dev = make_dev(&fildesc_cdevsw, 2, UID_ROOT, GID_WHEEL, 0666, "fd/2"); make_dev_alias(dev, "stderr"); - if (!devfs_present) { - int fd; +#ifdef NODEVFS + { + int fd; - for (fd = 3; fd < NUMFDESC; fd++) - make_dev(&fildesc_cdevsw, fd, UID_ROOT, GID_WHEEL, - 0666, "fd/%d", fd); + for (fd = 3; fd < NUMFDESC; fd++) + make_dev(&fildesc_cdevsw, fd, UID_ROOT, GID_WHEEL, + 0666, "fd/%d", fd); } +#endif } static fo_rdwr_t badfo_readwrite; diff --git a/sys/kern/tty_tty.c b/sys/kern/tty_tty.c index 3a5524e3bffb..d962c1884b23 100644 --- a/sys/kern/tty_tty.c +++ b/sys/kern/tty_tty.c @@ -361,12 +361,7 @@ ctty_drvinit(unused) void *unused; { - if (devfs_present) { - EVENTHANDLER_REGISTER(dev_clone, ctty_clone, 0, 1000); - ctty = make_dev(&ctty_cdevsw, 0, 0, 0, 0666, "ctty"); - } else { - make_dev(&ctty_cdevsw, 0, 0, 0, 0666, "tty"); - } + make_dev(&ctty_cdevsw, 0, 0, 0, 0666, "tty"); } SYSINIT(cttydev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,ctty_drvinit,NULL) -- cgit v1.3