diff options
author | phk <phk@FreeBSD.org> | 2000-08-20 21:34:39 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2000-08-20 21:34:39 +0000 |
commit | b648921accec69a7e5c83e915ded3037cbca7f3d (patch) | |
tree | fa2e43c05e3c1d31732408f806d72db091c03d14 /sys/dev | |
parent | 1c624ac57c791b6df4b51eb86e04dc404052c700 (diff) | |
download | FreeBSD-src-b648921accec69a7e5c83e915ded3037cbca7f3d.zip FreeBSD-src-b648921accec69a7e5c83e915ded3037cbca7f3d.tar.gz |
Remove all traces of Julians DEVFS (incl from kern/subr_diskslice.c)
Remove old DEVFS support fields from dev_t.
Make uid, gid & mode members of dev_t and set them in make_dev().
Use correct uid, gid & mode in make_dev in disk minilayer.
Add support for registering alias names for a dev_t using the
new function make_dev_alias(). These will show up as symlinks
in DEVFS.
Use makedev() rather than make_dev() for MFSs magic devices to prevent
DEVFS from noticing this abuse.
Add a field for DEVFS inode number in dev_t.
Add new DEVFS in fs/devfs.
Add devfs cloning to:
disk minilayer (ie: ad(4), sd(4), cd(4) etc etc)
md(4), tun(4), bpf(4), fd(4)
If DEVFS add -d flag to /sbin/inits args to make it mount devfs.
Add commented out DEVFS to GENERIC
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/bktr/bktr_os.c | 14 | ||||
-rw-r--r-- | sys/dev/fdc/fdc.c | 88 | ||||
-rw-r--r-- | sys/dev/md/md.c | 68 |
3 files changed, 135 insertions, 35 deletions
diff --git a/sys/dev/bktr/bktr_os.c b/sys/dev/bktr/bktr_os.c index 060e996..45ff376 100644 --- a/sys/dev/bktr/bktr_os.c +++ b/sys/dev/bktr/bktr_os.c @@ -80,12 +80,6 @@ #include <vm/pmap.h> #include <vm/vm_extern.h> -#if (__FreeBSD_version < 400000) -#ifdef DEVFS -#include <sys/devfsext.h> -#endif /* DEVFS */ -#endif - #if (__FreeBSD_version >=400000) || (NSMBUS > 0) #include <sys/bus.h> /* used by smbus and newbus */ #endif @@ -972,14 +966,6 @@ bktr_attach( pcici_t tag, int unit ) /* call the common attach code */ common_bktr_attach( bktr, unit, fun, rev ); - -#ifdef DEVFS - /* XXX This just throw away the token, which should probably be fixed when - DEVFS is finally made really operational. */ - devfs_add_devswf(&bktr_cdevsw, unit, DV_CHR, 0, 0, 0444, "bktr%d", unit); - devfs_add_devswf(&bktr_cdevsw, unit+16, DV_CHR, 0, 0, 0444, "tuner%d", unit); - devfs_add_devswf(&bktr_cdevsw, unit+32, DV_CHR, 0, 0, 0444, "vbi%d", unit); -#endif /* DEVFS */ } diff --git a/sys/dev/fdc/fdc.c b/sys/dev/fdc/fdc.c index d901250..dd513e9 100644 --- a/sys/dev/fdc/fdc.c +++ b/sys/dev/fdc/fdc.c @@ -52,6 +52,7 @@ */ #include "opt_fdc.h" +#include "opt_devfs.h" #include "card.h" #include <sys/param.h> @@ -83,6 +84,12 @@ #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 */ @@ -945,6 +952,67 @@ 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 { + char *match; + int minor; + int link; +} fd_suffix[] = { + { "a", 0, 1 }, + { "b", 0, 1 }, + { "c", 0, 1 }, + { "d", 0, 1 }, + { "e", 0, 1 }, + { "f", 0, 1 }, + { "g", 0, 1 }, + { "h", 0, 1 }, + { ".1720", 1, 0 }, + { ".1480", 2, 0 }, + { ".1440", 3, 0 }, + { ".1200", 4, 0 }, + { ".820", 5, 0 }, + { ".800", 6, 0 }, + { ".720", 7, 0 }, + { ".360", 8, 0 }, + { ".640", 9, 0 }, + { ".1232", 10, 0 }, + { 0, 0 } +}; +static void +fd_clone(arg, name, namelen, dev) + void *arg; + char *name; + int namelen; + dev_t *dev; +{ + int u, d, i; + char *n; + dev_t pdev; + + if (*dev != NODEV) + return; + if (devfs_stdclone(name, &n, "fd", &u) != 2) + return; + for (i = 0; ; i++) { + if (fd_suffix[i].match == NULL) + return; + if (strcmp(n, fd_suffix[i].match)) + continue; + d = fd_suffix[i].minor; + break; + } + if (fd_suffix[i].link == 0) { + *dev = make_dev(&fd_cdevsw, (u << 6) + d, + UID_ROOT, GID_OPERATOR, 0640, name); + } else { + pdev = makedev(fd_cdevsw.d_maj, (u << 6) + d); + *dev = make_dev_alias(pdev, name); + } +} +#endif + /******************************************************************/ /* * devices attached to the controller section. @@ -1095,26 +1163,22 @@ static int fd_attach(device_t dev) { struct fd_data *fd; -#if 0 - int i; - int mynor; - int typemynor; - int typesize; -#endif - 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++; } - make_dev(&fd_cdevsw, (fd->fdu << 6), - UID_ROOT, GID_OPERATOR, 0640, "rfd%d", fd->fdu); - -#if 0 - /* Other make_dev() go here. */ + } +#else + EVENTHANDLER_REGISTER(devfs_clone, fd_clone, 0, 1000); #endif + make_dev(&fd_cdevsw, (fd->fdu << 6), + UID_ROOT, GID_OPERATOR, 0640, "fd%d", fd->fdu); /* * Export the drive to the devstat interface. diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c index 725b407..59cd8d7 100644 --- a/sys/dev/md/md.c +++ b/sys/dev/md/md.c @@ -11,7 +11,8 @@ */ #include "opt_mfs.h" /* We have adopted some tasks from MFS */ -#include "opt_md.h" /* We have adopted some tasks from MFS */ +#include "opt_md.h" +#include "opt_devfs.h" #include <sys/param.h> #include <sys/systm.h> @@ -23,6 +24,12 @@ #include <sys/malloc.h> #include <sys/sysctl.h> #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) @@ -52,7 +59,7 @@ static u_char end_mfs_root[] __unused = "MFS Filesystem had better STOP here"; static int mdrootready; -static void mdcreate_malloc(void); +static void mdcreate_malloc(int unit); #define CDEV_MAJOR 95 #define BDEV_MAJOR 22 @@ -82,8 +89,11 @@ static struct cdevsw md_cdevsw = { static struct cdevsw mddisk_cdevsw; +static LIST_HEAD(, md_s) md_softc_list = LIST_HEAD_INITIALIZER(&md_softc_list); + struct md_s { int unit; + LIST_ENTRY(md_s) list; struct devstat stats; struct bio_queue_head bio_queue; struct disk disk; @@ -114,8 +124,10 @@ 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) - mdcreate_malloc(); + mdcreate_malloc(-1); +#endif dl = &sc->disk.d_label; bzero(dl, sizeof(*dl)); @@ -341,13 +353,21 @@ mdstrategy_preload(struct bio *bp) } static struct md_s * -mdcreate(void) +mdcreate(int unit) { struct md_s *sc; + if (unit == -1) + unit = mdunits++; + /* Make sure this unit isn't already in action */ + LIST_FOREACH(sc, &md_softc_list, list) { + if (sc->unit == unit) + return (NULL); + } MALLOC(sc, struct md_s *,sizeof(*sc), M_MD, M_WAITOK); bzero(sc, sizeof(*sc)); - sc->unit = mdunits++; + LIST_INSERT_HEAD(&md_softc_list, sc, list); + sc->unit = unit; bioq_init(&sc->bio_queue); devstat_add_entry(&sc->stats, "md", sc->unit, DEV_BSIZE, DEVSTAT_NO_ORDERED_TAGS, @@ -363,7 +383,7 @@ mdcreate_preload(u_char *image, unsigned length) { struct md_s *sc; - sc = mdcreate(); + sc = mdcreate(-1); sc->type = MD_PRELOAD; sc->nsect = length / DEV_BSIZE; sc->pl_ptr = image; @@ -374,11 +394,14 @@ mdcreate_preload(u_char *image, unsigned length) } static void -mdcreate_malloc(void) +mdcreate_malloc(int unit) { struct md_s *sc; - sc = mdcreate(); + sc = mdcreate(unit); + if (sc == NULL) + return; + sc->type = MD_MALLOC; sc->nsect = MD_NSECT; /* for now */ @@ -388,6 +411,28 @@ mdcreate_malloc(void) printf("md%d: Malloc disk\n", sc->unit); } +#ifdef DEVFS +static void +md_clone (void *arg, char *name, int namelen, dev_t *dev) +{ + int i, u; + + if (*dev != NODEV) + return; + i = devfs_stdclone(name, NULL, "md", &u); + if (i == 0) + return; + /* XXX: should check that next char is [\0sa-h] */ + /* + * Now we cheat: We just create the disk, but don't match. + * Since we run before it, subr_disk.c::disk_clone() will + * find our disk and match the sought for device. + */ + mdcreate_malloc(u); + return; +} +#endif + static void md_drvinit(void *unused) { @@ -418,7 +463,11 @@ md_drvinit(void *unused) mdunits, name, len, ptr); mdcreate_preload(ptr, len); } - mdcreate_malloc(); +#ifdef DEVFS + EVENTHANDLER_REGISTER(devfs_clone, md_clone, 0, 999); +#else + mdcreate_malloc(-1); +#endif } SYSINIT(mddev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR, md_drvinit,NULL) @@ -433,3 +482,4 @@ md_takeroot(void *junk) SYSINIT(md_root, SI_SUB_MOUNT_ROOT, SI_ORDER_FIRST, md_takeroot, NULL); #endif + |