From patchwork Sat Feb 7 22:11:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 4963 Received: (qmail 24098 invoked by alias); 7 Feb 2015 22:11:18 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 24082 invoked by uid 89); 7 Feb 2015 22:11:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: sonata.ens-lyon.org Date: Sat, 7 Feb 2015 23:11:13 +0100 From: Samuel Thibault To: Roland McGrath Cc: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: [PATCH] hurd: Allow unknown root directory Message-ID: <20150207221113.GX3023@type.youpi.perso.aquilenet.fr> Mail-Followup-To: Roland McGrath , libc-alpha@sourceware.org, bug-hurd@gnu.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30) To be efficient, the remap translator simply returns ports from the underlying filesystem, and thus the root directory found through browsing '..' is the underlying root, not the remap root. This should not be a reason for getcwd to fail. * sysdeps/mach/hurd/getcwd.c (_hurd_canonicalize_directory_name_internal): Do not remove the heading slash if we got an unknown root directory. (__getcwd): Do not fail with EGRATUITOUS if we got an unknown root directory. --- sysdeps/mach/hurd/getcwd.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/sysdeps/mach/hurd/getcwd.c b/sysdeps/mach/hurd/getcwd.c index d1ac7ae..3d4d056 100644 --- a/sysdeps/mach/hurd/getcwd.c +++ b/sysdeps/mach/hurd/getcwd.c @@ -266,11 +266,6 @@ _hurd_canonicalize_directory_name_internal (file_t thisdir, So the root is our current directory. */ *--file_namep = '/'; - if (thisid != rootid) - /* We did not get to our root directory. The returned name should - not begin with a slash. */ - ++file_namep; - memmove (file_name, file_namep, file_name + size - file_namep); cleanup (); return file_name; @@ -310,13 +305,6 @@ __getcwd (char *buf, size_t size) __USEPORT (CWDIR, _hurd_canonicalize_directory_name_internal (port, buf, size)); - if (cwd && cwd[0] != '/') - { - /* `cwd' is an unknown root directory. */ - if (buf == NULL) - free (cwd); - return __hurd_fail (EGRATUITOUS), NULL; - } return cwd; } weak_alias (__getcwd, getcwd)