svn commit: r202994 - stable/7/sys/kern

Colin Percival cperciva at FreeBSD.org
Mon Jan 25 23:48:48 UTC 2010


Author: cperciva
Date: Mon Jan 25 23:48:47 2010
New Revision: 202994
URL: http://svn.freebsd.org/changeset/base/202994

Log:
  Add support for "at vp" lookups to namei.  This functionality was added
  to HEAD in r185029; but this is an "inspired by" commit rather than a
  literal merge, since this region of code in HEAD has other non-MFCable
  changes.
  
  The namei lookups this unbreaks are required for ZFS extended attributes;
  prior to this commit, an attempt to look up (list, read, write, delete)
  extended attributes would be handled as an attempt to look up a file in
  the current directory if an extended attribute directory existed ("at vp"
  was mishandled as "right here").
  
  Reviewed by:	jhb
  Approved by:	re (kib)
  Found by:	Henrik Wiest & libarchive

Modified:
  stable/7/sys/kern/vfs_lookup.c

Modified: stable/7/sys/kern/vfs_lookup.c
==============================================================================
--- stable/7/sys/kern/vfs_lookup.c	Mon Jan 25 23:44:00 2010	(r202993)
+++ stable/7/sys/kern/vfs_lookup.c	Mon Jan 25 23:48:47 2010	(r202994)
@@ -191,10 +191,26 @@ namei(struct nameidata *ndp)
 	ndp->ni_rootdir = fdp->fd_rdir;
 	ndp->ni_topdir = fdp->fd_jdir;
 
-	dp = fdp->fd_cdir;
+	if (ndp->ni_startdir != NULL) {
+		dp = ndp->ni_startdir;
+		FILEDESC_SUNLOCK(fdp);
+		if (dp->v_type != VDIR) {
+			vfslocked = VFS_LOCK_GIANT(dp->v_mount);
+			vrele(dp);
+			VFS_UNLOCK_GIANT(vfslocked);
+			uma_zfree(namei_zone, cnp->cn_pnbuf);
+#ifdef DIAGNOSTIC
+			cnp->cn_pnbuf = NULL;
+			cnp->cn_nameptr = NULL;
+#endif
+			return (ENOTDIR);
+		}
+	} else {
+		dp = fdp->fd_cdir;
+		VREF(dp);
+		FILEDESC_SUNLOCK(fdp);
+	}
 	vfslocked = VFS_LOCK_GIANT(dp->v_mount);
-	VREF(dp);
-	FILEDESC_SUNLOCK(fdp);
 	for (;;) {
 		/*
 		 * Check if root directory should replace current directory.


More information about the svn-src-stable mailing list