diff options
author | des <des@FreeBSD.org> | 2009-06-06 00:49:49 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2009-06-06 00:49:49 +0000 |
commit | 8b0be2f4d32382d5d406e9dfec8ea38827b4bb46 (patch) | |
tree | b3710a521a42eb4ff5429eb9d4da3322f615eed7 /sys/kern/vfs_lookup.c | |
parent | 1e782303dec5a1467e980e58e8ba2cdfb54bacf7 (diff) | |
download | FreeBSD-src-8b0be2f4d32382d5d406e9dfec8ea38827b4bb46.zip FreeBSD-src-8b0be2f4d32382d5d406e9dfec8ea38827b4bb46.tar.gz |
Eliminate trailing_slash, which was made redundant in r193028.
Remove a couple of 4-year-old "temporary" KASSERTs.
Improve comments.
MFC after: 1 week
Diffstat (limited to 'sys/kern/vfs_lookup.c')
-rw-r--r-- | sys/kern/vfs_lookup.c | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index 7847f35..85173eda 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -453,7 +453,6 @@ lookup(struct nameidata *ndp) int docache; /* == 0 do not cache last component */ int wantparent; /* 1 => wantparent or lockparent flag */ int rdonly; /* lookup read-only flag bit */ - int trailing_slash; int error = 0; int dpunlocked = 0; /* dp has already been unlocked */ struct componentname *cnp = &ndp->ni_cnd; @@ -528,13 +527,11 @@ dirloop: * trailing slashes to handle symlinks, existing non-directories * and non-existing files that won't be directories specially later. */ - trailing_slash = 0; while (*cp == '/' && (cp[1] == '/' || cp[1] == '\0')) { cp++; ndp->ni_pathlen--; if (*cp == '\0') { - trailing_slash = 1; - *ndp->ni_next = '\0'; /* XXX for direnter() ... */ + *ndp->ni_next = '\0'; cnp->cn_flags |= TRAILINGSLASH; } } @@ -703,27 +700,24 @@ unionlookup: if (error != EJUSTRETURN) goto bad; /* - * If creating and at end of pathname, then can consider - * allowing file to be created. + * At this point, we know we're at the end of the + * pathname. If creating / renaming, we can consider + * allowing the file or directory to be created / renamed, + * provided we're not on a read-only filesystem. */ if (rdonly) { error = EROFS; goto bad; } - if (*cp == '\0' && trailing_slash && - !(cnp->cn_flags & WILLBEDIR)) { + /* trailing slash only allowed for directories */ + if ((cnp->cn_flags & TRAILINGSLASH) && + !(cnp->cn_flags & WILLBEDIR)) { error = ENOENT; goto bad; } if ((cnp->cn_flags & LOCKPARENT) == 0) VOP_UNLOCK(dp, 0); /* - * This is a temporary assert to make sure I know what the - * behavior here was. - */ - KASSERT((cnp->cn_flags & (WANTPARENT|LOCKPARENT)) != 0, - ("lookup: Unhandled case.")); - /* * We return with ni_vp NULL to indicate that the entry * doesn't currently exist, leaving a pointer to the * (possibly locked) directory vnode in ndp->ni_dvp. @@ -787,7 +781,7 @@ unionlookup: * Check for symbolic link */ if ((dp->v_type == VLNK) && - ((cnp->cn_flags & FOLLOW) || trailing_slash || + ((cnp->cn_flags & FOLLOW) || (cnp->cn_flags & TRAILINGSLASH) || *ndp->ni_next == '/')) { cnp->cn_flags |= ISSYMLINK; if (dp->v_iflag & VI_DOOMED) { @@ -812,8 +806,8 @@ unionlookup: nextname: /* - * Not a symbolic link. If more pathname, - * continue at next component, else return. + * Not a symbolic link that we will follow. Continue with the + * next component if there is any; otherwise, we're done. */ KASSERT((cnp->cn_flags & ISLASTCN) || *ndp->ni_next == '/', ("lookup: invalid path state.")); @@ -990,12 +984,6 @@ relookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp) if ((cnp->cn_flags & LOCKPARENT) == 0) VOP_UNLOCK(dp, 0); /* - * This is a temporary assert to make sure I know what the - * behavior here was. - */ - KASSERT((cnp->cn_flags & (WANTPARENT|LOCKPARENT)) != 0, - ("relookup: Unhandled case.")); - /* * We return with ni_vp NULL to indicate that the entry * doesn't currently exist, leaving a pointer to the * (possibly locked) directory vnode in ndp->ni_dvp. |