diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-10-06 20:23:17 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-10-06 20:23:17 +0000 |
commit | 85674180ac0b414993bec634994ea51b28390306 (patch) | |
tree | 5ce384dfed739e368b8605fc6db4ed1f26a43609 /sys/ufs/mfs/mfs_vfsops.c | |
parent | 44f83f3e77b70fbce9f014e39cf5c97bae700213 (diff) |
back out vfs lite2 till after 2.2
Diffstat (limited to 'sys/ufs/mfs/mfs_vfsops.c')
-rw-r--r-- | sys/ufs/mfs/mfs_vfsops.c | 65 |
1 files changed, 43 insertions, 22 deletions
diff --git a/sys/ufs/mfs/mfs_vfsops.c b/sys/ufs/mfs/mfs_vfsops.c index dbd32e6ea2f..24f94b86582 100644 --- a/sys/ufs/mfs/mfs_vfsops.c +++ b/sys/ufs/mfs/mfs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mfs_vfsops.c,v 1.3 1997/10/06 15:27:12 csapuntz Exp $ */ +/* $OpenBSD: mfs_vfsops.c,v 1.4 1997/10/06 20:21:41 deraadt Exp $ */ /* $NetBSD: mfs_vfsops.c,v 1.10 1996/02/09 22:31:28 christos Exp $ */ /* @@ -69,6 +69,7 @@ extern int (**mfs_vnodeop_p) __P((void *)); * mfs vfs operations. */ struct vfsops mfs_vfsops = { + MOUNT_MFS, mfs_mount, mfs_start, ffs_unmount, @@ -80,31 +81,37 @@ struct vfsops mfs_vfsops = { ffs_fhtovp, ffs_vptofh, mfs_init, - ffs_sysctl }; /* * Called by main() when mfs is going to be mounted as root. + * + * Name is updated by mount(8) after booting. */ +#define ROOTNAME "mfs_root" int mfs_mountroot() { extern struct vnode *rootvp; register struct fs *fs; - struct mount *mp; + register struct mount *mp; struct proc *p = curproc; /* XXX */ struct ufsmount *ump; struct mfsnode *mfsp; + size_t size; int error; - if ((error = bdevvp(swapdev, &swapdev_vp)) || - (error = bdevvp(rootdev, &rootvp))) { - printf("mfs_mountroot: can't setup bdevvp's"); - return (error); - } - if ((error = vfs_rootmountalloc("mfs", "mfs_root", &mp)) != 0) - return (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; @@ -115,20 +122,28 @@ mfs_mountroot() mfsp->mfs_pid = p->p_pid; mfsp->mfs_buflist = (struct buf *)0; if ((error = ffs_mountfs(rootvp, mp, p)) != 0) { - mp->mnt_vfc->vfc_refcount--; - vfs_unbusy(mp, p); free(mp, M_MOUNT); free(mfsp, M_MFSNODE); return (error); } - simple_lock(&mountlist_slock); + if ((error = vfs_lock(mp)) != 0) { + (void)ffs_unmount(mp, 0, p); + free(mp, M_MOUNT); + free(mfsp, M_MFSNODE); + return (error); + } CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list); - simple_unlock(&mountlist_slock); + mp->mnt_vnodecovered = NULLVP; ump = VFSTOUFS(mp); fs = ump->um_fs; - (void) copystr(mp->mnt_stat.f_mntonname, fs->fs_fsmnt, MNAMELEN - 1, 0); + 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_unbusy(mp, p); + vfs_unlock(mp); inittodr((time_t)0); return (0); } @@ -192,7 +207,10 @@ mfs_mount(mp, path, data, ndp, p) 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); } @@ -254,6 +272,7 @@ mfs_start(mp, flags, p) 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) { @@ -270,11 +289,13 @@ mfs_start(mp, flags, p) * otherwise we will loop here, as tsleep will always return * EINTR/ERESTART. */ - if (tsleep((caddr_t)vp, mfs_pri, "mfsidl", 0) && - dounmount(mp, 0, p) != 0) - CLRSIG(p, CURSIG(p)); + if ((error = tsleep((caddr_t)vp, mfs_pri, "mfsidl", 0)) != 0) { + DOIO(); + if (dounmount(mp, 0, p) != 0) + CLRSIG(p, CURSIG(p)); + } } - return (0); + return (error); } /* @@ -290,10 +311,10 @@ mfs_statfs(mp, sbp, p) error = ffs_statfs(mp, sbp, p); #ifdef COMPAT_09 - sbp->f_type = mp->mnt_vfc->vfc_typenum; + sbp->f_type = 3; #else sbp->f_type = 0; #endif - strncpy(&sbp->f_fstypename[0], mp->mnt_vfc->vfc_name, MFSNAMELEN); + strncpy(&sbp->f_fstypename[0], mp->mnt_op->vfs_name, MFSNAMELEN); return (error); } |