diff options
author | phk <phk@FreeBSD.org> | 2003-01-19 11:03:07 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2003-01-19 11:03:07 +0000 |
commit | 24596ddb76743273c5d39821727e4e00d025cb02 (patch) | |
tree | a1836e6e7bd999b9e7099048c5c2bd9535ef95cd | |
parent | 49b60b2ebe504ba8584d684a66b1351307a962cf (diff) | |
download | FreeBSD-src-24596ddb76743273c5d39821727e4e00d025cb02.zip FreeBSD-src-24596ddb76743273c5d39821727e4e00d025cb02.tar.gz |
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.
-rw-r--r-- | sys/fs/devfs/devfs_devs.c | 1 | ||||
-rw-r--r-- | sys/kern/init_main.c | 30 | ||||
-rw-r--r-- | sys/kern/kern_conf.c | 7 | ||||
-rw-r--r-- | sys/kern/kern_descrip.c | 12 | ||||
-rw-r--r-- | sys/kern/tty_tty.c | 7 | ||||
-rw-r--r-- | sys/net/if_tap.c | 17 | ||||
-rw-r--r-- | sys/net/if_tun.c | 17 | ||||
-rw-r--r-- | sys/sys/conf.h | 1 | ||||
-rw-r--r-- | sys/sys/linedisc.h | 1 |
9 files changed, 45 insertions, 48 deletions
diff --git a/sys/fs/devfs/devfs_devs.c b/sys/fs/devfs/devfs_devs.c index cb7c99c..3b9a1bb 100644 --- a/sys/fs/devfs/devfs_devs.c +++ b/sys/fs/devfs/devfs_devs.c @@ -450,7 +450,6 @@ devfs_init(void *junk) { devfs_create_hook = devfs_create; devfs_destroy_hook = devfs_destroy; - devfs_present = 1; devfs_rules_init(); } diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 354536f..74424cc 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 6b04b45..0a98a34 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 cf802ab..835ec39 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 3a5524e..d962c18 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) diff --git a/sys/net/if_tap.c b/sys/net/if_tap.c index d84d2b4..0648200 100644 --- a/sys/net/if_tap.c +++ b/sys/net/if_tap.c @@ -178,13 +178,13 @@ tapmodevent(mod, type, data) goto bail2; } - if (!devfs_present) { - error = cdevsw_add(&tap_cdevsw); - if (error != 0) { - EVENTHANDLER_DEREGISTER(dev_clone, eh_tag); - goto bail2; - } +#ifdef NODEVFS + error = cdevsw_add(&tap_cdevsw); + if (error != 0) { + EVENTHANDLER_DEREGISTER(dev_clone, eh_tag); + goto bail2; } +#endif return (0); bail2: @@ -229,8 +229,9 @@ bail: if (tapbasedev != NOUDEV) destroy_dev(udev2dev(tapbasedev, 0)); - if (!devfs_present) - cdevsw_remove(&tap_cdevsw); +#ifdef NODEVFS + cdevsw_remove(&tap_cdevsw); +#endif break; diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index 719191b..ce39d1f 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -147,13 +147,13 @@ tunmodevent(module_t mod, int type, void *data) tag = EVENTHANDLER_REGISTER(dev_clone, tunclone, 0, 1000); if (tag == NULL) return (ENOMEM); - if (!devfs_present) { - err = cdevsw_add(&tun_cdevsw); - if (err != 0) { - EVENTHANDLER_DEREGISTER(dev_clone, tag); - return (err); - } +#ifdef NODEVFS + err = cdevsw_add(&tun_cdevsw); + if (err != 0) { + EVENTHANDLER_DEREGISTER(dev_clone, tag); + return (err); } +#endif tununits.rm_type = RMAN_ARRAY; tununits.rm_descr = "open if_tun units"; err = rman_init(&tununits); @@ -200,8 +200,9 @@ tunmodevent(module_t mod, int type, void *data) if (tunbasedev != NOUDEV) destroy_dev(udev2dev(tunbasedev, 0)); - if (!devfs_present) - cdevsw_remove(&tun_cdevsw); +#ifdef NODEVFS + cdevsw_remove(&tun_cdevsw); +#endif break; } return 0; diff --git a/sys/sys/conf.h b/sys/sys/conf.h index f11cd80..580b233 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -323,7 +323,6 @@ typedef void devfs_destroy_t(dev_t dev); extern devfs_create_t *devfs_create_hook; extern devfs_destroy_t *devfs_destroy_hook; -extern int devfs_present; #define UID_ROOT 0 #define UID_BIN 3 diff --git a/sys/sys/linedisc.h b/sys/sys/linedisc.h index f11cd80..580b233 100644 --- a/sys/sys/linedisc.h +++ b/sys/sys/linedisc.h @@ -323,7 +323,6 @@ typedef void devfs_destroy_t(dev_t dev); extern devfs_create_t *devfs_create_hook; extern devfs_destroy_t *devfs_destroy_hook; -extern int devfs_present; #define UID_ROOT 0 #define UID_BIN 3 |