summaryrefslogtreecommitdiff
path: root/sys/ufs/mfs
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1995-10-18 08:53:40 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1995-10-18 08:53:40 +0000
commitd6583bb2a13f329cf0332ef2570eb8bb8fc0e39c (patch)
treeece253b876159b39c620e62b6c9b1174642e070e /sys/ufs/mfs
initial import of NetBSD tree
Diffstat (limited to 'sys/ufs/mfs')
-rw-r--r--sys/ufs/mfs/mfs_extern.h62
-rw-r--r--sys/ufs/mfs/mfs_vfsops.c315
-rw-r--r--sys/ufs/mfs/mfs_vnops.c346
-rw-r--r--sys/ufs/mfs/mfsiom.h39
-rw-r--r--sys/ufs/mfs/mfsnode.h88
5 files changed, 850 insertions, 0 deletions
diff --git a/sys/ufs/mfs/mfs_extern.h b/sys/ufs/mfs/mfs_extern.h
new file mode 100644
index 00000000000..f7e2c63f208
--- /dev/null
+++ b/sys/ufs/mfs/mfs_extern.h
@@ -0,0 +1,62 @@
+/* $NetBSD: mfs_extern.h,v 1.3 1994/12/14 13:03:51 mycroft Exp $ */
+
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)mfs_extern.h 8.2 (Berkeley) 6/16/94
+ */
+
+struct buf;
+struct mount;
+struct nameidata;
+struct proc;
+struct statfs;
+struct ucred;
+struct vnode;
+
+__BEGIN_DECLS
+int mfs_badop __P((void));
+int mfs_bmap __P((struct vop_bmap_args *));
+int mfs_close __P((struct vop_close_args *));
+void mfs_doio __P((struct buf *bp, caddr_t base));
+int mfs_inactive __P((struct vop_inactive_args *)); /* XXX */
+int mfs_reclaim __P((struct vop_reclaim_args *));
+int mfs_init __P((void));
+int mfs_ioctl __P((struct vop_ioctl_args *));
+int mfs_mount __P((struct mount *mp,
+ char *path, caddr_t data, struct nameidata *ndp, struct proc *p));
+int mfs_open __P((struct vop_open_args *));
+int mfs_print __P((struct vop_print_args *)); /* XXX */
+int mfs_start __P((struct mount *mp, int flags, struct proc *p));
+int mfs_statfs __P((struct mount *mp, struct statfs *sbp, struct proc *p));
+int mfs_strategy __P((struct vop_strategy_args *)); /* XXX */
+__END_DECLS
diff --git a/sys/ufs/mfs/mfs_vfsops.c b/sys/ufs/mfs/mfs_vfsops.c
new file mode 100644
index 00000000000..e42968473bc
--- /dev/null
+++ b/sys/ufs/mfs/mfs_vfsops.c
@@ -0,0 +1,315 @@
+/* $NetBSD: mfs_vfsops.c,v 1.9 1995/09/01 19:39:18 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1989, 1990, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)mfs_vfsops.c 8.4 (Berkeley) 4/16/94
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/time.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/buf.h>
+#include <sys/mount.h>
+#include <sys/signalvar.h>
+#include <sys/vnode.h>
+#include <sys/malloc.h>
+
+#include <ufs/ufs/quota.h>
+#include <ufs/ufs/inode.h>
+#include <ufs/ufs/ufsmount.h>
+#include <ufs/ufs/ufs_extern.h>
+
+#include <ufs/ffs/fs.h>
+#include <ufs/ffs/ffs_extern.h>
+
+#include <ufs/mfs/mfsnode.h>
+#include <ufs/mfs/mfs_extern.h>
+
+caddr_t mfs_rootbase; /* address of mini-root in kernel virtual memory */
+u_long mfs_rootsize; /* size of mini-root in bytes */
+
+static int mfs_minor; /* used for building internal dev_t */
+
+extern int (**mfs_vnodeop_p)();
+
+/*
+ * mfs vfs operations.
+ */
+struct vfsops mfs_vfsops = {
+ MOUNT_MFS,
+ mfs_mount,
+ mfs_start,
+ ffs_unmount,
+ ufs_root,
+ ufs_quotactl,
+ mfs_statfs,
+ ffs_sync,
+ ffs_vget,
+ ffs_fhtovp,
+ ffs_vptofh,
+ mfs_init,
+};
+
+/*
+ * Called by main() when mfs is going to be mounted as root.
+ *
+ * Name is updated by mount(8) after booting.
+ */
+#define ROOTNAME "mfs_root"
+
+mfs_mountroot()
+{
+ extern struct vnode *rootvp;
+ register struct fs *fs;
+ register struct mount *mp;
+ struct proc *p = curproc; /* XXX */
+ struct ufsmount *ump;
+ struct mfsnode *mfsp;
+ size_t size;
+ int error;
+
+ /*
+ * Get vnodes for swapdev and rootdev.
+ */
+ if (bdevvp(swapdev, &swapdev_vp) || bdevvp(rootdev, &rootvp))
+ panic("mfs_mountroot: can't setup bdevvp's");
+
+ mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK);
+ bzero((char *)mp, (u_long)sizeof(struct mount));
+ mp->mnt_op = &mfs_vfsops;
+ mp->mnt_flag = MNT_RDONLY;
+ mfsp = malloc(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_buflist = (struct buf *)0;
+ if (error = ffs_mountfs(rootvp, mp, p)) {
+ free(mp, M_MOUNT);
+ free(mfsp, M_MFSNODE);
+ return (error);
+ }
+ if (error = vfs_lock(mp)) {
+ (void)ffs_unmount(mp, 0, p);
+ free(mp, M_MOUNT);
+ free(mfsp, M_MFSNODE);
+ return (error);
+ }
+ CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list);
+ mp->mnt_vnodecovered = NULLVP;
+ ump = VFSTOUFS(mp);
+ fs = ump->um_fs;
+ bzero(fs->fs_fsmnt, sizeof(fs->fs_fsmnt));
+ fs->fs_fsmnt[0] = '/';
+ bcopy(fs->fs_fsmnt, mp->mnt_stat.f_mntonname, MNAMELEN);
+ (void) copystr(ROOTNAME, mp->mnt_stat.f_mntfromname, MNAMELEN - 1,
+ &size);
+ bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
+ (void)ffs_statfs(mp, &mp->mnt_stat, p);
+ vfs_unlock(mp);
+ inittodr((time_t)0);
+ return (0);
+}
+
+/*
+ * This is called early in boot to set the base address and size
+ * of the mini-root.
+ */
+mfs_initminiroot(base)
+ caddr_t base;
+{
+ struct fs *fs = (struct fs *)(base + SBOFF);
+ extern int (*mountroot)();
+
+ /* check for valid super block */
+ if (fs->fs_magic != FS_MAGIC || fs->fs_bsize > MAXBSIZE ||
+ fs->fs_bsize < sizeof(struct fs))
+ return (0);
+ mountroot = mfs_mountroot;
+ mfs_rootbase = base;
+ mfs_rootsize = fs->fs_fsize * fs->fs_size;
+ rootdev = makedev(255, mfs_minor++);
+ return (mfs_rootsize);
+}
+
+/*
+ * VFS Operations.
+ *
+ * mount system call
+ */
+/* ARGSUSED */
+int
+mfs_mount(mp, path, data, ndp, p)
+ register struct mount *mp;
+ char *path;
+ caddr_t data;
+ struct nameidata *ndp;
+ struct proc *p;
+{
+ struct vnode *devvp;
+ struct mfs_args args;
+ struct ufsmount *ump;
+ register struct fs *fs;
+ register struct mfsnode *mfsp;
+ size_t size;
+ int flags, error;
+
+ if (error = copyin(data, (caddr_t)&args, sizeof (struct mfs_args)))
+ return (error);
+
+ /*
+ * If updating, check whether changing from read-only to
+ * read/write; if there is no device name, that's all we do.
+ */
+ if (mp->mnt_flag & MNT_UPDATE) {
+ ump = VFSTOUFS(mp);
+ fs = ump->um_fs;
+ if (fs->fs_ronly == 0 && (mp->mnt_flag & MNT_RDONLY)) {
+ flags = WRITECLOSE;
+ if (mp->mnt_flag & MNT_FORCE)
+ flags |= FORCECLOSE;
+ if (vfs_busy(mp))
+ return (EBUSY);
+ error = ffs_flushfiles(mp, flags, p);
+ vfs_unbusy(mp);
+ if (error)
+ return (error);
+ }
+ if (fs->fs_ronly && (mp->mnt_flag & MNT_WANTRDWR))
+ fs->fs_ronly = 0;
+#ifdef EXPORTMFS
+ if (args.fspec == 0)
+ return (vfs_export(mp, &ump->um_export, &args.export));
+#endif
+ return (0);
+ }
+ error = getnewvnode(VT_MFS, (struct mount *)0, mfs_vnodeop_p, &devvp);
+ if (error)
+ return (error);
+ devvp->v_type = VBLK;
+ if (checkalias(devvp, makedev(255, mfs_minor++), (struct mount *)0))
+ panic("mfs_mount: dup dev");
+ mfsp = (struct mfsnode *)malloc(sizeof *mfsp, M_MFSNODE, M_WAITOK);
+ devvp->v_data = mfsp;
+ mfsp->mfs_baseoff = args.base;
+ mfsp->mfs_size = args.size;
+ mfsp->mfs_vnode = devvp;
+ mfsp->mfs_pid = p->p_pid;
+ mfsp->mfs_buflist = (struct buf *)0;
+ if (error = ffs_mountfs(devvp, mp, p)) {
+ mfsp->mfs_buflist = (struct buf *)-1;
+ vrele(devvp);
+ return (error);
+ }
+ ump = VFSTOUFS(mp);
+ fs = ump->um_fs;
+ (void) copyinstr(path, fs->fs_fsmnt, sizeof(fs->fs_fsmnt) - 1, &size);
+ bzero(fs->fs_fsmnt + size, sizeof(fs->fs_fsmnt) - size);
+ bcopy(fs->fs_fsmnt, mp->mnt_stat.f_mntonname, MNAMELEN);
+ (void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1,
+ &size);
+ bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
+ return (0);
+}
+
+int mfs_pri = PWAIT | PCATCH; /* XXX prob. temp */
+
+/*
+ * Used to grab the process and keep it in the kernel to service
+ * memory filesystem I/O requests.
+ *
+ * Loop servicing I/O requests.
+ * Copy the requested data into or out of the memory filesystem
+ * address space.
+ */
+/* ARGSUSED */
+int
+mfs_start(mp, flags, p)
+ struct mount *mp;
+ int flags;
+ struct proc *p;
+{
+ register struct vnode *vp = VFSTOUFS(mp)->um_devvp;
+ register struct mfsnode *mfsp = VTOMFS(vp);
+ register struct buf *bp;
+ register caddr_t base;
+ int error = 0;
+
+ base = mfsp->mfs_baseoff;
+ while (mfsp->mfs_buflist != (struct buf *)-1) {
+#define DOIO() \
+ while (bp = mfsp->mfs_buflist) { \
+ mfsp->mfs_buflist = bp->b_actf; \
+ mfs_doio(bp, base); \
+ wakeup((caddr_t)bp); \
+ }
+ DOIO();
+ /*
+ * If a non-ignored signal is received, try to unmount.
+ * If that fails, clear the signal (it has been "processed"),
+ * otherwise we will loop here, as tsleep will always return
+ * EINTR/ERESTART.
+ */
+ if (error = tsleep((caddr_t)vp, mfs_pri, "mfsidl", 0)) {
+ DOIO();
+ if (dounmount(mp, 0, p) != 0)
+ CLRSIG(p, CURSIG(p));
+ }
+ }
+ return (error);
+}
+
+/*
+ * Get file system statistics.
+ */
+mfs_statfs(mp, sbp, p)
+ struct mount *mp;
+ struct statfs *sbp;
+ struct proc *p;
+{
+ int error;
+
+ error = ffs_statfs(mp, sbp, p);
+#ifdef COMPAT_09
+ sbp->f_type = 3;
+#else
+ sbp->f_type = 0;
+#endif
+ strncpy(&sbp->f_fstypename[0], mp->mnt_op->vfs_name, MFSNAMELEN);
+ return (error);
+}
diff --git a/sys/ufs/mfs/mfs_vnops.c b/sys/ufs/mfs/mfs_vnops.c
new file mode 100644
index 00000000000..6a71c936e51
--- /dev/null
+++ b/sys/ufs/mfs/mfs_vnops.c
@@ -0,0 +1,346 @@
+/* $NetBSD: mfs_vnops.c,v 1.5 1994/12/14 13:03:52 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)mfs_vnops.c 8.5 (Berkeley) 7/28/94
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/time.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/buf.h>
+#include <sys/map.h>
+#include <sys/vnode.h>
+#include <sys/malloc.h>
+
+#include <miscfs/specfs/specdev.h>
+
+#include <machine/vmparam.h>
+
+#include <ufs/mfs/mfsnode.h>
+#include <ufs/mfs/mfsiom.h>
+#include <ufs/mfs/mfs_extern.h>
+
+/*
+ * mfs vnode operations.
+ */
+int (**mfs_vnodeop_p)();
+struct vnodeopv_entry_desc mfs_vnodeop_entries[] = {
+ { &vop_default_desc, vn_default_error },
+ { &vop_lookup_desc, mfs_lookup }, /* lookup */
+ { &vop_create_desc, mfs_create }, /* create */
+ { &vop_mknod_desc, mfs_mknod }, /* mknod */
+ { &vop_open_desc, mfs_open }, /* open */
+ { &vop_close_desc, mfs_close }, /* close */
+ { &vop_access_desc, mfs_access }, /* access */
+ { &vop_getattr_desc, mfs_getattr }, /* getattr */
+ { &vop_setattr_desc, mfs_setattr }, /* setattr */
+ { &vop_read_desc, mfs_read }, /* read */
+ { &vop_write_desc, mfs_write }, /* write */
+ { &vop_ioctl_desc, mfs_ioctl }, /* ioctl */
+ { &vop_select_desc, mfs_select }, /* select */
+ { &vop_mmap_desc, mfs_mmap }, /* mmap */
+ { &vop_fsync_desc, spec_fsync }, /* fsync */
+ { &vop_seek_desc, mfs_seek }, /* seek */
+ { &vop_remove_desc, mfs_remove }, /* remove */
+ { &vop_link_desc, mfs_link }, /* link */
+ { &vop_rename_desc, mfs_rename }, /* rename */
+ { &vop_mkdir_desc, mfs_mkdir }, /* mkdir */
+ { &vop_rmdir_desc, mfs_rmdir }, /* rmdir */
+ { &vop_symlink_desc, mfs_symlink }, /* symlink */
+ { &vop_readdir_desc, mfs_readdir }, /* readdir */
+ { &vop_readlink_desc, mfs_readlink }, /* readlink */
+ { &vop_abortop_desc, mfs_abortop }, /* abortop */
+ { &vop_inactive_desc, mfs_inactive }, /* inactive */
+ { &vop_reclaim_desc, mfs_reclaim }, /* reclaim */
+ { &vop_lock_desc, mfs_lock }, /* lock */
+ { &vop_unlock_desc, mfs_unlock }, /* unlock */
+ { &vop_bmap_desc, mfs_bmap }, /* bmap */
+ { &vop_strategy_desc, mfs_strategy }, /* strategy */
+ { &vop_print_desc, mfs_print }, /* print */
+ { &vop_islocked_desc, mfs_islocked }, /* islocked */
+ { &vop_pathconf_desc, mfs_pathconf }, /* pathconf */
+ { &vop_advlock_desc, mfs_advlock }, /* advlock */
+ { &vop_blkatoff_desc, mfs_blkatoff }, /* blkatoff */
+ { &vop_valloc_desc, mfs_valloc }, /* valloc */
+ { &vop_vfree_desc, mfs_vfree }, /* vfree */
+ { &vop_truncate_desc, mfs_truncate }, /* truncate */
+ { &vop_update_desc, mfs_update }, /* update */
+ { &vop_bwrite_desc, mfs_bwrite }, /* bwrite */
+ { (struct vnodeop_desc*)NULL, (int(*)())NULL }
+};
+struct vnodeopv_desc mfs_vnodeop_opv_desc =
+ { &mfs_vnodeop_p, mfs_vnodeop_entries };
+
+/*
+ * Vnode Operations.
+ *
+ * Open called to allow memory filesystem to initialize and
+ * validate before actual IO. Record our process identifier
+ * so we can tell when we are doing I/O to ourself.
+ */
+/* ARGSUSED */
+int
+mfs_open(ap)
+ struct vop_open_args /* {
+ struct vnode *a_vp;
+ int a_mode;
+ struct ucred *a_cred;
+ struct proc *a_p;
+ } */ *ap;
+{
+
+ if (ap->a_vp->v_type != VBLK) {
+ panic("mfs_ioctl not VBLK");
+ /* NOTREACHED */
+ }
+ return (0);
+}
+
+/*
+ * Ioctl operation.
+ */
+/* ARGSUSED */
+int
+mfs_ioctl(ap)
+ struct vop_ioctl_args /* {
+ struct vnode *a_vp;
+ u_long a_command;
+ caddr_t a_data;
+ int a_fflag;
+ struct ucred *a_cred;
+ struct proc *a_p;
+ } */ *ap;
+{
+
+ return (ENOTTY);
+}
+
+/*
+ * Pass I/O requests to the memory filesystem process.
+ */
+int
+mfs_strategy(ap)
+ struct vop_strategy_args /* {
+ struct buf *a_bp;
+ } */ *ap;
+{
+ register struct buf *bp = ap->a_bp;
+ register struct mfsnode *mfsp;
+ struct vnode *vp;
+ struct proc *p = curproc; /* XXX */
+
+ if (!vfinddev(bp->b_dev, VBLK, &vp) || vp->v_usecount == 0)
+ panic("mfs_strategy: bad dev");
+ mfsp = VTOMFS(vp);
+ /* check for mini-root access */
+ if (mfsp->mfs_pid == 0) {
+ caddr_t base;
+
+ base = mfsp->mfs_baseoff + (bp->b_blkno << DEV_BSHIFT);
+ if (bp->b_flags & B_READ)
+ bcopy(base, bp->b_data, bp->b_bcount);
+ else
+ bcopy(bp->b_data, base, bp->b_bcount);
+ biodone(bp);
+ } else if (mfsp->mfs_pid == p->p_pid) {
+ mfs_doio(bp, mfsp->mfs_baseoff);
+ } else {
+ bp->b_actf = mfsp->mfs_buflist;
+ mfsp->mfs_buflist = bp;
+ wakeup((caddr_t)vp);
+ }
+ return (0);
+}
+
+/*
+ * Memory file system I/O.
+ *
+ * Trivial on the HP since buffer has already been mapping into KVA space.
+ */
+void
+mfs_doio(bp, base)
+ register struct buf *bp;
+ caddr_t base;
+{
+
+ base += (bp->b_blkno << DEV_BSHIFT);
+ if (bp->b_flags & B_READ)
+ bp->b_error = copyin(base, bp->b_data, bp->b_bcount);
+ else
+ bp->b_error = copyout(bp->b_data, base, bp->b_bcount);
+ if (bp->b_error)
+ bp->b_flags |= B_ERROR;
+ biodone(bp);
+}
+
+/*
+ * This is a noop, simply returning what one has been given.
+ */
+int
+mfs_bmap(ap)
+ struct vop_bmap_args /* {
+ struct vnode *a_vp;
+ daddr_t a_bn;
+ struct vnode **a_vpp;
+ daddr_t *a_bnp;
+ int *a_runp;
+ } */ *ap;
+{
+
+ if (ap->a_vpp != NULL)
+ *ap->a_vpp = ap->a_vp;
+ if (ap->a_bnp != NULL)
+ *ap->a_bnp = ap->a_bn;
+ return (0);
+}
+
+/*
+ * Memory filesystem close routine
+ */
+/* ARGSUSED */
+int
+mfs_close(ap)
+ struct vop_close_args /* {
+ struct vnode *a_vp;
+ int a_fflag;
+ struct ucred *a_cred;
+ struct proc *a_p;
+ } */ *ap;
+{
+ register struct vnode *vp = ap->a_vp;
+ register struct mfsnode *mfsp = VTOMFS(vp);
+ register struct buf *bp;
+ int error;
+
+ /*
+ * Finish any pending I/O requests.
+ */
+ while (bp = mfsp->mfs_buflist) {
+ mfsp->mfs_buflist = bp->b_actf;
+ mfs_doio(bp, mfsp->mfs_baseoff);
+ wakeup((caddr_t)bp);
+ }
+ /*
+ * On last close of a memory filesystem
+ * we must invalidate any in core blocks, so that
+ * we can, free up its vnode.
+ */
+ if (error = vinvalbuf(vp, 1, ap->a_cred, ap->a_p, 0, 0))
+ return (error);
+ /*
+ * There should be no way to have any more uses of this
+ * vnode, so if we find any other uses, it is a panic.
+ */
+ if (vp->v_usecount > 1)
+ printf("mfs_close: ref count %d > 1\n", vp->v_usecount);
+ if (vp->v_usecount > 1 || mfsp->mfs_buflist)
+ panic("mfs_close");
+ /*
+ * Send a request to the filesystem server to exit.
+ */
+ mfsp->mfs_buflist = (struct buf *)(-1);
+ wakeup((caddr_t)vp);
+ return (0);
+}
+
+/*
+ * Memory filesystem inactive routine
+ */
+/* ARGSUSED */
+int
+mfs_inactive(ap)
+ struct vop_inactive_args /* {
+ struct vnode *a_vp;
+ } */ *ap;
+{
+ register struct mfsnode *mfsp = VTOMFS(ap->a_vp);
+
+ if (mfsp->mfs_buflist && mfsp->mfs_buflist != (struct buf *)(-1))
+ panic("mfs_inactive: not inactive (mfs_buflist %x)",
+ mfsp->mfs_buflist);
+ return (0);
+}
+
+/*
+ * Reclaim a memory filesystem devvp so that it can be reused.
+ */
+int
+mfs_reclaim(ap)
+ struct vop_reclaim_args /* {
+ struct vnode *a_vp;
+ } */ *ap;
+{
+ register struct vnode *vp = ap->a_vp;
+
+ FREE(vp->v_data, M_MFSNODE);
+ vp->v_data = NULL;
+ return (0);
+}
+
+/*
+ * Print out the contents of an mfsnode.
+ */
+int
+mfs_print(ap)
+ struct vop_print_args /* {
+ struct vnode *a_vp;
+ } */ *ap;
+{
+ register struct mfsnode *mfsp = VTOMFS(ap->a_vp);
+
+ printf("tag VT_MFS, pid %d, base %d, size %d\n", mfsp->mfs_pid,
+ mfsp->mfs_baseoff, mfsp->mfs_size);
+ return (0);
+}
+
+/*
+ * Block device bad operation
+ */
+int
+mfs_badop()
+{
+
+ panic("mfs_badop called\n");
+ /* NOTREACHED */
+}
+
+/*
+ * Memory based filesystem initialization.
+ */
+mfs_init()
+{
+
+}
diff --git a/sys/ufs/mfs/mfsiom.h b/sys/ufs/mfs/mfsiom.h
new file mode 100644
index 00000000000..975e53b0991
--- /dev/null
+++ b/sys/ufs/mfs/mfsiom.h
@@ -0,0 +1,39 @@
+/* $NetBSD: mfsiom.h,v 1.2 1994/06/29 06:47:14 cgd Exp $ */
+
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)mfsiom.h 8.1 (Berkeley) 6/11/93
+ */
+
+#define MFS_MAPREG (MAXPHYS/NBPG + 2) /* Kernel mapping pte's */
+#define MFS_MAPSIZE 10 /* Size of alloc map for pte's */
diff --git a/sys/ufs/mfs/mfsnode.h b/sys/ufs/mfs/mfsnode.h
new file mode 100644
index 00000000000..b3238b5860b
--- /dev/null
+++ b/sys/ufs/mfs/mfsnode.h
@@ -0,0 +1,88 @@
+/* $NetBSD: mfsnode.h,v 1.2 1994/06/29 06:47:16 cgd Exp $ */
+
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)mfsnode.h 8.2 (Berkeley) 8/11/93
+ */
+
+/*
+ * This structure defines the control data for the memory based file system.
+ */
+
+struct mfsnode {
+ struct vnode *mfs_vnode; /* vnode associated with this mfsnode */
+ caddr_t mfs_baseoff; /* base of file system in memory */
+ long mfs_size; /* size of memory file system */
+ pid_t mfs_pid; /* supporting process pid */
+ struct buf *mfs_buflist; /* list of I/O requests */
+ long mfs_spare[4];
+};
+
+/*
+ * Convert between mfsnode pointers and vnode pointers
+ */
+#define VTOMFS(vp) ((struct mfsnode *)(vp)->v_data)
+#define MFSTOV(mfsp) ((mfsp)->mfs_vnode)
+
+/* Prototypes for MFS operations on vnodes. */
+#define mfs_lookup ((int (*) __P((struct vop_lookup_args *)))mfs_badop)
+#define mfs_create ((int (*) __P((struct vop_create_args *)))mfs_badop)
+#define mfs_mknod ((int (*) __P((struct vop_mknod_args *)))mfs_badop)
+#define mfs_access ((int (*) __P((struct vop_access_args *)))mfs_badop)
+#define mfs_getattr ((int (*) __P((struct vop_getattr_args *)))mfs_badop)
+#define mfs_setattr ((int (*) __P((struct vop_setattr_args *)))mfs_badop)
+#define mfs_read ((int (*) __P((struct vop_read_args *)))mfs_badop)
+#define mfs_write ((int (*) __P((struct vop_write_args *)))mfs_badop)
+#define mfs_select ((int (*) __P((struct vop_select_args *)))mfs_badop)
+#define mfs_mmap ((int (*) __P((struct vop_mmap_args *)))mfs_badop)
+#define mfs_seek ((int (*) __P((struct vop_seek_args *)))mfs_badop)
+#define mfs_remove ((int (*) __P((struct vop_remove_args *)))mfs_badop)
+#define mfs_link ((int (*) __P((struct vop_link_args *)))mfs_badop)
+#define mfs_rename ((int (*) __P((struct vop_rename_args *)))mfs_badop)
+#define mfs_mkdir ((int (*) __P((struct vop_mkdir_args *)))mfs_badop)
+#define mfs_rmdir ((int (*) __P((struct vop_rmdir_args *)))mfs_badop)
+#define mfs_symlink ((int (*) __P((struct vop_symlink_args *)))mfs_badop)
+#define mfs_readdir ((int (*) __P((struct vop_readdir_args *)))mfs_badop)
+#define mfs_readlink ((int (*) __P((struct vop_readlink_args *)))mfs_badop)
+#define mfs_abortop ((int (*) __P((struct vop_abortop_args *)))mfs_badop)
+#define mfs_lock ((int (*) __P((struct vop_lock_args *)))nullop)
+#define mfs_unlock ((int (*) __P((struct vop_unlock_args *)))nullop)
+#define mfs_islocked ((int (*) __P((struct vop_islocked_args *)))nullop)
+#define mfs_pathconf ((int (*) __P((struct vop_pathconf_args *)))mfs_badop)
+#define mfs_advlock ((int (*) __P((struct vop_advlock_args *)))mfs_badop)
+#define mfs_blkatoff ((int (*) __P((struct vop_blkatoff_args *)))mfs_badop)
+#define mfs_valloc ((int (*) __P((struct vop_valloc_args *)))mfs_badop)
+#define mfs_vfree ((int (*) __P((struct vop_vfree_args *)))mfs_badop)
+#define mfs_truncate ((int (*) __P((struct vop_truncate_args *)))mfs_badop)
+#define mfs_update ((int (*) __P((struct vop_update_args *)))mfs_badop)
+#define mfs_bwrite ((int (*) __P((struct vop_bwrite_args *)))vn_bwrite)