Avoid the modules madness I inadvertently introduced by making the

cloning infrastructure standard in kern_conf.  Modules are now
the same with or without devfs support.

If you need to detect if devfs is present, in modules or elsewhere,
check the integer variable "devfs_present".

This happily removes an ugly hack from kern/vfs_conf.c.

This forces a rename of the eventhandler and the standard clone
helper function.

Include <sys/eventhandler.h> in <sys/conf.h>: it's a helper #include
like <sys/queue.h>

Remove all #includes of opt_devfs.h they no longer matter.
This commit is contained in:
Poul-Henning Kamp 2000-09-02 19:17:34 +00:00
parent f3dcf66158
commit db90128160
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=65374
45 changed files with 103 additions and 416 deletions

View File

@ -98,7 +98,6 @@
#ifdef __FreeBSD__
#include "bktr.h"
#include "opt_devfs.h"
#endif /* __FreeBSD__ */
#if ( \

View File

@ -50,7 +50,6 @@
#ifdef __FreeBSD__
#include "bktr.h"
#include "opt_devfs.h"
#endif /* __FreeBSD__ */
#include "opt_bktr.h" /* include any kernel config options */

View File

@ -87,7 +87,6 @@
* Moffett Field, CA 94035
*/
#include "opt_devfs.h"
#include "ccd.h"
#include <sys/param.h>
@ -109,11 +108,6 @@
#include <sys/ccdvar.h>
#ifdef DEVFS
#include <sys/eventhandler.h>
#include <fs/devfs/devfs.h>
#endif
#if defined(CCDDEBUG) && !defined(DEBUG)
#define DEBUG
#endif
@ -289,7 +283,6 @@ putccdbuf(struct ccdbuf *cbp)
#define CCD_OFFSET 16
#endif
#ifdef DEVFS
static void
ccd_clone(void *arg, char *name, int namelen, dev_t *dev)
{
@ -298,7 +291,7 @@ ccd_clone(void *arg, char *name, int namelen, dev_t *dev)
if (*dev != NODEV)
return;
i = devfs_stdclone(name, &s, "ccd", &u);
i = dev_stdclone(name, &s, "ccd", &u);
if (i != 2)
return;
if (u >= numccd)
@ -310,7 +303,6 @@ ccd_clone(void *arg, char *name, int namelen, dev_t *dev)
*dev = make_dev(&ccd_cdevsw, u * 8 + *s - 'a',
UID_ROOT, GID_OPERATOR, 0640, name);
}
#endif DEVFS
/*
* Called by main() during pseudo-device attachment. All we need
@ -348,9 +340,7 @@ ccdattach()
/* XXX: is this necessary? */
for (i = 0; i < numccd; ++i)
ccddevs[i].ccd_dk = -1;
#ifdef DEVFS
EVENTHANDLER_REGISTER(devfs_clone, ccd_clone, 0, 1000);
#endif
EVENTHANDLER_REGISTER(dev_clone, ccd_clone, 0, 1000);
}
static int

View File

@ -52,7 +52,6 @@
*/
#include "opt_fdc.h"
#include "opt_devfs.h"
#include "card.h"
#include <sys/param.h>
@ -84,12 +83,6 @@
#include <isa/fdc.h>
#include <isa/rtc.h>
#ifdef DEVFS
#include <sys/ctype.h>
#include <sys/eventhandler.h>
#include <fs/devfs/devfs.h>
#endif
/* misuse a flag to identify format operation */
/* configuration flags */
@ -952,7 +945,6 @@ DRIVER_MODULE(fdc, pccard, fdc_pccard_driver, fdc_devclass, 0, 0);
#endif /* NCARD > 0 */
#ifdef DEVFS
static void fd_clone __P((void *arg, char *name, int namelen, dev_t *dev));
static struct {
@ -993,7 +985,7 @@ fd_clone(arg, name, namelen, dev)
if (*dev != NODEV)
return;
if (devfs_stdclone(name, &n, "fd", &u) != 2)
if (dev_stdclone(name, &n, "fd", &u) != 2)
return;
for (i = 0; ; i++) {
if (fd_suffix[i].match == NULL)
@ -1011,7 +1003,6 @@ fd_clone(arg, name, namelen, dev)
*dev = make_dev_alias(pdev, name);
}
}
#endif
/******************************************************************/
/*
@ -1163,20 +1154,15 @@ static int
fd_attach(device_t dev)
{
struct fd_data *fd;
static int cdevsw_add_done = 0;
fd = device_get_softc(dev);
#ifndef DEVFS
{
static int cdevsw_add_done = 0;
if (!cdevsw_add_done) {
cdevsw_add(&fd_cdevsw); /* XXX */
cdevsw_add_done++;
cdevsw_add(&fd_cdevsw); /* XXX */
cdevsw_add_done++;
}
}
#else
EVENTHANDLER_REGISTER(devfs_clone, fd_clone, 0, 1000);
#endif
EVENTHANDLER_REGISTER(dev_clone, fd_clone, 0, 1000);
make_dev(&fd_cdevsw, (fd->fdu << 6),
UID_ROOT, GID_OPERATOR, 0640, "fd%d", fd->fdu);

View File

