return EBUSY if reference count on mount point is greater than 1 to
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Tue, 22 Nov 1994 09:42:10 +0000 (01:42 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Tue, 22 Nov 1994 09:42:10 +0000 (01:42 -0800)
avoid problems in lookup from programs referencing the hidden vnode

SCCS-vsn: sys/kern/vfs_syscalls.c 8.25

usr/src/sys/kern/vfs_syscalls.c

index c59ce72..4577355 100644 (file)
@@ -9,7 +9,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)vfs_syscalls.c      8.24 (Berkeley) %G%
+ *     @(#)vfs_syscalls.c      8.25 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -145,6 +145,10 @@ mount(p, uap, retval)
                vput(vp);
                return (ENODEV);
        }
                vput(vp);
                return (ENODEV);
        }
+       if (vp->v_usecount > 1 || vp->v_mountedhere != NULL) {
+               vput(vp);
+               return (EBUSY);
+       }
 
        /*
         * Allocate and initialize the file system.
 
        /*
         * Allocate and initialize the file system.
@@ -158,12 +162,6 @@ mount(p, uap, retval)
                vput(vp);
                return (error);
        }
                vput(vp);
                return (error);
        }
-       if (vp->v_mountedhere != NULL) {
-               vfs_unlock(mp);
-               free((caddr_t)mp, M_MOUNT);
-               vput(vp);
-               return (EBUSY);
-       }
        vp->v_mountedhere = mp;
        mp->mnt_vnodecovered = vp;
        mp->mnt_stat.f_owner = p->p_ucred->cr_uid;
        vp->v_mountedhere = mp;
        mp->mnt_vnodecovered = vp;
        mp->mnt_stat.f_owner = p->p_ucred->cr_uid;