new copyright notice
[unix-history] / usr / src / sys / ufs / ffs / ffs_vfsops.c
index bf1a669..6ab1f3a 100644 (file)
@@ -2,19 +2,9 @@
  * Copyright (c) 1989 The Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1989 The Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * %sccs.include.redist.c%
  *
  *
- *     @(#)ffs_vfsops.c        7.41 (Berkeley) %G%
+ *     @(#)ffs_vfsops.c        7.49 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -170,6 +160,8 @@ ufs_mount(mp, path, data, ndp)
                        return (error);
                if (devvp != ump->um_devvp)
                        error = EINVAL; /* needs translation */
                        return (error);
                if (devvp != ump->um_devvp)
                        error = EINVAL; /* needs translation */
+               else
+                       vrele(devvp);
        }
        if (error) {
                vrele(devvp);
        }
        if (error) {
                vrele(devvp);
@@ -411,19 +403,20 @@ ufs_quotactl(mp, cmds, uid, arg)
 {
        register struct nameidata *ndp = &u.u_nd;
        struct ufsmount *ump = VFSTOUFS(mp);
 {
        register struct nameidata *ndp = &u.u_nd;
        struct ufsmount *ump = VFSTOUFS(mp);
+       struct proc *p = u.u_procp;     /* XXX */
        int cmd, type, error;
 
 #ifndef QUOTA
        return (EOPNOTSUPP);
 #else
        if (uid == -1)
        int cmd, type, error;
 
 #ifndef QUOTA
        return (EOPNOTSUPP);
 #else
        if (uid == -1)
-               uid = u.u_ruid;
+               uid = p->p_ruid;
        cmd = cmds >> SUBCMDSHIFT;
 
        switch (cmd) {
        case Q_GETQUOTA:
        case Q_SYNC:
        cmd = cmds >> SUBCMDSHIFT;
 
        switch (cmd) {
        case Q_GETQUOTA:
        case Q_SYNC:
-               if (uid == u.u_ruid)
+               if (uid == p->p_ruid)
                        break;
                /* fall through */
        default:
                        break;
                /* fall through */
        default:
@@ -520,18 +513,11 @@ ufs_sync(mp, waitfor)
        register struct inode *ip;
        register struct ufsmount *ump = VFSTOUFS(mp);
        register struct fs *fs;
        register struct inode *ip;
        register struct ufsmount *ump = VFSTOUFS(mp);
        register struct fs *fs;
-       struct vnode *nvp;
        int error, allerror = 0;
        int error, allerror = 0;
-       static int updlock = 0;
 
        if (syncprt)
                bufstats();
 
        if (syncprt)
                bufstats();
-       if (updlock)
-               return (EBUSY);
        fs = ump->um_fs;
        fs = ump->um_fs;
-       if (fs == (struct fs *)1)
-               return (0);
-       updlock++;
        /*
         * Write back modified superblock.
         * Consistency check that the superblock
        /*
         * Write back modified superblock.
         * Consistency check that the superblock
@@ -544,14 +530,19 @@ ufs_sync(mp, waitfor)
                }
                fs->fs_fmod = 0;
                fs->fs_time = time.tv_sec;
                }
                fs->fs_fmod = 0;
                fs->fs_time = time.tv_sec;
-               error = sbupdate(ump, waitfor);
+               allerror = sbupdate(ump, waitfor);
        }
        /*
         * Write back each (modified) inode.
         */
 loop:
        }
        /*
         * Write back each (modified) inode.
         */
 loop:
-       for (vp = mp->mnt_mounth; vp; vp = nvp) {
-               nvp = vp->v_mountf;
+       for (vp = mp->mnt_mounth; vp; vp = vp->v_mountf) {
+               /*
+                * If the vnode that we are about to sync is no longer
+                * associated with this mount point, start over.
+                */
+               if (vp->v_mount != mp)
+                       goto loop;
                ip = VTOI(vp);
                if ((ip->i_flag & (IMOD|IACC|IUPD|ICHG)) == 0 &&
                    vp->v_dirtyblkhd == NULL)
                ip = VTOI(vp);
                if ((ip->i_flag & (IMOD|IACC|IUPD|ICHG)) == 0 &&
                    vp->v_dirtyblkhd == NULL)
@@ -565,7 +556,6 @@ loop:
                        allerror = error;
                vput(vp);
        }
                        allerror = error;
                vput(vp);
        }
-       updlock = 0;
        /*
         * Force stale file system control information to be flushed.
         */
        /*
         * Force stale file system control information to be flushed.
         */
@@ -732,7 +722,6 @@ ufs_vptofh(vp, fhp)
 }
 
 /*
 }
 
 /*
- * Common code for mount and quota.
  * Check that the user's argument is a reasonable
  * thing on which to mount, and return the device number if so.
  */
  * Check that the user's argument is a reasonable
  * thing on which to mount, and return the device number if so.
  */
@@ -744,24 +733,20 @@ getmdev(devvpp, fname, ndp)
        register struct vnode *vp;
        int error;
 
        register struct vnode *vp;
        int error;
 
-       ndp->ni_nameiop = LOOKUP | LOCKLEAF | FOLLOW;
+       ndp->ni_nameiop = LOOKUP | FOLLOW;
        ndp->ni_segflg = UIO_USERSPACE;
        ndp->ni_dirp = fname;
        ndp->ni_segflg = UIO_USERSPACE;
        ndp->ni_dirp = fname;
-       if (error = namei(ndp)) {
-               if (error == ENOENT)
-                       return (ENODEV);        /* needs translation */
+       if (error = namei(ndp))
                return (error);
                return (error);
-       }
        vp = ndp->ni_vp;
        if (vp->v_type != VBLK) {
        vp = ndp->ni_vp;
        if (vp->v_type != VBLK) {
-               vput(vp);
+               vrele(vp);
                return (ENOTBLK);
        }
        if (major(vp->v_rdev) >= nblkdev) {
                return (ENOTBLK);
        }
        if (major(vp->v_rdev) >= nblkdev) {
-               vput(vp);
+               vrele(vp);
                return (ENXIO);
        }
                return (ENXIO);
        }
-       iunlock(VTOI(vp));
        *devvpp = vp;
        return (0);
 }
        *devvpp = vp;
        return (0);
 }