diff options
Diffstat (limited to 'sys/ufs/mfs')
-rw-r--r-- | sys/ufs/mfs/mfs_extern.h | 6 | ||||
-rw-r--r-- | sys/ufs/mfs/mfs_vfsops.c | 65 | ||||
-rw-r--r-- | sys/ufs/mfs/mfs_vnops.c | 15 | ||||
-rw-r--r-- | sys/ufs/mfs/mfsnode.h | 8 |
4 files changed, 53 insertions, 41 deletions
diff --git a/sys/ufs/mfs/mfs_extern.h b/sys/ufs/mfs/mfs_extern.h index 3616acedf76..2e6990373c1 100644 --- a/sys/ufs/mfs/mfs_extern.h +++ b/sys/ufs/mfs/mfs_extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mfs_extern.h,v 1.3 1997/10/06 15:27:12 csapuntz Exp $ */ +/* $OpenBSD: mfs_extern.h,v 1.4 1997/10/06 20:21:40 deraadt Exp $ */ /* $NetBSD: mfs_extern.h,v 1.4 1996/02/09 22:31:27 christos Exp $ */ /*- @@ -43,7 +43,6 @@ struct proc; struct statfs; struct ucred; struct vnode; -struct vfsconf; __BEGIN_DECLS /* mfs_vfsops.c */ @@ -54,7 +53,7 @@ int mfs_mount __P((struct mount *, char *, caddr_t, int mfs_start __P((struct mount *, int, struct proc *)); int mfs_statfs __P((struct mount *, struct statfs *, struct proc *)); -int mfs_init __P((struct vfsconf *)); +void mfs_init __P((void)); /* mfs_vnops.c */ int mfs_open __P((void *)); @@ -66,7 +65,6 @@ int mfs_close __P((void *)); int mfs_inactive __P((void *)); int mfs_reclaim __P((void *)); int mfs_print __P((void *)); -#define mfs_revoke vop_revoke int mfs_badop __P((void *)); __END_DECLS 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); } diff --git a/sys/ufs/mfs/mfs_vnops.c b/sys/ufs/mfs/mfs_vnops.c index 84a5ed3d368..23121dfa94b 100644 --- a/sys/ufs/mfs/mfs_vnops.c +++ b/sys/ufs/mfs/mfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mfs_vnops.c,v 1.5 1997/10/06 15:27:13 csapuntz Exp $ */ +/* $OpenBSD: mfs_vnops.c,v 1.6 1997/10/06 20:21:42 deraadt Exp $ */ /* $NetBSD: mfs_vnops.c,v 1.8 1996/03/17 02:16:32 christos Exp $ */ /* @@ -72,7 +72,6 @@ struct vnodeopv_entry_desc mfs_vnodeop_entries[] = { { &vop_write_desc, mfs_write }, /* write */ { &vop_ioctl_desc, mfs_ioctl }, /* ioctl */ { &vop_select_desc, mfs_select }, /* select */ - { &vop_revoke_desc, mfs_revoke }, /* revoke */ { &vop_mmap_desc, mfs_mmap }, /* mmap */ { &vop_fsync_desc, spec_fsync }, /* fsync */ { &vop_seek_desc, mfs_seek }, /* seek */ @@ -232,9 +231,6 @@ mfs_bmap(v) *ap->a_vpp = ap->a_vp; if (ap->a_bnp != NULL) *ap->a_bnp = ap->a_bn; - if (ap->a_runp != NULL) - *ap->a_runp = 0; - return (0); } @@ -298,14 +294,12 @@ mfs_inactive(v) { struct vop_inactive_args /* { struct vnode *a_vp; - struct proc *a_p; } */ *ap = v; 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 %p)", mfsp->mfs_buflist); - VOP_UNLOCK(ap->a_vp, 0, ap->a_p); return (0); } @@ -358,9 +352,8 @@ mfs_badop(v) /* * Memory based filesystem initialization. */ -int -mfs_init(vfsp) - struct vfsconf *vfsp; +void +mfs_init() { - return (0); + } diff --git a/sys/ufs/mfs/mfsnode.h b/sys/ufs/mfs/mfsnode.h index 29c290c4e09..384c3dc2475 100644 --- a/sys/ufs/mfs/mfsnode.h +++ b/sys/ufs/mfs/mfsnode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mfsnode.h,v 1.4 1997/10/06 15:27:13 csapuntz Exp $ */ +/* $OpenBSD: mfsnode.h,v 1.5 1997/10/06 20:21:43 deraadt Exp $ */ /* $NetBSD: mfsnode.h,v 1.3 1996/02/09 22:31:31 christos Exp $ */ /* @@ -76,9 +76,9 @@ struct mfsnode { #define mfs_readdir mfs_badop #define mfs_readlink mfs_badop #define mfs_abortop mfs_badop -#define mfs_lock vop_nolock -#define mfs_unlock vop_nounlock -#define mfs_islocked vop_noislocked +#define mfs_lock nullop +#define mfs_unlock nullop +#define mfs_islocked nullop #define mfs_pathconf mfs_badop #define mfs_advlock mfs_badop #define mfs_blkatoff mfs_badop |