@ -12,7 +12,6 @@
#include "opt_mfs.h" /* We have adopted some tasks from MFS */
#include "opt_md.h"
#include "opt_devfs.h"
#include <sys/param.h>
#include <sys/systm.h>
@ -26,11 +25,6 @@
#include <sys/linker.h>
#include <sys/queue.h>
#ifdef DEVFS
#include <sys/eventhandler.h>
#include <fs/devfs/devfs.h>
#endif
#ifndef MD_NSECT
#define MD_NSECT (10000 * 2)
#endif
@ -124,10 +118,8 @@ mdopen(dev_t dev, int flag, int fmt, struct proc *p)
devtoname(dev), flag, fmt, p);
sc = dev->si_drv1;
#ifndef DEVFS
if (sc->unit + 1 == mdunits)
if ((!devfs_present) && sc->unit + 1 == mdunits)
mdcreate_malloc(-1);
#endif
dl = &sc->disk.d_label;
bzero(dl, sizeof(*dl));
@ -411,7 +403,6 @@ mdcreate_malloc(int unit)
printf("md%d: Malloc disk\n", sc->unit);
}
#ifdef DEVFS
static void
md_clone (void *arg, char *name, int namelen, dev_t *dev)
{
@ -419,7 +410,7 @@ md_clone (void *arg, char *name, int namelen, dev_t *dev)
if (*dev != NODEV)
return;
i = devfs_stdclone(name, NULL, "md", &u);
i = dev_stdclone(name, NULL, "md", &u);
if (i == 0)
return;
/* XXX: should check that next char is [\0sa-h] */
@ -431,7 +422,6 @@ md_clone (void *arg, char *name, int namelen, dev_t *dev)
mdcreate_malloc(u);
return;
}
#endif
static void
md_drvinit(void *unused)
@ -463,11 +453,9 @@ md_drvinit(void *unused)
mdunits, name, len, ptr);
mdcreate_preload(ptr, len);
}
#ifdef DEVFS
EVENTHANDLER_REGISTER(devfs_clone, md_clone, 0, 999);
#else
mdcreate_malloc(-1);
#endif
EVENTHANDLER_REGISTER(dev_clone, md_clone, 0, 999);
if (!devfs_present)
mdcreate_malloc(-1);
}
SYSINIT(mddev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR, md_drvinit,NULL)

View File

@ -32,9 +32,6 @@
*
*/
#include "opt_devfs.h"
#include <dev/sound/midi/midi.h>
#include <isa/isavar.h>

View File

@ -37,8 +37,6 @@
*
*/
#include "opt_devfs.h"
#include <dev/sound/midi/midi.h>
#include <dev/sound/chip.h>
#include <machine/cpufunc.h>

View File

@ -44,8 +44,6 @@
*
*/
#include "opt_devfs.h"
#include <dev/sound/midi/midi.h>
#include <dev/sound/chip.h>

View File

@ -46,8 +46,6 @@
*
*/
#include "opt_devfs.h"
#include <isa/sioreg.h>
#include <isa/ic/ns16550.h>
#include <dev/sound/midi/midi.h>

View File

@ -50,8 +50,6 @@
*
*/
#include "opt_devfs.h"
#include <dev/sound/midi/midi.h>
static devclass_t midi_devclass;

View File

@ -35,8 +35,6 @@
* transmit to or received from a midi interface.
*/
#include "opt_devfs.h"
#include <dev/sound/midi/midi.h>
/* Some macros to handle the queue. */

View File

@ -34,8 +34,6 @@
* midi messages, and vice versa.
*/
#include "opt_devfs.h"
#include <stddef.h>
#include <dev/sound/midi/midi.h>

View File

@ -33,8 +33,6 @@
* to and from a midi device or synthesizer.
*/
#include "opt_devfs.h"
#include <dev/sound/midi/midi.h>
#include <dev/sound/midi/sequencer.h>

View File

@ -26,8 +26,6 @@
* $FreeBSD$
*/
#include "opt_devfs.h"
#include <dev/sound/midi/midi.h>
#include <dev/sound/chip.h>
#include <dev/sound/pci/csareg.h>

View File

@ -96,9 +96,4 @@ void devfs_purge __P((struct devfs_dirent *dd));
struct devfs_dirent * devfs_vmkdir __P((char *name, int namelen,
struct devfs_dirent *dotdot));
#endif /* DEVFS_INTERN */
typedef void (*devfs_clone_fn) __P((void *arg, char *name, int namelen, dev_t *result));
int devfs_stdclone __P((char *name, char **namep, char *stem, int *unit));
EVENTHANDLER_DECLARE(devfs_clone, devfs_clone_fn);
#endif /* _KERNEL */

View File

@ -238,34 +238,12 @@ devfs_create(dev_t dev)
}
static void
devfs_remove(dev_t dev)
devfs_destroy(dev_t dev)
{
devfs_inot[dev->si_inode] = NULL;
devfs_generation++;
}
devfs_create_t *devfs_create_hook = devfs_create;
devfs_remove_t *devfs_remove_hook = devfs_remove;
int
devfs_stdclone(char *name, char **namep, char *stem, int *unit)
{
int u, i;
if (bcmp(stem, name, strlen(stem)) != 0)
return (0);
i = strlen(stem);
if (!isdigit(name[i]))
return (0);
u = 0;
while (isdigit(name[i])) {
u *= 10;
u += name[i++] - '0';
}
*unit = u;
if (namep)
*namep = &name[i];
if (name[i])
return (2);
return (1);
}
devfs_destroy_t *devfs_destroy_hook = devfs_destroy;
int devfs_present = 1;

