summaryrefslogtreecommitdiffstats
path: root/sys/ufs
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1994-09-27 20:33:41 +0000
committerphk <phk@FreeBSD.org>1994-09-27 20:33:41 +0000
commitd0ad392702499b8224444ab43914aab79cee2ee9 (patch)
treebe46fa73b436f39cb6b10330724d83523da890f5 /sys/ufs
parent9aaca324b5b8c5827e7d32e8c8c14834bb5288a5 (diff)
downloadFreeBSD-src-d0ad392702499b8224444ab43914aab79cee2ee9.zip
FreeBSD-src-d0ad392702499b8224444ab43914aab79cee2ee9.tar.gz
Moved the "relookup" routine into vfs_lookup.c from ufs/ufs/ufs_vnops.c.
Several FS's use this, so it doesn't belong in ufs. (unionfs, msdosfs and ufs)
Diffstat (limited to 'sys/ufs')
-rw-r--r--sys/ufs/ufs/ufs_vnops.c156
1 files changed, 1 insertions, 155 deletions
diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c
index 41e1bba..f7eeacf 100644
--- a/sys/ufs/ufs/ufs_vnops.c
+++ b/sys/ufs/ufs/ufs_vnops.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)ufs_vnops.c 8.10 (Berkeley) 4/1/94
- * $Id: ufs_vnops.c,v 1.4 1994/08/08 17:31:01 davidg Exp $
+ * $Id: ufs_vnops.c,v 1.5 1994/09/22 19:38:41 wollman Exp $
*/
#include <sys/param.h>
@@ -709,160 +709,6 @@ out2:
}
-
-/*
- * relookup - lookup a path name component
- * Used by lookup to re-aquire things.
- */
-int
-relookup(dvp, vpp, cnp)
- struct vnode *dvp, **vpp;
- struct componentname *cnp;
-{
- register struct vnode *dp = 0; /* the directory we are searching */
- int docache; /* == 0 do not cache last component */
- int wantparent; /* 1 => wantparent or lockparent flag */
- int rdonly; /* lookup read-only flag bit */
- int error = 0;
-#ifdef NAMEI_DIAGNOSTIC
- int newhash; /* DEBUG: check name hash */
- char *cp; /* DEBUG: check name ptr/len */
-#endif
-
- /*
- * Setup: break out flag bits into variables.
- */
- wantparent = cnp->cn_flags & (LOCKPARENT|WANTPARENT);
- docache = (cnp->cn_flags & NOCACHE) ^ NOCACHE;
- if (cnp->cn_nameiop == DELETE ||
- (wantparent && cnp->cn_nameiop != CREATE))
- docache = 0;
- rdonly = cnp->cn_flags & RDONLY;
- cnp->cn_flags &= ~ISSYMLINK;
- dp = dvp;
- VOP_LOCK(dp);
-
-/* dirloop: */
- /*
- * Search a new directory.
- *
- * The cn_hash value is for use by vfs_cache.
- * The last component of the filename is left accessible via
- * cnp->cn_nameptr for callers that need the name. Callers needing
- * the name set the SAVENAME flag. When done, they assume
- * responsibility for freeing the pathname buffer.
- */
-#ifdef NAMEI_DIAGNOSTIC
- for (newhash = 0, cp = cnp->cn_nameptr; *cp != 0 && *cp != '/'; cp++)
- newhash += (unsigned char)*cp;
- if (newhash != cnp->cn_hash)
- panic("relookup: bad hash");
- if (cnp->cn_namelen != cp - cnp->cn_nameptr)
- panic ("relookup: bad len");
- if (*cp != 0)
- panic("relookup: not last component");
- printf("{%s}: ", cnp->cn_nameptr);
-#endif
-
- /*
- * Check for degenerate name (e.g. / or "")
- * which is a way of talking about a directory,
- * e.g. like "/." or ".".
- */
- if (cnp->cn_nameptr[0] == '\0') {
- if (cnp->cn_nameiop != LOOKUP || wantparent) {
- error = EISDIR;
- goto bad;
- }
- if (dp->v_type != VDIR) {
- error = ENOTDIR;
- goto bad;
- }
- if (!(cnp->cn_flags & LOCKLEAF))
- VOP_UNLOCK(dp);
- *vpp = dp;
- if (cnp->cn_flags & SAVESTART)
- panic("lookup: SAVESTART");
- return (0);
- }
-
- if (cnp->cn_flags & ISDOTDOT)
- panic ("relookup: lookup on dot-dot");
-
- /*
- * We now have a segment name to search for, and a directory to search.
- */
- if (error = VOP_LOOKUP(dp, vpp, cnp)) {
-#ifdef DIAGNOSTIC
- if (*vpp != NULL)
- panic("leaf should be empty");
-#endif
- if (error != EJUSTRETURN)
- goto bad;
- /*
- * If creating and at end of pathname, then can consider
- * allowing file to be created.
- */
- if (rdonly || (dvp->v_mount->mnt_flag & MNT_RDONLY)) {
- error = EROFS;
- goto bad;
- }
- /* ASSERT(dvp == ndp->ni_startdir) */
- if (cnp->cn_flags & SAVESTART)
- VREF(dvp);
- /*
- * 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);
- }
- dp = *vpp;
-
-#ifdef DIAGNOSTIC
- /*
- * Check for symbolic link
- */
- if (dp->v_type == VLNK && (cnp->cn_flags & FOLLOW))
- panic ("relookup: symlink found.\n");
-#endif
-
- /*
- * Check for 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;
- }
- }
- /* ASSERT(dvp == ndp->ni_startdir) */
- if (cnp->cn_flags & SAVESTART)
- VREF(dvp);
-
- if (!wantparent)
- vrele(dvp);
- if ((cnp->cn_flags & LOCKLEAF) == 0)
- VOP_UNLOCK(dp);
- return (0);
-
-bad2:
- if ((cnp->cn_flags & LOCKPARENT) && (cnp->cn_flags & ISLASTCN))
- VOP_UNLOCK(dvp);
- vrele(dvp);
-bad:
- vput(dp);
- *vpp = NULL;
- return (error);
-}
-
-
/*
* Rename system call.
* rename("foo", "bar");
OpenPOWER on IntegriCloud