From owner-svn-src-head@FreeBSD.ORG Sat Jun 6 00:49:49 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9C9BE106564A; Sat, 6 Jun 2009 00:49:49 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8A44E8FC14; Sat, 6 Jun 2009 00:49:49 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n560nn69043379; Sat, 6 Jun 2009 00:49:49 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n560nnjb043378; Sat, 6 Jun 2009 00:49:49 GMT (envelope-from des@svn.freebsd.org) Message-Id: <200906060049.n560nnjb043378@svn.freebsd.org> From: Dag-Erling Smorgrav Date: Sat, 6 Jun 2009 00:49:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r193557 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jun 2009 00:49:50 -0000 Author: des Date: Sat Jun 6 00:49:49 2009 New Revision: 193557 URL: http://svn.freebsd.org/changeset/base/193557 Log: Eliminate trailing_slash, which was made redundant in r193028. Remove a couple of 4-year-old "temporary" KASSERTs. Improve comments. MFC after: 1 week Modified: head/sys/kern/vfs_lookup.c Modified: head/sys/kern/vfs_lookup.c ============================================================================== --- head/sys/kern/vfs_lookup.c Sat Jun 6 00:44:13 2009 (r193556) +++ head/sys/kern/vfs_lookup.c Sat Jun 6 00:49:49 2009 (r193557) @@ -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 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.