From 71e4fff823e1f5d08467df93c62f445b7d88d142 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Fri, 26 Nov 1999 20:08:44 +0000 Subject: [PATCH] Retire MFS_ROOT and MFS_ROOT_SIZE options from the MFS implementation. Add MD_ROOT and MD_ROOT_SIZE options to the md driver. Make the md driver handle MFS_ROOT and MFS_ROOT_SIZE options for compatibility. Add md driver to GENERIC, PCCARD and LINT. This is a cleanup which removes the need for some of the worse hacks in MFS: We really want to have a rootvnode but MFS on a preloaded image doesn't really have one. md is a true device, so it is less trouble. This has been tested with make release, and if people remember to add the "md" pseudo-device to their kernels, PicoBSD should be just fine as well. If people have no other use for MFS, it can be removed from the kernel. --- sys/amd64/conf/GENERIC | 3 +- sys/conf/NOTES | 11 +- sys/conf/options | 2 + sys/dev/md/md.c | 292 ++++++++++++++++++++++++++------------- sys/i386/conf/GENERIC | 3 +- sys/i386/conf/LINT | 11 +- sys/i386/conf/NOTES | 11 +- sys/i386/conf/PCCARD | 3 +- sys/kern/vfs_conf.c | 4 + sys/kern/vfs_mount.c | 4 + sys/sys/conf.h | 1 + sys/sys/linedisc.h | 1 + sys/ufs/mfs/mfs_vfsops.c | 121 ---------------- 13 files changed, 234 insertions(+), 233 deletions(-) diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC index 60c5e9a99e88..81d9e00eef91 100644 --- a/sys/amd64/conf/GENERIC +++ b/sys/amd64/conf/GENERIC @@ -31,8 +31,8 @@ options MATH_EMULATE #Support for x87 emulation options INET #InterNETworking options FFS #Berkeley Fast Filesystem options FFS_ROOT #FFS usable as root device [keep this!] +options MD_ROOT #MD is a potential root device options MFS #Memory Filesystem -options MFS_ROOT #MFS usable as root device, "MFS" req'ed options NFS #Network Filesystem options NFS_ROOT #NFS usable as root device, "NFS" req'ed options MSDOSFS #MSDOS Filesystem @@ -206,6 +206,7 @@ pseudo-device ppp 1 # Kernel PPP pseudo-device tun # Packet tunnel. pseudo-device pty # Pseudo-ttys (telnet etc) pseudo-device gzip # Exec gzipped a.out's +pseudo-device md # Memory "disks" # The `bpf' pseudo-device enables the Berkeley Packet Filter. # Be aware of the administrative consequences of enabling this! diff --git a/sys/conf/NOTES b/sys/conf/NOTES index 00ee4f4df628..9bd94fc4d34b 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -604,7 +604,6 @@ options UNION #Union filesystem # The xFS_ROOT options REQUIRE the associated ``options xFS'' options CD9660_ROOT #CD-ROM usable as root device options FFS_ROOT #FFS usable as root device -options MFS_ROOT #MFS usable as root device options NFS_ROOT #NFS usable as root device # This code is still experimental (e.g. doesn't handle disk slices well). # Also, 'options MFS' is currently incompatible with DEVFS. @@ -620,9 +619,13 @@ options DEVFS #devices filesystem # #options SOFTUPDATES -# Make space in the kernel for a MFS root filesystem. Define to the number -# of kilobytes to reserve for the filesystem. -options MFS_ROOT_SIZE=10 +# Make space in the kernel for a root filesystem on a md device. +# Define to the number of kilobytes to reserve for the filesystem. +options MD_ROOT_SIZE=10 + +# Make the md device a potential root device, either with preloaded +# images of type mfs_root or md_root. +options MD_ROOT # Allow this many swap-devices. options NSWAPDEV=20 diff --git a/sys/conf/options b/sys/conf/options index bb38eb4c02bc..130e535eb186 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -55,6 +55,8 @@ DEVFS HW_WDOG KTRACE MD5 +MD_ROOT opt_md.h +MD_ROOT_SIZE opt_md.h MFS_ROOT opt_mfs.h MFS_ROOT_SIZE opt_mfs.h NTIMECOUNTER opt_ntp.h diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c index 66d4a013e164..1b9ba0f82473 100644 --- a/sys/dev/md/md.c +++ b/sys/dev/md/md.c @@ -10,6 +10,9 @@ * */ +#include "opt_mfs.h" /* We have adopted some tasks from MFS */ +#include "opt_md.h" /* We have adopted some tasks from MFS */ + #include #include #include @@ -28,13 +31,33 @@ MALLOC_DEFINE(M_MD, "MD disk", "Memory Disk"); MALLOC_DEFINE(M_MDSECT, "MD sectors", "Memory Disk Sectors"); -static int md_debug = 0; +static int md_debug; SYSCTL_INT(_debug, OID_AUTO, mddebug, CTLFLAG_RW, &md_debug, 0, ""); +#if defined(MFS_ROOT) && !defined(MD_ROOT) +#define MD_ROOT MFS_ROOT +#warning "option MFS_ROOT has been superceeded by MD_ROOT" +#endif + +#if defined(MFS_ROOT_SIZE) && !defined(MD_ROOT_SIZE) +#define MD_ROOT_SIZE MFS_ROOT_SIZE +#warning "option MFS_ROOT_SIZE has been superceeded by MD_ROOT_SIZE" +#endif + +#if defined(MD_ROOT) && defined(MD_ROOT_SIZE) +/* Image gets put here: */ +static u_char mfs_root[MD_ROOT_SIZE*1024] = "MFS Filesystem goes here"; +static u_char end_mfs_root[] __unused = "MFS Filesystem had better STOP here"; +#endif + +static int mdrootready; + #define CDEV_MAJOR 95 #define BDEV_MAJOR 22 static d_strategy_t mdstrategy; +static d_strategy_t mdstrategy_preload; +static d_strategy_t mdstrategy_malloc; static d_open_t mdopen; static d_ioctl_t mdioctl; @@ -51,10 +74,9 @@ static struct cdevsw md_cdevsw = { /* maj */ CDEV_MAJOR, /* dump */ nodump, /* psize */ nopsize, - /* flags */ D_DISK | D_CANFREE, + /* flags */ D_DISK | D_CANFREE | D_MEMDISK, /* bmaj */ BDEV_MAJOR }; -static struct cdevsw mddisk_cdevsw; struct md_s { int unit; @@ -65,6 +87,7 @@ struct md_s { int busy; enum {MD_MALLOC, MD_PRELOAD} type; unsigned nsect; + struct cdevsw devsw; /* MD_MALLOC related fields */ unsigned nsecp; @@ -113,6 +136,26 @@ mdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) static void mdstrategy(struct buf *bp) +{ + struct md_s *sc; + + if (md_debug > 1) + printf("mdstrategy(%p) %s %lx, %d, %ld, %p)\n", + bp, devtoname(bp->b_dev), bp->b_flags, bp->b_blkno, + bp->b_bcount / DEV_BSIZE, bp->b_data); + + sc = bp->b_dev->si_drv1; + if (sc->type == MD_MALLOC) { + mdstrategy_malloc(bp); + } else { + mdstrategy_preload(bp); + } + return; +} + + +static void +mdstrategy_malloc(struct buf *bp) { int s, i; struct md_s *sc; @@ -121,7 +164,7 @@ mdstrategy(struct buf *bp) unsigned secno, nsec, secval, uc; if (md_debug > 1) - printf("mdstrategy(%p) %s %lx, %d, %ld, %p)\n", + printf("mdstrategy_malloc(%p) %s %lx, %d, %ld, %p)\n", bp, devtoname(bp->b_dev), bp->b_flags, bp->b_blkno, bp->b_bcount / DEV_BSIZE, bp->b_data); @@ -155,90 +198,79 @@ mdstrategy(struct buf *bp) else dop = DEVSTAT_WRITE; - if (sc->type == MD_MALLOC) { - nsec = bp->b_bcount / DEV_BSIZE; - secno = bp->b_pblkno; - dst = bp->b_data; - while (nsec--) { + nsec = bp->b_bcount / DEV_BSIZE; + secno = bp->b_pblkno; + dst = bp->b_data; + while (nsec--) { - if (secno < sc->nsecp) { - secpp = &sc->secp[secno]; - if ((u_int)*secpp > 255) { - secp = *secpp; - secval = 0; - } else { - secp = 0; - secval = (u_int) *secpp; - } - } else { - secpp = 0; - secp = 0; + if (secno < sc->nsecp) { + secpp = &sc->secp[secno]; + if ((u_int)*secpp > 255) { + secp = *secpp; secval = 0; - } - if (md_debug > 2) - printf("%lx %p %p %d\n", bp->b_flags, secpp, secp, secval); - - if (bp->b_flags & B_FREEBUF) { - if (secpp) { - if (secp) - FREE(secp, M_MDSECT); - *secpp = 0; - } - } else if (bp->b_flags & B_READ) { - if (secp) { - bcopy(secp, dst, DEV_BSIZE); - } else if (secval) { - for (i = 0; i < DEV_BSIZE; i++) - dst[i] = secval; - } else { - bzero(dst, DEV_BSIZE); - } } else { - uc = dst[0]; - for (i = 1; i < DEV_BSIZE; i++) - if (dst[i] != uc) - break; - if (i == DEV_BSIZE && !uc) { + secp = 0; + secval = (u_int) *secpp; + } + } else { + secpp = 0; + secp = 0; + secval = 0; + } + if (md_debug > 2) + printf("%lx %p %p %d\n", bp->b_flags, secpp, secp, secval); + + if (bp->b_flags & B_FREEBUF) { + if (secpp) { + if (secp) + FREE(secp, M_MDSECT); + *secpp = 0; + } + } else if (bp->b_flags & B_READ) { + if (secp) { + bcopy(secp, dst, DEV_BSIZE); + } else if (secval) { + for (i = 0; i < DEV_BSIZE; i++) + dst[i] = secval; + } else { + bzero(dst, DEV_BSIZE); + } + } else { + uc = dst[0]; + for (i = 1; i < DEV_BSIZE; i++) + if (dst[i] != uc) + break; + if (i == DEV_BSIZE && !uc) { + if (secp) + FREE(secp, M_MDSECT); + if (secpp) + *secpp = (u_char *)uc; + } else { + if (!secpp) { + MALLOC(secpp, u_char **, (secno + nsec + 1) * sizeof(u_char *), M_MD, M_WAITOK); + bzero(secpp, (secno + nsec + 1) * sizeof(u_char *)); + bcopy(sc->secp, secpp, sc->nsecp * sizeof(u_char *)); + FREE(sc->secp, M_MD); + sc->secp = secpp; + sc->nsecp = secno + nsec + 1; + secpp = &sc->secp[secno]; + } + if (i == DEV_BSIZE) { if (secp) FREE(secp, M_MDSECT); - if (secpp) - *secpp = (u_char *)uc; + *secpp = (u_char *)uc; } else { - if (!secpp) { - MALLOC(secpp, u_char **, (secno + nsec + 1) * sizeof(u_char *), M_MD, M_WAITOK); - bzero(secpp, (secno + nsec + 1) * sizeof(u_char *)); - bcopy(sc->secp, secpp, sc->nsecp * sizeof(u_char *)); - FREE(sc->secp, M_MD); - sc->secp = secpp; - sc->nsecp = secno + nsec + 1; - secpp = &sc->secp[secno]; - } - if (i == DEV_BSIZE) { - if (secp) - FREE(secp, M_MDSECT); - *secpp = (u_char *)uc; - } else { - if (!secp) - MALLOC(secp, u_char *, DEV_BSIZE, M_MDSECT, M_WAITOK); - bcopy(dst, secp, DEV_BSIZE); + if (!secp) + MALLOC(secp, u_char *, DEV_BSIZE, M_MDSECT, M_WAITOK); + bcopy(dst, secp, DEV_BSIZE); - *secpp = secp; - } + *secpp = secp; } } - secno++; - dst += DEV_BSIZE; - } - } else { - if (bp->b_flags & B_FREEBUF) { - /* nothing */ - } else if (bp->b_flags & B_READ) { - bcopy(sc->pl_ptr + (secno << DEV_BSHIFT), bp->b_data, bp->b_bcount); - } else { - bcopy(bp->b_data, sc->pl_ptr + (secno << DEV_BSHIFT), bp->b_bcount); } + secno++; + dst += DEV_BSIZE; } - bp->b_resid = 0; devstat_end_transaction_buf(&sc->stats, bp); biodone(bp); @@ -248,8 +280,62 @@ mdstrategy(struct buf *bp) return; } + static void -mdcreate_preload(u_char *image, unsigned length) +mdstrategy_preload(struct buf *bp) +{ + int s; + struct md_s *sc; + devstat_trans_flags dop; + + if (md_debug > 1) + printf("mdstrategy_preload(%p) %s %lx, %d, %ld, %p)\n", + bp, devtoname(bp->b_dev), bp->b_flags, bp->b_blkno, + bp->b_bcount / DEV_BSIZE, bp->b_data); + + sc = bp->b_dev->si_drv1; + + s = splbio(); + + bufqdisksort(&sc->buf_queue, bp); + + if (sc->busy) { + splx(s); + return; + } + + sc->busy++; + + while (1) { + bp = bufq_first(&sc->buf_queue); + if (bp) + bufq_remove(&sc->buf_queue, bp); + splx(s); + if (!bp) + break; + + devstat_start_transaction(&sc->stats); + + if (bp->b_flags & B_FREEBUF) { + dop = DEVSTAT_NO_DATA; + } else if (bp->b_flags & B_READ) { + dop = DEVSTAT_READ; + bcopy(sc->pl_ptr + (bp->b_pblkno << DEV_BSHIFT), bp->b_data, bp->b_bcount); + } else { + dop = DEVSTAT_WRITE; + bcopy(bp->b_data, sc->pl_ptr + (bp->b_pblkno << DEV_BSHIFT), bp->b_bcount); + } + bp->b_resid = 0; + devstat_end_transaction_buf(&sc->stats, bp); + biodone(bp); + s = splbio(); + } + sc->busy = 0; + return; +} + +static struct md_s * +mdcreate(struct cdevsw *devsw) { struct md_s *sc; @@ -260,13 +346,25 @@ mdcreate_preload(u_char *image, unsigned length) bufq_init(&sc->buf_queue); devstat_add_entry(&sc->stats, "md", sc->unit, DEV_BSIZE, DEVSTAT_NO_ORDERED_TAGS, - DEVSTAT_TYPE_DIRECT | DEVSTAT_TYPE_IF_OTHER, 0x190); - sc->dev = disk_create(sc->unit, &sc->disk, 0, - &md_cdevsw, &mddisk_cdevsw); + DEVSTAT_TYPE_DIRECT | DEVSTAT_TYPE_IF_OTHER, + DEVSTAT_PRIORITY_OTHER); + sc->dev = disk_create(sc->unit, &sc->disk, 0, devsw, &sc->devsw); sc->dev->si_drv1 = sc; + return (sc); +} + +static void +mdcreate_preload(u_char *image, unsigned length) +{ + struct md_s *sc; + + sc = mdcreate(&md_cdevsw); sc->nsect = length / DEV_BSIZE; sc->pl_ptr = image; sc->pl_len = length; + + if (sc->unit == 0) + mdrootready = 1; } static void @@ -274,21 +372,8 @@ mdcreate_malloc(void) { struct md_s *sc; - MALLOC(sc, struct md_s *,sizeof(*sc), M_MD, M_WAITOK); - bzero(sc, sizeof(*sc)); - sc->unit = mdunits++; - sc->type = MD_MALLOC; + sc = mdcreate(&md_cdevsw); - bufq_init(&sc->buf_queue); - - devstat_add_entry(&sc->stats, "md", sc->unit, DEV_BSIZE, - DEVSTAT_NO_ORDERED_TAGS, - DEVSTAT_TYPE_DIRECT | DEVSTAT_TYPE_IF_OTHER, 0x190); - - sc->dev = disk_create(sc->unit, &sc->disk, 0, - &md_cdevsw, &mddisk_cdevsw); - - sc->dev->si_drv1 = sc; sc->nsect = MDNSECT; /* for now */ MALLOC(sc->secp, u_char **, sizeof(u_char *), M_MD, M_WAITOK); bzero(sc->secp, sizeof(u_char *)); @@ -304,6 +389,9 @@ md_drvinit(void *unused) u_char *ptr, *name, *type; unsigned len; +#ifdef MD_ROOT_SIZE + mdcreate_preload(mfs_root, MD_ROOT_SIZE*1024); +#endif mod = NULL; while ((mod = preload_search_next_name(mod)) != NULL) { name = (char *)preload_search_info(mod, MODINFO_NAME); @@ -312,7 +400,7 @@ md_drvinit(void *unused) continue; if (type == NULL) continue; - if (strcmp(type, "md_image")) + if (strcmp(type, "md_image") && strcmp(type, "mfs_root")) continue; c = preload_search_info(mod, MODINFO_ADDR); ptr = *(u_char **)c; @@ -325,5 +413,15 @@ md_drvinit(void *unused) mdcreate_malloc(); } -SYSINIT(ptcdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR, md_drvinit,NULL) +SYSINIT(mddev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR, md_drvinit,NULL) +#ifdef MD_ROOT +static void +md_takeroot(void *junk) +{ + if (mdrootready) + rootdevnames[0] = "ufs:/dev/md0c"; +} + +SYSINIT(md_root, SI_SUB_MOUNT_ROOT, SI_ORDER_FIRST, md_takeroot, NULL); +#endif diff --git a/sys/i386/conf/GENERIC b/sys/i386/conf/GENERIC index 60c5e9a99e88..81d9e00eef91 100644 --- a/sys/i386/conf/GENERIC +++ b/sys/i386/conf/GENERIC @@ -31,8 +31,8 @@ options MATH_EMULATE #Support for x87 emulation options INET #InterNETworking options FFS #Berkeley Fast Filesystem options FFS_ROOT #FFS usable as root device [keep this!] +options MD_ROOT #MD is a potential root device options MFS #Memory Filesystem -options MFS_ROOT #MFS usable as root device, "MFS" req'ed options NFS #Network Filesystem options NFS_ROOT #NFS usable as root device, "NFS" req'ed options MSDOSFS #MSDOS Filesystem @@ -206,6 +206,7 @@ pseudo-device ppp 1 # Kernel PPP pseudo-device tun # Packet tunnel. pseudo-device pty # Pseudo-ttys (telnet etc) pseudo-device gzip # Exec gzipped a.out's +pseudo-device md # Memory "disks" # The `bpf' pseudo-device enables the Berkeley Packet Filter. # Be aware of the administrative consequences of enabling this! diff --git a/sys/i386/conf/LINT b/sys/i386/conf/LINT index 00ee4f4df628..9bd94fc4d34b 100644 --- a/sys/i386/conf/LINT +++ b/sys/i386/conf/LINT @@ -604,7 +604,6 @@ options UNION #Union filesystem # The xFS_ROOT options REQUIRE the associated ``options xFS'' options CD9660_ROOT #CD-ROM usable as root device options FFS_ROOT #FFS usable as root device -options MFS_ROOT #MFS usable as root device options NFS_ROOT #NFS usable as root device # This code is still experimental (e.g. doesn't handle disk slices well). # Also, 'options MFS' is currently incompatible with DEVFS. @@ -620,9 +619,13 @@ options DEVFS #devices filesystem # #options SOFTUPDATES -# Make space in the kernel for a MFS root filesystem. Define to the number -# of kilobytes to reserve for the filesystem. -options MFS_ROOT_SIZE=10 +# Make space in the kernel for a root filesystem on a md device. +# Define to the number of kilobytes to reserve for the filesystem. +options MD_ROOT_SIZE=10 + +# Make the md device a potential root device, either with preloaded +# images of type mfs_root or md_root. +options MD_ROOT # Allow this many swap-devices. options NSWAPDEV=20 diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES index 00ee4f4df628..9bd94fc4d34b 100644 --- a/sys/i386/conf/NOTES +++ b/sys/i386/conf/NOTES @@ -604,7 +604,6 @@ options UNION #Union filesystem # The xFS_ROOT options REQUIRE the associated ``options xFS'' options CD9660_ROOT #CD-ROM usable as root device options FFS_ROOT #FFS usable as root device -options MFS_ROOT #MFS usable as root device options NFS_ROOT #NFS usable as root device # This code is still experimental (e.g. doesn't handle disk slices well). # Also, 'options MFS' is currently incompatible with DEVFS. @@ -620,9 +619,13 @@ options DEVFS #devices filesystem # #options SOFTUPDATES -# Make space in the kernel for a MFS root filesystem. Define to the number -# of kilobytes to reserve for the filesystem. -options MFS_ROOT_SIZE=10 +# Make space in the kernel for a root filesystem on a md device. +# Define to the number of kilobytes to reserve for the filesystem. +options MD_ROOT_SIZE=10 + +# Make the md device a potential root device, either with preloaded +# images of type mfs_root or md_root. +options MD_ROOT # Allow this many swap-devices. options NSWAPDEV=20 diff --git a/sys/i386/conf/PCCARD b/sys/i386/conf/PCCARD index 52b59476a0cf..e7837944db01 100644 --- a/sys/i386/conf/PCCARD +++ b/sys/i386/conf/PCCARD @@ -33,7 +33,7 @@ options INET #InterNETworking options FFS #Berkeley Fast Filesystem options FFS_ROOT #FFS usable as root device [keep this!] options MFS #Memory Filesystem -options MFS_ROOT #MFS usable as root device, "MFS" req'ed +options MD_ROOT #MD is a potential root device options NFS #Network Filesystem options NFS_ROOT #NFS usable as root device, "NFS" req'ed options MSDOSFS #MSDOS Filesystem @@ -213,6 +213,7 @@ pseudo-device ppp 1 # Kernel PPP pseudo-device tun # Packet tunnel. pseudo-device pty # Pseudo-ttys (telnet etc) pseudo-device gzip # Exec gzipped a.out's +pseudo-device md # Memory "disks" # The `bpf' pseudo-device enables the Berkeley Packet Filter. # Be aware of the administrative consequences of enabling this! diff --git a/sys/kern/vfs_conf.c b/sys/kern/vfs_conf.c index 57d994c5cdf1..e63343cf78db 100644 --- a/sys/kern/vfs_conf.c +++ b/sys/kern/vfs_conf.c @@ -197,6 +197,10 @@ vfs_mountroot_try(char *mountfrom) if ((path[0] != 0) && setrootbyname(path)) printf("setrootbyname failed\n"); + /* If the root device is a type "memory disk", mount RW */ + if (devsw(rootdev) && (devsw(rootdev)->d_flags & D_MEMDISK)) + mp->mnt_flag &= ~MNT_RDONLY; + strcpy(mp->mnt_stat.f_mntfromname, path); error = VFS_MOUNT(mp, NULL, NULL, NULL, curproc); diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 57d994c5cdf1..e63343cf78db 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -197,6 +197,10 @@ vfs_mountroot_try(char *mountfrom) if ((path[0] != 0) && setrootbyname(path)) printf("setrootbyname failed\n"); + /* If the root device is a type "memory disk", mount RW */ + if (devsw(rootdev) && (devsw(rootdev)->d_flags & D_MEMDISK)) + mp->mnt_flag &= ~MNT_RDONLY; + strcpy(mp->mnt_stat.f_mntfromname, path); error = VFS_MOUNT(mp, NULL, NULL, NULL, curproc); diff --git a/sys/sys/conf.h b/sys/sys/conf.h index 8b92374b0229..ba051d1b558c 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -151,6 +151,7 @@ typedef void devfs_remove_t __P((dev_t dev)); /* * Flags for d_flags. */ +#define D_MEMDISK 0x10000 /* memory type disk */ #define D_NAGGED 0x20000 /* nagged about missing make_dev() */ #define D_CANFREE 0x40000 /* can free blocks */ #define D_TRACKCLOSE 0x80000 /* track all closes */ diff --git a/sys/sys/linedisc.h b/sys/sys/linedisc.h index 8b92374b0229..ba051d1b558c 100644 --- a/sys/sys/linedisc.h +++ b/sys/sys/linedisc.h @@ -151,6 +151,7 @@ typedef void devfs_remove_t __P((dev_t dev)); /* * Flags for d_flags. */ +#define D_MEMDISK 0x10000 /* memory type disk */ #define D_NAGGED 0x20000 /* nagged about missing make_dev() */ #define D_CANFREE 0x40000 /* can free blocks */ #define D_TRACKCLOSE 0x80000 /* track all closes */ diff --git a/sys/ufs/mfs/mfs_vfsops.c b/sys/ufs/mfs/mfs_vfsops.c index a4ebaacaec70..268590fa011e 100644 --- a/sys/ufs/mfs/mfs_vfsops.c +++ b/sys/ufs/mfs/mfs_vfsops.c @@ -62,10 +62,6 @@ MALLOC_DEFINE(M_MFSNODE, "MFS node", "MFS vnode private part"); -#ifdef MFS_ROOT -static caddr_t mfs_rootbase; /* address of mini-root in kernel virtual memory */ -static u_long mfs_rootsize; /* size of mini-root in bytes */ -#endif static int mfs_minor; /* used for building internal dev_t */ @@ -78,9 +74,6 @@ static int mfs_start __P((struct mount *mp, int flags, struct proc *p)); static int mfs_statfs __P((struct mount *mp, struct statfs *sbp, struct proc *p)); static int mfs_init __P((struct vfsconf *)); -#ifdef MFS_ROOT -static void mfs_takeroot __P((void *)); -#endif static struct cdevsw mfs_cdevsw = { /* open */ noopen, @@ -119,35 +112,6 @@ static struct vfsops mfs_vfsops = { VFS_SET(mfs_vfsops, mfs, 0); -#ifdef MFS_ROOT - -#ifdef MFS_ROOT_SIZE -/* Image was already written into mfs_root */ -static u_char mfs_root[MFS_ROOT_SIZE*1024] = "MFS Filesystem goes here"; -static u_char end_mfs_root[] __unused = "MFS Filesystem had better STOP here"; -#endif - -u_char * -mfs_getimage(void) -{ -#ifdef MFS_ROOT_SIZE - /* Get it from compiled-in code */ - return mfs_root; -#else - caddr_t p; - vm_offset_t *q; - - p = preload_search_by_type("mfs_root"); - if (!p) - return NULL; - q = (vm_offset_t *)preload_search_info(p, MODINFO_ADDR); - if (!q) - return NULL; - return (u_char *)*q; -#endif -} - -#endif /* MFS_ROOT */ /* * mfs_mount @@ -199,9 +163,6 @@ mfs_mount(mp, path, data, ndp, p) struct mfs_args args; struct ufsmount *ump; struct fs *fs; -#ifdef MFS_ROOT - u_char *base; -#endif struct mfsnode *mfsp; size_t size; int flags, err; @@ -217,65 +178,8 @@ mfs_mount(mp, path, data, ndp, p) *** */ -#ifdef MFS_ROOT - /* Get it from preload area */ - base = mfs_getimage(); - if (!base) - panic("No mfs_root image loaded; can't continue!"); - fs = (struct fs *)(base + SBOFF); - /* check for valid super block */ - if (fs->fs_magic != FS_MAGIC || fs->fs_bsize > MAXBSIZE || - fs->fs_bsize < sizeof(struct fs)) { - panic("MFS image is invalid!!"); - } - - mfs_rootbase = base; - mfs_rootsize = fs->fs_fsize * fs->fs_size; - - /* remake rootdev, since vfs_mountroot will have it wrong */ - rootdev = make_dev(&mfs_cdevsw, mfs_minor, - 0, 0, 0, "MFS%d", mfs_minor); - rootdev->si_bsize_phys = DEV_BSIZE; - rootdev->si_iosize_max = DFLTPHYS; - mfs_minor++; - - if ((err = bdevvp(rootdev, &rootvp))) { - printf("mfs_mount: can't find rootvp\n"); - return (err); - } - - /* - * FS specific handling - */ - MALLOC(mfsp, struct mfsnode *, sizeof *mfsp, M_MFSNODE, M_WAITOK); - rootvp->v_data = mfsp; - rootvp->v_op = mfs_vnodeop_p; - rootvp->v_tag = VT_MFS; - mfsp->mfs_baseoff = mfs_rootbase; - mfsp->mfs_size = mfs_rootsize; - mfsp->mfs_vnode = rootvp; - mfsp->mfs_pid = p->p_pid; - mfsp->mfs_active = 1; - bufq_init(&mfsp->buf_queue); - - /* MFS wants to be read/write */ - mp->mnt_flag &= ~MNT_RDONLY; - - /* - * Attempt mount - */ - if( (err = ffs_mountfs(rootvp, mp, p, M_MFSNODE)) != 0 ) { - /* fs specific cleanup (if any)*/ - rootvp->v_data = NULL; - FREE(mfsp, M_MFSNODE); - goto error_1; - } - - goto dostatfs; /* success*/ -#else /* !MFS_ROOT */ /* you loose */ panic("mfs_mount: mount MFS as root: not configured!"); -#endif /* MFS_ROOT */ } /* @@ -374,9 +278,6 @@ mfs_mount(mp, path, data, ndp, p) goto error_2; } -#ifdef MFS_ROOT -dostatfs: -#endif /* * Initialize FS stat information in mount struct; uses both * mp->mnt_stat.f_mntonname and mp->mnt_stat.f_mntfromname @@ -498,25 +399,3 @@ mfs_init(vfsp) return (0); } -#ifdef MFS_ROOT -/* - * Just before root is mounted, check to see if we are a candidate - * to supply it. If we have an image available, override the guessed - * defaults. - */ -static void -mfs_takeroot(junk) - void *junk; -{ - if (bootverbose) - printf("Considering MFS root f/s..."); - if (mfs_getimage()) { - rootdevnames[0] = "mfs:"; - printf("preloaded filesystem found.\n"); - } else if (bootverbose) { - printf("not found.\n"); - } -} - -SYSINIT(mfs_root, SI_SUB_MOUNT_ROOT, SI_ORDER_FIRST, mfs_takeroot, NULL); -#endif