View File

@ -300,7 +300,7 @@ devfs_lookup(ap)
printf("Finished specname: %d \"%s\"\n", i, specname + i);
#endif
cdev = NODEV;
EVENTHANDLER_INVOKE(devfs_clone, specname + i,
EVENTHANDLER_INVOKE(dev_clone, specname + i,
strlen(specname + i), &cdev);
#if 0
printf("cloned %s -> %p %s\n", specname + i, cdev,

View File

@ -87,7 +87,6 @@
* Moffett Field, CA 94035
*/
#include "opt_devfs.h"
#include "ccd.h"
#include <sys/param.h>
@ -109,11 +108,6 @@
#include <sys/ccdvar.h>
#ifdef DEVFS
#include <sys/eventhandler.h>
#include <fs/devfs/devfs.h>
#endif
#if defined(CCDDEBUG) && !defined(DEBUG)
#define DEBUG
#endif
@ -289,7 +283,6 @@ putccdbuf(struct ccdbuf *cbp)
#define CCD_OFFSET 16
#endif
#ifdef DEVFS
static void
ccd_clone(void *arg, char *name, int namelen, dev_t *dev)
{
@ -298,7 +291,7 @@ ccd_clone(void *arg, char *name, int namelen, dev_t *dev)
if (*dev != NODEV)
return;
i = devfs_stdclone(name, &s, "ccd", &u);
i = dev_stdclone(name, &s, "ccd", &u);
if (i != 2)
return;
if (u >= numccd)
@ -310,7 +303,6 @@ ccd_clone(void *arg, char *name, int namelen, dev_t *dev)
*dev = make_dev(&ccd_cdevsw, u * 8 + *s - 'a',
UID_ROOT, GID_OPERATOR, 0640, name);
}
#endif DEVFS
/*
* Called by main() during pseudo-device attachment. All we need
@ -348,9 +340,7 @@ ccdattach()
/* XXX: is this necessary? */
for (i = 0; i < numccd; ++i)
ccddevs[i].ccd_dk = -1;
#ifdef DEVFS
EVENTHANDLER_REGISTER(devfs_clone, ccd_clone, 0, 1000);
#endif
EVENTHANDLER_REGISTER(dev_clone, ccd_clone, 0, 1000);
}
static int

View File

@ -61,15 +61,6 @@
#include <sys/socket.h>
#include <net/if.h>
#ifdef __FreeBSD__
#if defined(__FreeBSD__) && __FreeBSD__ == 3
#include "opt_devfs.h"
#endif
#endif /* __FreeBSD__ */
#ifdef __FreeBSD__
#include <machine/i4b_debug.h>
#include <machine/i4b_ioctl.h>

View File

@ -56,15 +56,6 @@ extern cc_t ttydefchars;
#define termioschars(t) memcpy((t)->c_cc, &ttydefchars, sizeof((t)->c_cc))
#endif
#ifdef __FreeBSD__
#if defined(__FreeBSD__) && __FreeBSD__ == 3
#include "opt_devfs.h"
#endif
#endif /* __FreeBSD__ */
#ifdef __NetBSD__
#include <sys/filio.h>
#define bootverbose 0

View File

@ -61,15 +61,6 @@
#include <sys/proc.h>
#include <sys/tty.h>
#ifdef __FreeBSD__
#if defined(__FreeBSD__) && __FreeBSD__ == 3
#include "opt_devfs.h"
#endif
#endif /* __FreeBSD__ */
#ifdef __bsdi__
#include <sys/device.h>
#endif

View File

@ -71,15 +71,6 @@
#include <sys/select.h>
#include <net/if.h>
#ifdef __FreeBSD__
#if defined(__FreeBSD__) && __FreeBSD__ == 3
#include "opt_devfs.h"
#endif
#endif /* __FreeBSD__*/
#ifdef __FreeBSD__
#include <machine/i4b_debug.h>
#include <machine/i4b_ioctl.h>

View File

@ -52,7 +52,6 @@
*/
#include "opt_fdc.h"
#include "opt_devfs.h"
#include "card.h"
#include <sys/param.h>
@ -84,12 +83,6 @@
#include <isa/fdc.h>
#include <isa/rtc.h>
#ifdef DEVFS
#include <sys/ctype.h>
#include <sys/eventhandler.h>
#include <fs/devfs/devfs.h>
#endif
/* misuse a flag to identify format operation */
/* configuration flags */
@ -952,7 +945,6 @@ DRIVER_MODULE(fdc, pccard, fdc_pccard_driver, fdc_devclass, 0, 0);
#endif /* NCARD > 0 */
#ifdef DEVFS
static void fd_clone __P((void *arg, char *name, int namelen, dev_t *dev));
static struct {
@ -993,7 +985,7 @@ fd_clone(arg, name, namelen, dev)
if (*dev != NODEV)
return;
if (devfs_stdclone(name, &n, "fd", &u) != 2)
if (dev_stdclone(name, &n, "fd", &u) != 2)
return;
for (i = 0; ; i++) {
if (fd_suffix[i].match == NULL)
@ -1011,7 +1003,6 @@ fd_clone(arg, name, namelen, dev)
*dev = make_dev_alias(pdev, name);
}
}
#endif
/******************************************************************/
/*
@ -1163,20 +1154,15 @@ static int
fd_attach(device_t dev)
{
struct fd_data *fd;
static int cdevsw_add_done = 0;
fd = device_get_softc(dev);
#ifndef DEVFS
{
static int cdevsw_add_done = 0;
if (!cdevsw_add_done) {
cdevsw_add(&fd_cdevsw); /* XXX */
cdevsw_add_done++;
cdevsw_add(&fd_cdevsw); /* XXX */
cdevsw_add_done++;
}
}
#else
EVENTHANDLER_REGISTER(devfs_clone, fd_clone, 0, 1000);
#endif
EVENTHANDLER_REGISTER(dev_clone, fd_clone, 0, 1000);
make_dev(&fd_cdevsw, (fd->fdu << 6),
UID_ROOT, GID_OPERATOR, 0640, "fd%d", fd->fdu);

