pass V_SAVE to vinvalbuf
[unix-history] / usr / src / sys / ufs / lfs / lfs_vfsops.c
index 1f9b58d..34aac29 100644 (file)
@@ -1,10 +1,10 @@
 /*
 /*
- * Copyright (c) 1989, 1991 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1989, 1991, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)lfs_vfsops.c        7.86 (Berkeley) %G%
+ *     @(#)lfs_vfsops.c        8.6 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -81,8 +81,9 @@ lfs_mount(mp, path, data, ndp, p)
                return (error);
 
        /* Until LFS can do NFS right.          XXX */
                return (error);
 
        /* Until LFS can do NFS right.          XXX */
-       if (args.exflags & MNT_EXPORTED)
+       if (args.export.ex_flags & MNT_EXPORTED)
                return (EINVAL);
                return (EINVAL);
+
        /*
         * If updating, check whether changing from read-only to
         * read/write; if there is no device name, that's all we do.
        /*
         * If updating, check whether changing from read-only to
         * read/write; if there is no device name, that's all we do.
@@ -102,17 +103,7 @@ lfs_mount(mp, path, data, ndp, p)
                        /*
                         * Process export requests.
                         */
                        /*
                         * Process export requests.
                         */
-                       if (args.exflags & MNT_EXPORTED) {
-                               if (error = ufs_hang_addrlist(mp, &args))
-                                       return (error);
-                               mp->mnt_flag |= MNT_EXPORTED;
-                       }
-                       if (args.exflags & MNT_DELEXPORT) {
-                               ufs_free_addrlist(ump);
-                               mp->mnt_flag &=
-                                   ~(MNT_EXPORTED | MNT_DEFEXPORTED);
-                       }
-                       return (0);
+                       return (vfs_export(mp, &ump->um_export, &args.export));
                }
        }
        /*
                }
        }
        /*
@@ -186,7 +177,7 @@ lfs_mountfs(devvp, mp, p)
        dev_t dev;
        int error, i, ronly, size;
 
        dev_t dev;
        int error, i, ronly, size;
 
-       if (error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p))
+       if (error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p))
                return (error);
 
        if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, NOCRED, p) != 0)
                return (error);
 
        if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, NOCRED, p) != 0)
@@ -211,14 +202,11 @@ lfs_mountfs(devvp, mp, p)
                error = EINVAL;         /* XXX needs translation */
                goto out;
        }
                error = EINVAL;         /* XXX needs translation */
                goto out;
        }
-#ifdef DEBUG
-       lfs_dump_super(fs);
-#endif
 
        /* Allocate the mount structure, copy the superblock into it. */
        ump = (struct ufsmount *)malloc(sizeof *ump, M_UFSMNT, M_WAITOK);
        fs = ump->um_lfs = malloc(sizeof(struct lfs), M_UFSMNT, M_WAITOK);
 
        /* Allocate the mount structure, copy the superblock into it. */
        ump = (struct ufsmount *)malloc(sizeof *ump, M_UFSMNT, M_WAITOK);
        fs = ump->um_lfs = malloc(sizeof(struct lfs), M_UFSMNT, M_WAITOK);
-       bcopy(bp->b_un.b_addr, fs, sizeof(struct lfs));
+       bcopy(bp->b_data, fs, sizeof(struct lfs));
        if (sizeof(struct lfs) < LFS_SBPAD)                     /* XXX why? */
                bp->b_flags |= B_INVAL;
        brelse(bp);
        if (sizeof(struct lfs) < LFS_SBPAD)                     /* XXX why? */
                bp->b_flags |= B_INVAL;
        brelse(bp);
@@ -247,6 +235,9 @@ lfs_mountfs(devvp, mp, p)
        ump->um_mountp = mp;
        ump->um_dev = dev;
        ump->um_devvp = devvp;
        ump->um_mountp = mp;
        ump->um_dev = dev;
        ump->um_devvp = devvp;
+       ump->um_bptrtodb = 0;
+       ump->um_seqinc = 1 << fs->lfs_fsbtodb;
+       ump->um_nindir = fs->lfs_nindir;
        for (i = 0; i < MAXQUOTAS; i++)
                ump->um_quotas[i] = NULLVP;
        devvp->v_specflags |= SI_MOUNTEDON;
        for (i = 0; i < MAXQUOTAS; i++)
                ump->um_quotas[i] = NULLVP;
        devvp->v_specflags |= SI_MOUNTEDON;
