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.
This commit is contained in:
phk 2003-01-19 11:03:07 +00:00
parent eaa6ad0521
commit be470e56d7
9 changed files with 45 additions and 48 deletions

View File

@ -450,7 +450,6 @@ devfs_init(void *junk)
{
devfs_create_hook = devfs_create;
devfs_destroy_hook = devfs_destroy;
devfs_present = 1;
devfs_rules_init();
}

View File

@ -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.

View File

@ -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
}
/*

View File

@ -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;

View File

@ -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)

View File

@ -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 @@ tapmodevent(mod, type, data)
if (tapbasedev != NOUDEV)
destroy_dev(udev2dev(tapbasedev, 0));
if (!devfs_present)
cdevsw_remove(&tap_cdevsw);
#ifdef NODEVFS
cdevsw_remove(&tap_cdevsw);
#endif
break;

View File

@ -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;

View File

@ -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

View File

@ -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