View File

@ -43,7 +43,6 @@
*/
#include "opt_init_path.h"
#include "opt_devfs.h"
#include <sys/param.h>
#include <sys/file.h>
@ -62,6 +61,7 @@
#include <sys/vmmeter.h>
#include <sys/unistd.h>
#include <sys/malloc.h>
#include <sys/conf.h>
#include <machine/cpu.h>
@ -499,10 +499,11 @@ start_init(void *dummy)
(void)subyte(--ucp, 'C');
options = 1;
#endif
#ifdef DEVFS
(void)subyte(--ucp, 'd');
options = 1;
#endif
if (devfs_present) {
(void)subyte(--ucp, 'd');
options = 1;
}
if (options == 0)
(void)subyte(--ucp, '-');
(void)subyte(--ucp, '-'); /* leading hyphen */

View File

@ -42,6 +42,7 @@
#include <sys/conf.h>
#include <sys/vnode.h>
#include <sys/queue.h>
#include <sys/ctype.h>
#include <machine/stdarg.h>
#define cdevsw_ALLOCSTART (NUMCDEVSW/2)
@ -69,7 +70,8 @@ static LIST_HEAD(, specinfo) dev_hash[DEVT_HASH];
static LIST_HEAD(, specinfo) dev_free;
devfs_create_t *devfs_create_hook;
devfs_remove_t *devfs_remove_hook;
devfs_destroy_t *devfs_destroy_hook;
int devfs_present;
static int free_devt;
SYSCTL_INT(_debug, OID_AUTO, free_devt, CTLFLAG_RW, &free_devt, 0, "");
@ -352,8 +354,8 @@ make_dev_alias(dev_t pdev, char *fmt, ...)
void
destroy_dev(dev_t dev)
{
if (devfs_remove_hook)
devfs_remove_hook(dev);
if (devfs_destroy_hook)
devfs_destroy_hook(dev);
dev->si_drv1 = 0;
dev->si_drv2 = 0;
dev->si_devsw = 0;
@ -381,3 +383,26 @@ devtoname(dev_t dev)
}
return (dev->si_name);
}
int
dev_stdclone(char *name, char **namep, char *stem, int *unit)
{
int u, i;
if (bcmp(stem, name, strlen(stem)) != 0)
return (0);
i = strlen(stem);
if (!isdigit(name[i]))
return (0);
u = 0;
while (isdigit(name[i])) {
u *= 10;
u += name[i++] - '0';
}
*unit = u;
if (namep)
*namep = &name[i];
if (name[i])
return (2);
return (1);
}

View File

