kern/73777: [linux] [patch] linux emulation: root dir special handling useless and harmful

Andriy Gapon avg at icyb.net.ua
Sat Feb 23 07:50:03 UTC 2008


The following reply was made to PR kern/73777; it has been noted by GNATS.

From: Andriy Gapon <avg at icyb.net.ua>
To: bug-followup at FreeBSD.org
Cc:  
Subject: Re: kern/73777: [linux] [patch] linux emulation: root dir special
 handling useless and harmful
Date: Sat, 23 Feb 2008 09:46:53 +0200

 This is a multi-part message in MIME format.
 --------------080104050205040809080106
 Content-Type: text/plain; charset=UTF-8
 Content-Transfer-Encoding: 7bit
 
 
 Well, I think that the issue described in this PR still holds.
 On the other hand, I now think that some people might still prefer
 current behavior over what I suggest. There could be some POLA concerns too.
 Another concern is that now the code is common to all emulation, so it's
 not linux specific anymore.
 In any case, I am attaching a patch that I currently use.
 
 -- 
 Andriy Gapon
 
 --------------080104050205040809080106
 Content-Type: text/x-patch;
  name="rootdir-6.patch"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="rootdir-6.patch"
 
 --- sys/kern/vfs_lookup.c.orig	Fri May 12 16:03:41 2006
 +++ sys/kern/vfs_lookup.c	Fri May 12 16:09:31 2006
 @@ -955,7 +955,7 @@
  kern_alternate_path(struct thread *td, const char *prefix, char *path,
      enum uio_seg pathseg, char **pathbuf, int create)
  {
 -	struct nameidata nd, ndroot;
 +	struct nameidata nd;
  	char *ptr, *buf, *cp;
  	size_t len, sz;
  	int error;
 @@ -1014,28 +1014,6 @@
  		error = namei(&nd);
  		if (error != 0)
  			goto keeporig;
 -
 -		/*
 -		 * We now compare the vnode of the prefix to the one
 -		 * vnode asked. If they resolve to be the same, then we
 -		 * ignore the match so that the real root gets used.
 -		 * This avoids the problem of traversing "../.." to find the
 -		 * root directory and never finding it, because "/" resolves
 -		 * to the emulation root directory. This is expensive :-(
 -		 */
 -		NDINIT(&ndroot, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, prefix,
 -		    td);
 -
 -		/* We shouldn't ever get an error from this namei(). */
 -		error = namei(&ndroot);
 -		if (error == 0) {
 -			if (nd.ni_vp == ndroot.ni_vp)
 -				error = ENOENT;
 -
 -			NDFREE(&ndroot, NDF_ONLY_PNBUF);
 -			vrele(ndroot.ni_vp);
 -			VFS_UNLOCK_GIANT(NDHASGIANT(&ndroot));
 -		}
  	}
  
  	NDFREE(&nd, NDF_ONLY_PNBUF);
 
 --------------080104050205040809080106--


More information about the freebsd-emulation mailing list