- if (ndp->ni_isdotdot && (dp->v_flag & VROOT)) {
- ndp->ni_dvp = dp;
- ndp->ni_vp = dp;
- VREF(dp);
- goto nextname;
- }
-
- /*
- * We now have a segment name to search for, and a directory to search.
- */
- if (error = VOP_LOOKUP(dp, ndp)) {
- if (ndp->ni_vp != NULL)
- panic("leaf should be empty");
- /*
- * If creating and at end of pathname, then can consider
- * allowing file to be created.
- */
- if (ndp->ni_dvp->v_mount->m_flag & (M_RDONLY | M_EXRDONLY))
- error = EROFS;
- if (flag == LOOKUP || flag == DELETE || error != ENOENT)
- goto bad;
- /*
- * We return with ni_vp NULL to indicate that the entry
- * doesn't currently exist, leaving a pointer to the
- * (possibly locked) directory inode in ndp->ni_dvp.
- */
- return (0); /* should this be ENOENT? */
- }
-
- dp = ndp->ni_vp;
-
-nextname:
- ndp->ni_ptr = ndp->ni_next;
- /*
- * Check for read-only file systems
- */
- if (flag == DELETE || flag == RENAME) {
- /*
- * Disallow directory write attempts on read-only
- * file systems.
- */
- if ((dp->v_mount->m_flag & (M_RDONLY|M_EXRDONLY)) ||
- (wantparent && (ndp->ni_dvp->v_mount->m_flag & (M_RDONLY|M_EXRDONLY)))) {
- error = EROFS;
- goto bad2;
- }
- }
-
- if (!wantparent)
- vrele(ndp->ni_dvp);
-
- if ((ndp->ni_nameiop & LOCKLEAF) == 0)
- VOP_UNLOCK(dp);
- return (0);
-
-bad2:
- if (lockparent)
- VOP_UNLOCK(ndp->ni_dvp);
- vrele(ndp->ni_dvp);
-bad:
- vput(dp);
- ndp->ni_vp = NULL;