BSD 4_4_Lite2 release
[unix-history] / usr / src / sys / kern / vfs_lookup.c
index 7991812..826fbfe 100644 (file)
@@ -7,9 +7,35 @@
  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
  * the permission of UNIX System Laboratories, Inc.
  *
  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
  * the permission of UNIX System Laboratories, Inc.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
  *
- *     @(#)vfs_lookup.c        8.9 (Berkeley) %G%
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)vfs_lookup.c        8.10 (Berkeley) 5/27/95
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -348,6 +374,7 @@ dirloop:
         */
 unionlookup:
        ndp->ni_dvp = dp;
         */
 unionlookup:
        ndp->ni_dvp = dp;
+       ndp->ni_vp = NULL;
        if (error = VOP_LOOKUP(dp, &ndp->ni_vp, cnp)) {
 #ifdef DIAGNOSTIC
                if (ndp->ni_vp != NULL)
        if (error = VOP_LOOKUP(dp, &ndp->ni_vp, cnp)) {
 #ifdef DIAGNOSTIC
                if (ndp->ni_vp != NULL)
@@ -373,7 +400,7 @@ unionlookup:
                 * If creating and at end of pathname, then can consider
                 * allowing file to be created.
                 */
                 * If creating and at end of pathname, then can consider
                 * allowing file to be created.
                 */
-               if (rdonly || (ndp->ni_dvp->v_mount->mnt_flag & MNT_RDONLY)) {
+               if (rdonly) {
                        error = EROFS;
                        goto bad;
                }
                        error = EROFS;
                        goto bad;
                }
@@ -385,7 +412,6 @@ unionlookup:
                if (cnp->cn_flags & SAVESTART) {
                        ndp->ni_startdir = ndp->ni_dvp;
                        VREF(ndp->ni_startdir);
                if (cnp->cn_flags & SAVESTART) {
                        ndp->ni_startdir = ndp->ni_dvp;
                        VREF(ndp->ni_startdir);
-                       p->p_spare[1]++;
                }
                return (0);
        }
                }
                return (0);
        }
@@ -445,23 +471,15 @@ nextname:
                goto dirloop;
        }
        /*
                goto dirloop;
        }
        /*
-        * Check for read-only file systems.
+        * Disallow directory write attempts on read-only file systems.
         */
         */
-       if (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME) {
-               /*
-                * Disallow directory write attempts on read-only
-                * file systems.
-                */
-               if (rdonly || (dp->v_mount->mnt_flag & MNT_RDONLY) ||
-                   (wantparent &&
-                    (ndp->ni_dvp->v_mount->mnt_flag & MNT_RDONLY))) {
-                       error = EROFS;
-                       goto bad2;
-               }
+       if (rdonly &&
+           (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME)) {
+               error = EROFS;
+               goto bad2;
        }
        if (cnp->cn_flags & SAVESTART) {
                ndp->ni_startdir = ndp->ni_dvp;
        }
        if (cnp->cn_flags & SAVESTART) {
                ndp->ni_startdir = ndp->ni_dvp;
-               p->p_spare[1]++;
                VREF(ndp->ni_startdir);
        }
        if (!wantparent)
                VREF(ndp->ni_startdir);
        }
        if (!wantparent)
@@ -574,7 +592,7 @@ relookup(dvp, vpp, cnp)
                 * If creating and at end of pathname, then can consider
                 * allowing file to be created.
                 */
                 * If creating and at end of pathname, then can consider
                 * allowing file to be created.
                 */
-               if (rdonly || (dvp->v_mount->mnt_flag & MNT_RDONLY)) {
+               if (rdonly) {
                        error = EROFS;
                        goto bad;
                }
                        error = EROFS;
                        goto bad;
                }
@@ -599,19 +617,12 @@ relookup(dvp, vpp, cnp)
 #endif
 
        /*
 #endif
 
        /*
-        * Check for read-only file systems.
+        * Disallow directory write attempts on read-only file systems.
         */
         */
-       if (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME) {
-               /*
-                * Disallow directory write attempts on read-only
-                * file systems.
-                */
-               if (rdonly || (dp->v_mount->mnt_flag & MNT_RDONLY) ||
-                   (wantparent &&
-                    (dvp->v_mount->mnt_flag & MNT_RDONLY))) {
-                       error = EROFS;
-                       goto bad2;
-               }
+       if (rdonly &&
+           (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME)) {
+               error = EROFS;
+               goto bad2;
        }
        /* ASSERT(dvp == ndp->ni_startdir) */
        if (cnp->cn_flags & SAVESTART)
        }
        /* ASSERT(dvp == ndp->ni_startdir) */
        if (cnp->cn_flags & SAVESTART)