From owner-freebsd-emulation@FreeBSD.ORG Mon Mar 3 21:10:04 2008 Return-Path: Delivered-To: freebsd-emulation@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 19A081065670 for ; Mon, 3 Mar 2008 21:10:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 195C18FC12 for ; Mon, 3 Mar 2008 21:10:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m23LA3kZ075721 for ; Mon, 3 Mar 2008 21:10:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m23LA3eb075720; Mon, 3 Mar 2008 21:10:03 GMT (envelope-from gnats) Date: Mon, 3 Mar 2008 21:10:03 GMT Message-Id: <200803032110.m23LA3eb075720@freefall.freebsd.org> To: freebsd-emulation@FreeBSD.org From: Andriy Gapon Cc: Subject: Re: kern/73777: [linux] [patch] linux emulation: root dir special handling useless and harmful X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Andriy Gapon List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Mar 2008 21:10:04 -0000 The following reply was made to PR kern/73777; it has been noted by GNATS. From: Andriy Gapon To: bug-followup@FreeBSD.org Cc: Alexander Leidinger Subject: Re: kern/73777: [linux] [patch] linux emulation: root dir special handling useless and harmful Date: Mon, 03 Mar 2008 22:14:40 +0200 This is a multi-part message in MIME format. --------------050001090401010706020209 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit An updated patch that makes the proposed behavior controlled by sysctl. Present behavior is the default. -- Andriy Gapon --------------050001090401010706020209 Content-Type: text/x-patch; name="rootdir-7.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="rootdir-7.patch" --- sys/kern/vfs_lookup.c.orig 2007-09-21 13:16:56.000000000 +0300 +++ sys/kern/vfs_lookup.c 2008-03-03 22:03:16.000000000 +0200 @@ -96,6 +96,11 @@ SYSCTL_INT(_vfs, OID_AUTO, lookup_shared, CTLFLAG_RW, &lookup_shared, 0, "Enables/Disables shared locks for path name translation"); +static int alt_root_is_real_root = 1; +SYSCTL_INT(_vfs, OID_AUTO, alt_root_is_real_root, CTLFLAG_RW, + &alt_root_is_real_root, 0, + "Alternative/emulation root directory resolves to the real root"); + /* * Convert a pathname into a pointer to a locked vnode. * @@ -1071,26 +1076,28 @@ 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)); + if (alt_root_is_real_root) { + /* + * 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)); + } } } --------------050001090401010706020209--