@ -40,7 +40,6 @@
*/
#include "opt_compat.h"
#include "opt_devfs.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/sysproto.h>
@ -62,12 +61,6 @@
#include <vm/vm.h>
#include <vm/vm_extern.h>
#ifdef DEVFS
#include <sys/ctype.h>
#include <sys/eventhandler.h>
#include <fs/devfs/devfs.h>
#endif
static MALLOC_DEFINE(M_FILEDESC, "file desc", "Open file descriptor table");
MALLOC_DEFINE(M_FILE, "file", "Open file structure");
static MALLOC_DEFINE(M_SIGIO, "sigio", "sigio structures");
@ -1322,7 +1315,6 @@ SYSCTL_INT(_kern, KERN_MAXFILES, maxfiles, CTLFLAG_RW,
SYSCTL_INT(_kern, OID_AUTO, openfiles, CTLFLAG_RD,
&nfiles, 0, "System-wide number of open files");
#ifdef DEVFS
static void
fildesc_clone(void *arg, char *name, int namelen, dev_t *dev)
{
@ -1330,14 +1322,13 @@ fildesc_clone(void *arg, char *name, int namelen, dev_t *dev)
if (*dev != NODEV)
return;
if (devfs_stdclone(name, NULL, "fd/", &u) != 1)
if (dev_stdclone(name, NULL, "fd/", &u) != 1)
return;
if (u <= 2)
return;
*dev = make_dev(&fildesc_cdevsw, u, UID_BIN, GID_BIN, 0666, name);
return;
}
#endif
static void
fildesc_drvinit(void *unused)
@ -1350,16 +1341,14 @@ fildesc_drvinit(void *unused)
make_dev_alias(dev, "stdout");
dev = make_dev(&fildesc_cdevsw, 2, UID_BIN, GID_BIN, 0666, "fd/2");
make_dev_alias(dev, "stderr");
#ifdef DEVFS
EVENTHANDLER_REGISTER(devfs_clone, fildesc_clone, 0, 1000);
#else
{
int fd;
EVENTHANDLER_REGISTER(dev_clone, fildesc_clone, 0, 1000);
if (!devfs_present) {
int fd;
for (fd = 3; fd < NUMFDESC; fd++)
make_dev(&fildesc_cdevsw, fd, UID_BIN, GID_BIN, 0666, "fd/%d", fd);
for (fd = 3; fd < NUMFDESC; fd++)
make_dev(&fildesc_cdevsw, fd, UID_BIN, GID_BIN, 0666,
"fd/%d", fd);
}
#endif
}
struct fileops badfileops = {

View File

@ -10,8 +10,6 @@
*
*/
#include "opt_devfs.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@ -22,12 +20,7 @@
#include <sys/malloc.h>
#include <sys/sysctl.h>
#include <machine/md_var.h>
#ifdef DEVFS
#include <sys/eventhandler.h>
#include <fs/devfs/devfs.h>
#include <sys/ctype.h>
#endif
MALLOC_DEFINE(M_DISK, "disk", "disk data");
@ -39,7 +32,6 @@ static d_psize_t diskpsize;
static LIST_HEAD(, disk) disklist = LIST_HEAD_INITIALIZER(&disklist);
#ifdef DEVFS
static void
disk_clone(void *arg, char *name, int namelen, dev_t *dev)
{
@ -95,7 +87,6 @@ disk_clone(void *arg, char *name, int namelen, dev_t *dev)
return;
}
}
#endif
static void
inherit_raw(dev_t pdev, dev_t dev)
@ -138,9 +129,7 @@ disk_create(int unit, struct disk *dp, int flags, struct cdevsw *cdevsw, struct
dp->d_devsw = cdevsw;
LIST_INSERT_HEAD(&disklist, dp, d_list);
if (!once) {
#ifdef DEVFS
EVENTHANDLER_REGISTER(devfs_clone, disk_clone, 0, 1000);
#endif
EVENTHANDLER_REGISTER(dev_clone, disk_clone, 0, 1000);
once++;
}
return (dev);

View File

@ -46,8 +46,6 @@
* $FreeBSD$
*/
#include "opt_devfs.h"
#include <stddef.h>
#include <sys/param.h>
@ -465,16 +463,13 @@ dsioctl(dev, cmd, data, flags, sspp)
S_IFCHR, ssp->dss_oflags, sspp,
lp);
if (error != 0) {
/* XXX should free devfs toks. */
free(lp, M_DEVBUF);
/* XXX should restore devfs toks. */
*sspp = ssp;
return (EBUSY);
}
}
}
/* XXX devfs tokens? */
free(lp, M_DEVBUF);
dsgone(&ssp);
return (0);
@ -693,10 +688,7 @@ dsopen(dev, mode, flags, sspp, lp)
ssp->dss_slices[WHOLE_DISK_SLICE].ds_wlabel = TRUE;
}
/*
* Initialize secondary info for all slices. It is needed for more
* than the current slice in the DEVFS case.
*/
/* Initialize secondary info for all slices. */
for (slice = 0; slice < ssp->dss_nslices; slice++) {
sp = &ssp->dss_slices[slice];
if (sp->ds_label != NULL

View File

@ -39,7 +39,6 @@
* (Actually two drivers, requiring two entries in 'cdevsw')
*/
#include "opt_compat.h"
#include "opt_devfs.h"
#include <sys/param.h>
#include <sys/systm.h>
#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
@ -55,11 +54,6 @@
#include <sys/signalvar.h>
#include <sys/malloc.h>
#ifdef DEVFS
#include <sys/eventhandler.h>
#include <fs/devfs/devfs.h>
#endif
MALLOC_DEFINE(M_PTY, "ptys", "pty data structures");
static void ptsstart __P((struct tty *tp));
@ -177,23 +171,8 @@ ptsopen(dev, flag, devtype, p)
int error;
struct pt_ioctl *pti;
#ifndef DEVFS
{
int minr = lminor(dev);
/*
* If we openned this device, ensure we have the
* next one too, so people can open it.
*/
if (minr < 255) {
dev_t nextdev = makedev(major(dev), minr + 1);
if (!nextdev->si_drv1) {
ptyinit(minr + 1);
}
}
if (!dev->si_drv1)
ptyinit(minor(dev));
}
#endif
if (!dev->si_drv1)
return(ENXIO);
pti = dev->si_drv1;
@ -355,10 +334,8 @@ ptcopen(dev, flag, devtype, p)
register struct tty *tp;
struct pt_ioctl *pti;
#ifndef DEVFS
if (!dev->si_drv1)
ptyinit(minor(dev));
#endif
if (!dev->si_drv1)
return(ENXIO);
tp = dev->si_tty;
@ -826,7 +803,6 @@ ptyioctl(dev, cmd, data, flag, p)
static void ptc_drvinit __P((void *unused));
#ifdef DEVFS
static void pty_clone __P((void *arg, char *name, int namelen, dev_t *dev));
static void
@ -865,20 +841,13 @@ pty_clone(arg, name, namelen, dev)
return;
}
#endif
static void
ptc_drvinit(unused)
void *unused;
{
#ifdef DEVFS
EVENTHANDLER_REGISTER(devfs_clone, pty_clone, 0, 1000);
#else
EVENTHANDLER_REGISTER(dev_clone, pty_clone, 0, 1000);
cdevsw_add(&pts_cdevsw);
cdevsw_add(&ptc_cdevsw);
ptyinit(0);
#endif
}
SYSINIT(ptcdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR_C,ptc_drvinit,NULL)

View File

@ -43,7 +43,6 @@
*/
#include "opt_rootdevname.h"
#include "opt_devfs.h"
#include <sys/param.h>
#include <sys/kernel.h>
@ -63,11 +62,6 @@
#include <ddb/ddb.h>
#endif
#ifdef DEVFS
#include <sys/eventhandler.h>
#include <fs/devfs/devfs.h>
#endif
MALLOC_DEFINE(M_MOUNT, "mount", "vfs mount structure");
#define ROOTNAME "root_device"
@ -326,7 +320,6 @@ gets(char *cp)
*/
dev_t
getdiskbyname(char *name) {
#ifdef DEVFS
char *cp;
dev_t dev;
@ -335,58 +328,8 @@ getdiskbyname(char *name) {
cp += 5;
dev = NODEV;
EVENTHANDLER_INVOKE(devfs_clone, cp, strlen(cp), &dev);
EVENTHANDLER_INVOKE(dev_clone, cp, strlen(cp), &dev);
return (dev);
#else
char *cp;
int cd, unit, slice, part;
dev_t dev;
slice = 0;
part = 0;
cp = rindex(name, '/');
if (cp != NULL) {
name = cp + 1;
}
cp = name;
while (cp != '\0' && (*cp < '0' || *cp > '9'))
cp++;
if (cp == name) {
printf("missing device name\n");
return (NODEV);
}
if (*cp == '\0') {
printf("missing unit number\n");
return (NODEV);
}
unit = *cp - '0';
*cp++ = '\0';
for (cd = 0; cd < NUMCDEVSW; cd++) {
dev = makedev(cd, 0);
if (devsw(dev) != NULL &&
strcmp(devsw(dev)->d_name, name) == 0)
goto gotit;
}
printf("no such device '%s'\n", name);
return (NODEV);
gotit:
while (*cp >= '0' && *cp <= '9')
unit += 10 * unit + *cp++ - '0';
if (*cp == 's' && cp[1] >= '0' && cp[1] <= '9') {
slice = cp[1] - '0' + 1;
cp += 2;
}
if (*cp >= 'a' && *cp <= 'h') {
part = *cp - 'a';
cp++;
}
if (*cp != '\0') {
printf("junk after name\n");
return (NODEV);
}
return (makedev(cd, dkmakeminor(unit, slice, part)));
#endif
}
/*

View File

@ -43,7 +43,6 @@
*/
#include "opt_rootdevname.h"
#include "opt_devfs.h"
#include <sys/param.h>
#include <sys/kernel.h>
@ -63,11 +62,6 @@
#include <ddb/ddb.h>
#endif
#ifdef DEVFS
#include <sys/eventhandler.h>
#include <fs/devfs/devfs.h>
#endif
MALLOC_DEFINE(M_MOUNT, "mount", "vfs mount structure");
#define ROOTNAME "root_device"
@ -326,7 +320,6 @@ gets(char *cp)
*/
dev_t
getdiskbyname(char *name) {
#ifdef DEVFS
char *cp;
dev_t dev;
@ -335,58 +328,8 @@ getdiskbyname(char *name) {
cp += 5;
dev = NODEV;
EVENTHANDLER_INVOKE(devfs_clone, cp, strlen(cp), &dev);
EVENTHANDLER_INVOKE(dev_clone, cp, strlen(cp), &dev);
return (dev);
#else
char *cp;
int cd, unit, slice, part;
dev_t dev;
slice = 0;
part = 0;
cp = rindex(name, '/');
if (cp != NULL) {
name = cp + 1;
}
cp = name;
while (cp != '\0' && (*cp < '0' || *cp > '9'))
cp++;
if (cp == name) {
printf("missing device name\n");
return (NODEV);
}
if (*cp == '\0') {
printf("missing unit number\n");
return (NODEV);
}
unit = *cp - '0';
*cp++ = '\0';
for (cd = 0; cd < NUMCDEVSW; cd++) {
dev = makedev(cd, 0);
if (devsw(dev) != NULL &&
strcmp(devsw(dev)->d_name, name) == 0)
goto gotit;
}
printf("no such device '%s'\n", name);
return (NODEV);
gotit:
while (*cp >= '0' && *cp <= '9')
unit += 10 * unit + *cp++ - '0';
if (*cp == 's' && cp[1] >= '0' && cp[1] <= '9') {
slice = cp[1] - '0' + 1;
cp += 2;
}
if (*cp >= 'a' && *cp <= 'h') {
part = *cp - 'a';
cp++;
}
if (*cp != '\0') {
printf("junk after name\n");
return (NODEV);
}
return (makedev(cd, dkmakeminor(unit, slice, part)));
#endif
}
/*

View File

@ -14,7 +14,7 @@
.PATH: ${.CURDIR}/../../dev/bktr
KMOD= bktr
SRCS= bktr_core.c bktr_os.c bktr_audio.c bktr_tuner.c bktr_card.c \
bktr.h opt_devfs.h opt_bktr.h smbus.h bus_if.h device_if.h \
bktr.h opt_bktr.h smbus.h bus_if.h device_if.h \
pci_if.h vnode_if.h
CLEANFILES= bktr.h smbus.h

View File

@ -2,7 +2,7 @@
.PATH: ${.CURDIR}/../../dev/ccd
KMOD= ccd
SRCS= ccd.c ccd.h vnode_if.h opt_devfs.h
SRCS= ccd.c ccd.h vnode_if.h
NOMAN=
NCCD?= 4

View File

@ -4,7 +4,7 @@
KMOD= coda
SRCS= vnode_if.h \
coda_fbsd.c coda_namecache.c coda_psdev.c coda_subr.c \
coda_venus.c coda_vfsops.c coda_vnops.c opt_devfs.h vcoda.h
coda_venus.c coda_vfsops.c coda_vnops.c vcoda.h
NOMAN=
CLEANFILES= vcoda.h

View File

@ -4,7 +4,7 @@
.PATH: ${.CURDIR}/../../net
KMOD= if_tap
SRCS= if_tap.c opt_devfs.h opt_inet.h vnode_if.h
SRCS= if_tap.c opt_inet.h vnode_if.h
CLEANFILES+= opt_devfs.h opt_inet.h vnode_if.h

View File

@ -2,7 +2,7 @@
.PATH: ${.CURDIR}/../../net
KMOD= if_tun
SRCS= if_tun.c opt_devfs.h opt_inet.h vnode_if.h
SRCS= if_tun.c opt_inet.h vnode_if.h
NOMAN=
NBPF?= 1

View File

@ -2,7 +2,7 @@
.PATH: ${.CURDIR}/../../dev/md
KMOD= md
SRCS= md.c opt_mfs.h opt_md.h opt_devfs.h
SRCS= md.c opt_mfs.h opt_md.h
NOMAN=
.include <bsd.kmod.mk>

View File

@ -1,2 +0,0 @@
/* $FreeBSD$ */

View File

@ -7,7 +7,7 @@ CFLAGS+= -DDEBUG_SVR4
.PATH: ${.CURDIR}/../../dev/streams
KMOD= streams
SRCS= streams.c opt_streams.h opt_devfs.h
SRCS= streams.c opt_streams.h
NOMAN=

View File

@ -2,7 +2,7 @@
.PATH: ${.CURDIR}/../../dev/vn
KMOD= vn
SRCS= vn.c vnode_if.h opt_devfs.h
SRCS= vn.c vnode_if.h
NOMAN=
.include <bsd.kmod.mk>

View File

@ -41,7 +41,6 @@
*/
#include "bpf.h"
#include "opt_devfs.h"
#ifndef __GNUC__
#define inline
@ -79,11 +78,6 @@
#include <sys/kernel.h>
#include <sys/sysctl.h>
#ifdef DEVFS
#include <sys/eventhandler.h>
#include <fs/devfs/devfs.h>
#endif
MALLOC_DEFINE(M_BPF, "BPF", "BPF data");
#if NBPF > 0
@ -1363,7 +1357,6 @@ bpfdetach(ifp)
static void bpf_drvinit __P((void *unused));
#ifdef DEVFS
static void bpf_clone __P((void *arg, char *name, int namelen, dev_t *dev));
static void
@ -1377,24 +1370,20 @@ bpf_clone(arg, name, namelen, dev)
if (*dev != NODEV)
return;
if (devfs_stdclone(name, NULL, "bpf", &u) != 1)
if (dev_stdclone(name, NULL, "bpf", &u) != 1)
return;
/* XXX: minor encoding if u > 255 */
*dev = make_dev(&bpf_cdevsw, u, 0, 0, 0600, "bpf%d", u);
return;
}
#endif
static void
bpf_drvinit(unused)
void *unused;
{
#ifdef DEVFS
EVENTHANDLER_REGISTER(devfs_clone, bpf_clone, 0, 1000);
#else
EVENTHANDLER_REGISTER(dev_clone, bpf_clone, 0, 1000);
cdevsw_add(&bpf_cdevsw);
#endif
}
SYSINIT(bpfdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,bpf_drvinit,NULL)

View File

@ -17,7 +17,6 @@
*/
#include "opt_inet.h"
#include "opt_devfs.h"
#include <sys/param.h>
#include <sys/proc.h>
@ -51,11 +50,6 @@
#include <net/if_tunvar.h>
#include <net/if_tun.h>
#ifdef DEVFS
#include <sys/eventhandler.h>
#include <fs/devfs/devfs.h>
#endif
static MALLOC_DEFINE(M_TUN, "tun", "Tunnel Interface");
static void tunattach __P((void *));
@ -97,7 +91,6 @@ static struct cdevsw tun_cdevsw = {
/* bmaj */ -1
};
#ifdef DEVFS
static void tun_clone __P((void *arg, char *name, int namelen, dev_t *dev));
static void
@ -111,26 +104,21 @@ tun_clone(arg, name, namelen, dev)
if (*dev != NODEV)
return;
if (devfs_stdclone(name, NULL, "tun", &u) != 1)
if (dev_stdclone(name, NULL, "tun", &u) != 1)
return;
/* XXX: minor encoding if u > 255 */
*dev = make_dev(&tun_cdevsw, u,
UID_UUCP, GID_DIALER, 0600, "tun%d", u);
}
#endif
static void
tunattach(dummy)
void *dummy;
{
#ifdef DEVFS
EVENTHANDLER_REGISTER(devfs_clone, tun_clone, 0, 1000);
#else
EVENTHANDLER_REGISTER(dev_clone, tun_clone, 0, 1000);
cdevsw_add(&tun_cdevsw);
#endif
}
static void

View File

@ -45,6 +45,7 @@
#define _SYS_CONF_H_
#include <sys/queue.h>
#include <sys/eventhandler.h>
#define SPECNAMELEN 15
@ -135,10 +136,6 @@ typedef int l_rint_t __P((int c, struct tty *tp));
typedef int l_start_t __P((struct tty *tp));
typedef int l_modem_t __P((struct tty *tp, int flag));
/* This is type of the function DEVFS uses to hook into the kernel with */
typedef void devfs_create_t __P((dev_t dev));
typedef void devfs_remove_t __P((dev_t dev));
/*
* XXX: The dummy argument can be used to do what strategy1() never
* did anywhere: Create a per device flag to lock the device during
@ -299,7 +296,13 @@ int lminor __P((dev_t dev));
void setconf __P((void));
dev_t getdiskbyname(char *name);
/* This is type of the function DEVFS uses to hook into the kernel with */
typedef void devfs_create_t __P((dev_t dev));
typedef void devfs_destroy_t __P((dev_t dev));
extern devfs_create_t *devfs_create_hook;
extern devfs_destroy_t *devfs_destroy_hook;
extern int devfs_present;
/*
* XXX: This included for when DEVFS resurfaces
@ -316,6 +319,10 @@ extern devfs_create_t *devfs_create_hook;
#define GID_GAMES 13
#define GID_DIALER 68
typedef void (*dev_clone_fn) __P((void *arg, char *name, int namelen, dev_t *result));
int dev_stdclone __P((char *name, char **namep, char *stem, int *unit));
EVENTHANDLER_DECLARE(dev_clone, dev_clone_fn);
#endif /* _KERNEL */
#endif /* !_SYS_CONF_H_ */

View File

@ -50,15 +50,6 @@ struct diskslice {
u_char ds_name[16]; /* slice name */
#endif
struct disklabel *ds_label; /* BSD label, if any */
void *ds_dev; /* devfs token for raw whole slice */
#ifdef MAXPARTITIONS /* XXX don't depend on disklabel.h */
#if MAXPARTITIONS != 8 /* but check consistency if possible */
#error "inconsistent MAXPARTITIONS"
#endif
#else
#define MAXPARTITIONS 8
#endif
void *ds_devs[MAXPARTITIONS]; /* XXX s.b. in label */
u_char ds_openmask; /* devs open */
u_char ds_wlabel; /* nonzero if label is writable */
};

View File

@ -45,6 +45,7 @@
#define _SYS_CONF_H_
#include <sys/queue.h>
#include <sys/eventhandler.h>
#define SPECNAMELEN 15
@ -135,10 +136,6 @@ typedef int l_rint_t __P((int c, struct tty *tp));
typedef int l_start_t __P((struct tty *tp));
typedef int l_modem_t __P((struct tty *tp, int flag));
/* This is type of the function DEVFS uses to hook into the kernel with */
typedef void devfs_create_t __P((dev_t dev));
typedef void devfs_remove_t __P((dev_t dev));
/*
* XXX: The dummy argument can be used to do what strategy1() never
* did anywhere: Create a per device flag to lock the device during
@ -299,7 +296,13 @@ int lminor __P((dev_t dev));
void setconf __P((void));
dev_t getdiskbyname(char *name);
/* This is type of the function DEVFS uses to hook into the kernel with */
typedef void devfs_create_t __P((dev_t dev));
typedef void devfs_destroy_t __P((dev_t dev));
extern devfs_create_t *devfs_create_hook;
extern devfs_destroy_t *devfs_destroy_hook;
extern int devfs_present;
/*
* XXX: This included for when DEVFS resurfaces
@ -316,6 +319,10 @@ extern devfs_create_t *devfs_create_hook;
#define GID_GAMES 13
#define GID_DIALER 68
typedef void (*dev_clone_fn) __P((void *arg, char *name, int namelen, dev_t *result));
int dev_stdclone __P((char *name, char **namep, char *stem, int *unit));
EVENTHANDLER_DECLARE(dev_clone, dev_clone_fn);
#endif /* _KERNEL */
#endif /* !_SYS_CONF_H_ */