@@ -292,7 +283,7 @@ lfs_unmount(mp, mntflags, p)
 
        flags = 0;
        if (mntflags & MNT_FORCE) {
 
        flags = 0;
        if (mntflags & MNT_FORCE) {
-               if (!doforce || mp == rootfs)
+               if (!doforce || (mp->mnt_flag & MNT_ROOTFS))
                        return (EINVAL);
                flags |= FORCECLOSE;
        }
                        return (EINVAL);
                flags |= FORCECLOSE;
        }
@@ -320,7 +311,7 @@ lfs_unmount(mp, mntflags, p)
        fs->lfs_clean = 1;
        if (error = VFS_SYNC(mp, 1, p->p_ucred, p))
                return (error);
        fs->lfs_clean = 1;
        if (error = VFS_SYNC(mp, 1, p->p_ucred, p))
                return (error);
-       if (fs->lfs_ivnode->v_dirtyblkhd)
+       if (fs->lfs_ivnode->v_dirtyblkhd.lh_first)
                panic("lfs_unmount: still dirty blocks on ifile vnode\n");
        vrele(fs->lfs_ivnode);
        vgone(fs->lfs_ivnode);
                panic("lfs_unmount: still dirty blocks on ifile vnode\n");
        vrele(fs->lfs_ivnode);
        vgone(fs->lfs_ivnode);
@@ -372,11 +363,10 @@ lfs_sync(mp, waitfor, cred, p)
        struct ucred *cred;
        struct proc *p;
 {
        struct ucred *cred;
        struct proc *p;
 {
-       extern int syncprt;
        int error;
 
        /* All syncs must be checkpoints until roll-forward is implemented. */
        int error;
 
        /* All syncs must be checkpoints until roll-forward is implemented. */
-       error = lfs_segwrite(mp, 1);
+       error = lfs_segwrite(mp, SEGM_CKP | (waitfor ? SEGM_SYNC : 0));
 #ifdef QUOTA
        qsync(mp);
 #endif
 #ifdef QUOTA
        qsync(mp);
 #endif
@@ -448,19 +438,17 @@ lfs_vget(mp, ino, vpp)
        if (error =
            bread(ump->um_devvp, daddr, (int)fs->lfs_bsize, NOCRED, &bp)) {
                /*
        if (error =
            bread(ump->um_devvp, daddr, (int)fs->lfs_bsize, NOCRED, &bp)) {
                /*
-                * The inode does not contain anything useful, so it
-                * would be misleading to leave it on its hash chain.
-                * Iput() will return it to the free list.
+                * The inode does not contain anything useful, so it would
+                * be misleading to leave it on its hash chain. With mode
+                * still zero, it will be unlinked and returned to the free
+                * list by vput().
                 */
                 */
-               ufs_ihashrem(ip);
-
-               /* Unlock and discard unneeded inode. */
-               ufs_iput(ip);
+               vput(vp);
                brelse(bp);
                *vpp = NULL;
                return (error);
        }
                brelse(bp);
                *vpp = NULL;
                return (error);
        }
-       ip->i_din = *lfs_ifind(fs, ino, bp->b_un.b_dino);
+       ip->i_din = *lfs_ifind(fs, ino, (struct dinode *)bp->b_data);
        brelse(bp);
 
        /*
        brelse(bp);
 
        /*
@@ -468,7 +456,7 @@ lfs_vget(mp, ino, vpp)
         * cases re-init ip, the underlying vnode/inode may have changed.
         */
        if (error = ufs_vinit(mp, lfs_specop_p, LFS_FIFOOPS, &vp)) {
         * cases re-init ip, the underlying vnode/inode may have changed.
         */
        if (error = ufs_vinit(mp, lfs_specop_p, LFS_FIFOOPS, &vp)) {
-               ufs_iput(ip);
+               vput(vp);
                *vpp = NULL;
                return (error);
        }
                *vpp = NULL;
                return (error);
        }