1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*
|
1997-02-10 02:22:35 +00:00
|
|
|
* @(#)mfs_vfsops.c 8.11 (Berkeley) 6/19/95
|
1998-12-07 21:58:50 +00:00
|
|
|
* $Id: mfs_vfsops.c,v 1.51 1998/10/12 09:02:19 peter Exp $
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
|
1998-05-11 19:27:18 +00:00
|
|
|
|
1998-01-24 02:54:56 +00:00
|
|
|
#include "opt_mfs.h"
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
1995-12-14 20:16:15 +00:00
|
|
|
#include <sys/conf.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#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>
|
1998-10-09 01:40:56 +00:00
|
|
|
#include <sys/linker.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
#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>
|
|
|
|
|
1997-11-01 20:19:44 +00:00
|
|
|
MALLOC_DEFINE(M_MFSNODE, "MFS node", "MFS vnode private part");
|
1997-10-11 18:31:40 +00:00
|
|
|
|
1998-10-12 09:02:19 +00:00
|
|
|
u_char * mfs_getimage __P((void));
|
1995-12-03 11:17:15 +00:00
|
|
|
|
1995-12-17 21:14:36 +00:00
|
|
|
static caddr_t mfs_rootbase; /* address of mini-root in kernel virtual memory */
|
|
|
|
static u_long mfs_rootsize; /* size of mini-root in bytes */
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
static int mfs_minor; /* used for building internal dev_t */
|
|
|
|
|
1995-11-09 08:17:23 +00:00
|
|
|
extern vop_t **mfs_vnodeop_p;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1995-12-17 21:14:36 +00:00
|
|
|
static int mfs_mount __P((struct mount *mp,
|
|
|
|
char *path, caddr_t data, struct nameidata *ndp,
|
|
|
|
struct proc *p));
|
|
|
|
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));
|
1997-02-10 02:22:35 +00:00
|
|
|
static int mfs_init __P((struct vfsconf *));
|
1995-12-17 21:14:36 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* mfs vfs operations.
|
|
|
|
*/
|
1998-02-09 06:11:36 +00:00
|
|
|
static struct vfsops mfs_vfsops = {
|
1994-05-24 10:09:53 +00:00
|
|
|
mfs_mount,
|
|
|
|
mfs_start,
|
|
|
|
ffs_unmount,
|
|
|
|
ufs_root,
|
|
|
|
ufs_quotactl,
|
|
|
|
mfs_statfs,
|
|
|
|
ffs_sync,
|
|
|
|
ffs_vget,
|
|
|
|
ffs_fhtovp,
|
|
|
|
ffs_vptofh,
|
|
|
|
mfs_init,
|
|
|
|
};
|
|
|
|
|
1998-09-07 13:17:06 +00:00
|
|
|
VFS_SET(mfs_vfsops, mfs, 0);
|
1994-09-21 03:47:43 +00:00
|
|
|
|
1995-11-28 03:15:58 +00:00
|
|
|
#ifdef MFS_ROOT
|
|
|
|
|
1998-10-10 08:12:24 +00:00
|
|
|
#ifdef MFS_ROOT_SIZE
|
1998-10-08 23:34:44 +00:00
|
|
|
/* Image was already written into mfs_root */
|
|
|
|
static u_char mfs_root[MFS_ROOT_SIZE*1024] = "MFS Filesystem goes here";
|
1998-12-07 21:58:50 +00:00
|
|
|
static u_char end_mfs_root[] __unused = "MFS Filesystem had better STOP here";
|
1998-10-10 08:12:24 +00:00
|
|
|
#endif
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1998-10-10 08:12:24 +00:00
|
|
|
u_char *
|
1998-10-08 23:34:44 +00:00
|
|
|
mfs_getimage(void)
|
1995-12-14 14:25:03 +00:00
|
|
|
{
|
1998-10-10 08:12:24 +00:00
|
|
|
#ifdef MFS_ROOT_SIZE
|
|
|
|
/* Get it from compiled-in code */
|
|
|
|
return mfs_root;
|
|
|
|
#else
|
1998-10-09 06:21:12 +00:00
|
|
|
caddr_t p;
|
|
|
|
vm_offset_t *q;
|
1995-12-14 14:25:03 +00:00
|
|
|
|
1998-10-09 23:37:37 +00:00
|
|
|
p = preload_search_by_type("mfs_root");
|
1998-10-08 23:34:44 +00:00
|
|
|
if (!p)
|
|
|
|
return NULL;
|
1998-10-09 23:37:37 +00:00
|
|
|
q = (vm_offset_t *)preload_search_info(p, MODINFO_ADDR);
|
1998-10-09 06:21:12 +00:00
|
|
|
if (!q)
|
|
|
|
return NULL;
|
|
|
|
return (u_char *)*q;
|
1998-10-10 08:12:24 +00:00
|
|
|
#endif
|
1995-12-14 14:25:03 +00:00
|
|
|
}
|
1998-10-08 23:34:44 +00:00
|
|
|
|
1995-11-28 03:15:58 +00:00
|
|
|
#endif /* MFS_ROOT */
|
1995-08-28 09:19:25 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
1995-08-28 09:19:25 +00:00
|
|
|
* mfs_mount
|
1994-05-24 10:09:53 +00:00
|
|
|
*
|
1995-08-28 09:19:25 +00:00
|
|
|
* Called when mounting local physical media
|
|
|
|
*
|
|
|
|
* PARAMETERS:
|
|
|
|
* mountroot
|
|
|
|
* mp mount point structure
|
|
|
|
* path NULL (flag for root mount!!!)
|
|
|
|
* data <unused>
|
|
|
|
* ndp <unused>
|
|
|
|
* p process (user credentials check [statfs])
|
|
|
|
*
|
|
|
|
* mount
|
|
|
|
* mp mount point structure
|
|
|
|
* path path to mount point
|
|
|
|
* data pointer to argument struct in user space
|
|
|
|
* ndp mount point namei() return (used for
|
|
|
|
* credentials on reload), reused to look
|
|
|
|
* up block device.
|
|
|
|
* p process (user credentials check)
|
|
|
|
*
|
|
|
|
* RETURNS: 0 Success
|
|
|
|
* !0 error number (errno.h)
|
|
|
|
*
|
|
|
|
* LOCK STATE:
|
|
|
|
*
|
|
|
|
* ENTRY
|
|
|
|
* mount point is locked
|
|
|
|
* EXIT
|
|
|
|
* mount point is locked
|
|
|
|
*
|
|
|
|
* NOTES:
|
|
|
|
* A NULL path can be used for a flag since the mount
|
|
|
|
* system call will fail with EFAULT in copyinstr in
|
|
|
|
* namei() if it is a genuine NULL from the user.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
/* ARGSUSED */
|
1995-12-17 21:14:36 +00:00
|
|
|
static int
|
1994-05-24 10:09:53 +00:00
|
|
|
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;
|
1997-02-10 02:22:35 +00:00
|
|
|
struct fs *fs;
|
1998-10-08 23:34:44 +00:00
|
|
|
u_char *base;
|
1997-02-10 02:22:35 +00:00
|
|
|
struct mfsnode *mfsp;
|
1994-05-24 10:09:53 +00:00
|
|
|
u_int size;
|
1995-08-28 09:19:25 +00:00
|
|
|
int flags, err;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Use NULL path to flag a root mount
|
|
|
|
*/
|
|
|
|
if( path == NULL) {
|
|
|
|
/*
|
|
|
|
***
|
|
|
|
* Mounting root file system
|
|
|
|
***
|
|
|
|
*/
|
|
|
|
|
1995-11-28 03:15:58 +00:00
|
|
|
#ifdef MFS_ROOT
|
1998-10-09 23:37:37 +00:00
|
|
|
/* Get it from preload area */
|
1998-10-08 23:34:44 +00:00
|
|
|
base = mfs_getimage();
|
|
|
|
if (!base)
|
1998-10-10 08:12:24 +00:00
|
|
|
panic("No mfs_root image loaded; can't continue!");
|
1998-10-08 23:34:44 +00:00
|
|
|
fs = (struct fs *)(base + SBOFF);
|
1995-12-14 14:25:03 +00:00
|
|
|
/* check for valid super block */
|
1995-11-28 03:15:58 +00:00
|
|
|
if (fs->fs_magic != FS_MAGIC || fs->fs_bsize > MAXBSIZE ||
|
|
|
|
fs->fs_bsize < sizeof(struct fs)) {
|
|
|
|
panic("MFS image is invalid!!");
|
|
|
|
}
|
|
|
|
|
1998-10-08 23:34:44 +00:00
|
|
|
mfs_rootbase = base;
|
1995-11-28 03:15:58 +00:00
|
|
|
mfs_rootsize = fs->fs_fsize * fs->fs_size;
|
|
|
|
rootdev = makedev(255, mfs_minor++);
|
|
|
|
printf("rootfs is %ld Kbyte compiled in MFS\n",
|
|
|
|
mfs_rootsize/1024);
|
1997-09-07 16:21:11 +00:00
|
|
|
if ((err = bdevvp(rootdev, &rootvp))) {
|
|
|
|
printf("mfs_mountroot: can't find rootvp");
|
1997-02-10 16:29:32 +00:00
|
|
|
return (err);
|
1997-02-10 02:22:35 +00:00
|
|
|
}
|
1995-08-28 09:19:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* FS specific handling
|
|
|
|
*/
|
1996-06-12 03:37:57 +00:00
|
|
|
MALLOC(mfsp, struct mfsnode *, sizeof *mfsp, M_MFSNODE, M_WAITOK);
|
1995-08-28 09:19:25 +00:00
|
|
|
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;
|
1996-04-08 07:54:51 +00:00
|
|
|
mfsp->mfs_active = 1;
|
1997-09-21 22:10:02 +00:00
|
|
|
bufq_init(&mfsp->buf_queue);
|
1995-08-28 09:19:25 +00:00
|
|
|
|
1997-04-28 09:15:18 +00:00
|
|
|
/* MFS wants to be read/write */
|
|
|
|
mp->mnt_flag &= ~MNT_RDONLY;
|
|
|
|
|
1995-08-28 09:19:25 +00:00
|
|
|
/*
|
|
|
|
* Attempt mount
|
|
|
|
*/
|
1997-10-10 18:17:42 +00:00
|
|
|
if( (err = ffs_mountfs(rootvp, mp, p, M_MFSNODE)) != 0 ) {
|
1995-08-28 09:19:25 +00:00
|
|
|
/* fs specific cleanup (if any)*/
|
|
|
|
rootvp->v_data = NULL;
|
1996-06-12 03:37:57 +00:00
|
|
|
FREE(mfsp, M_MFSNODE);
|
1995-08-28 09:19:25 +00:00
|
|
|
goto error_1;
|
|
|
|
}
|
|
|
|
|
|
|
|
goto dostatfs; /* success*/
|
1998-10-08 23:34:44 +00:00
|
|
|
#else /* !MFS_ROOT */
|
1995-11-28 03:15:58 +00:00
|
|
|
/* you loose */
|
|
|
|
panic("mfs_mount: mount MFS as root: not configured!");
|
|
|
|
#endif /* MFS_ROOT */
|
1995-08-28 09:19:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
***
|
|
|
|
* Mounting non-root file system or updating a file system
|
|
|
|
***
|
|
|
|
*/
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1995-08-28 09:19:25 +00:00
|
|
|
/* copy in user arguments*/
|
|
|
|
if (err = copyin(data, (caddr_t)&args, sizeof (struct mfs_args)))
|
|
|
|
goto error_1;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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) {
|
1995-08-28 09:19:25 +00:00
|
|
|
/*
|
|
|
|
********************
|
|
|
|
* UPDATE
|
|
|
|
********************
|
|
|
|
*/
|
1994-05-24 10:09:53 +00:00
|
|
|
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;
|
1995-08-28 09:19:25 +00:00
|
|
|
err = ffs_flushfiles(mp, flags, p);
|
|
|
|
if (err)
|
|
|
|
goto error_1;
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1997-11-12 05:42:33 +00:00
|
|
|
if (fs->fs_ronly && (mp->mnt_kern_flag & MNTK_WANTRDWR))
|
1994-05-24 10:09:53 +00:00
|
|
|
fs->fs_ronly = 0;
|
|
|
|
#ifdef EXPORTMFS
|
1995-08-28 09:19:25 +00:00
|
|
|
/* if not updating name...*/
|
|
|
|
if (args.fspec == 0) {
|
|
|
|
/*
|
|
|
|
* Process export requests. Jumping to "success"
|
|
|
|
* will return the vfs_export() error code.
|
|
|
|
*/
|
|
|
|
err = vfs_export(mp, &ump->um_export, &args.export);
|
|
|
|
goto success;
|
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
#endif
|
1995-08-28 09:19:25 +00:00
|
|
|
|
|
|
|
/* XXX MFS does not support name updating*/
|
|
|
|
goto success;
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1996-06-12 03:37:57 +00:00
|
|
|
/*
|
|
|
|
* Do the MALLOC before the getnewvnode since doing so afterward
|
|
|
|
* might cause a bogus v_data pointer to get dereferenced
|
|
|
|
* elsewhere if MALLOC should block.
|
|
|
|
*/
|
|
|
|
MALLOC(mfsp, struct mfsnode *, sizeof *mfsp, M_MFSNODE, M_WAITOK);
|
|
|
|
|
1997-03-22 03:59:46 +00:00
|
|
|
err = getnewvnode(VT_MFS, (struct mount *)0, mfs_vnodeop_p, &devvp);
|
1996-06-12 03:37:57 +00:00
|
|
|
if (err) {
|
|
|
|
FREE(mfsp, M_MFSNODE);
|
1995-08-28 09:19:25 +00:00
|
|
|
goto error_1;
|
1996-06-12 03:37:57 +00:00
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
devvp->v_type = VBLK;
|
|
|
|
if (checkalias(devvp, makedev(255, mfs_minor++), (struct mount *)0))
|
|
|
|
panic("mfs_mount: dup dev");
|
|
|
|
devvp->v_data = mfsp;
|
|
|
|
mfsp->mfs_baseoff = args.base;
|
|
|
|
mfsp->mfs_size = args.size;
|
|
|
|
mfsp->mfs_vnode = devvp;
|
|
|
|
mfsp->mfs_pid = p->p_pid;
|
1996-04-08 07:54:51 +00:00
|
|
|
mfsp->mfs_active = 1;
|
1997-09-21 22:10:02 +00:00
|
|
|
bufq_init(&mfsp->buf_queue);
|
1995-08-28 09:19:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Since this is a new mount, we want the names for
|
|
|
|
* the device and the mount point copied in. If an
|
|
|
|
* error occurs, the mountpoint is discarded by the
|
|
|
|
* upper level code.
|
|
|
|
*/
|
|
|
|
/* Save "last mounted on" info for mount point (NULL pad)*/
|
|
|
|
copyinstr( path, /* mount point*/
|
|
|
|
mp->mnt_stat.f_mntonname, /* save area*/
|
|
|
|
MNAMELEN - 1, /* max size*/
|
|
|
|
&size); /* real size*/
|
|
|
|
bzero( mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
|
|
|
|
|
|
|
|
/* Save "mounted from" info for mount point (NULL pad)*/
|
|
|
|
copyinstr( args.fspec, /* device name*/
|
|
|
|
mp->mnt_stat.f_mntfromname, /* save area*/
|
|
|
|
MNAMELEN - 1, /* max size*/
|
|
|
|
&size); /* real size*/
|
|
|
|
bzero( mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
|
|
|
|
|
1997-10-10 18:17:42 +00:00
|
|
|
if (err = ffs_mountfs(devvp, mp, p, M_MFSNODE)) {
|
1996-04-08 07:54:51 +00:00
|
|
|
mfsp->mfs_active = 0;
|
1995-08-28 09:19:25 +00:00
|
|
|
goto error_2;
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1995-08-28 09:19:25 +00:00
|
|
|
|
|
|
|
dostatfs:
|
|
|
|
/*
|
|
|
|
* Initialize FS stat information in mount struct; uses both
|
|
|
|
* mp->mnt_stat.f_mntonname and mp->mnt_stat.f_mntfromname
|
|
|
|
*
|
|
|
|
* This code is common to root and non-root mounts
|
|
|
|
*/
|
|
|
|
(void) VFS_STATFS(mp, &mp->mnt_stat, p);
|
|
|
|
|
|
|
|
goto success;
|
|
|
|
|
|
|
|
error_2: /* error with devvp held*/
|
|
|
|
|
|
|
|
/* release devvp before failing*/
|
|
|
|
vrele(devvp);
|
|
|
|
|
|
|
|
error_1: /* no state to back out*/
|
|
|
|
|
|
|
|
success:
|
|
|
|
return( err);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
1995-08-28 09:19:25 +00:00
|
|
|
|
1995-12-17 21:14:36 +00:00
|
|
|
static int mfs_pri = PWAIT | PCATCH; /* XXX prob. temp */
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 */
|
1995-12-17 21:14:36 +00:00
|
|
|
static int
|
1994-05-24 10:09:53 +00:00
|
|
|
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;
|
1995-11-28 02:15:29 +00:00
|
|
|
register int gotsig = 0;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
base = mfsp->mfs_baseoff;
|
1996-04-08 07:54:51 +00:00
|
|
|
while (mfsp->mfs_active) {
|
1997-09-21 22:10:02 +00:00
|
|
|
while (bp = bufq_first(&mfsp->buf_queue)) {
|
|
|
|
bufq_remove(&mfsp->buf_queue, bp);
|
1994-05-24 10:09:53 +00:00
|
|
|
mfs_doio(bp, base);
|
|
|
|
wakeup((caddr_t)bp);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
1995-11-28 02:15:29 +00:00
|
|
|
/*
|
|
|
|
* Note that dounmount() may fail if work was queued after
|
|
|
|
* we slept. We have to jump hoops here to make sure that we
|
|
|
|
* process any buffers after the sleep, before we dounmount()
|
|
|
|
*/
|
|
|
|
if (gotsig) {
|
|
|
|
gotsig = 0;
|
|
|
|
if (dounmount(mp, 0, p) != 0)
|
|
|
|
CLRSIG(p, CURSIG(p)); /* try sleep again.. */
|
|
|
|
}
|
|
|
|
else if (tsleep((caddr_t)vp, mfs_pri, "mfsidl", 0))
|
|
|
|
gotsig++; /* try to unmount in next pass */
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1995-08-20 10:26:00 +00:00
|
|
|
return (0);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get file system statistics.
|
|
|
|
*/
|
1995-12-17 21:14:36 +00:00
|
|
|
static int
|
1994-05-24 10:09:53 +00:00
|
|
|
mfs_statfs(mp, sbp, p)
|
|
|
|
struct mount *mp;
|
|
|
|
struct statfs *sbp;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = ffs_statfs(mp, sbp, p);
|
1997-02-10 02:22:35 +00:00
|
|
|
sbp->f_type = mp->mnt_vfc->vfc_typenum;
|
1994-05-24 10:09:53 +00:00
|
|
|
return (error);
|
|
|
|
}
|
1995-12-17 21:14:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Memory based filesystem initialization.
|
|
|
|
*/
|
|
|
|
static int
|
1997-02-10 02:22:35 +00:00
|
|
|
mfs_init(vfsp)
|
|
|
|
struct vfsconf *vfsp;
|
1995-12-17 21:14:36 +00:00
|
|
|
{
|
|
|
|
return (0);
|
|
|
|
}
|