Allow unknown root directory.
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 14 Jan 2018 10:24:48 +0000 (10:24 +0000)
committerAurelien Jarno <aurel32@debian.org>
Sun, 14 Jan 2018 10:24:48 +0000 (10:24 +0000)
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.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Gbp-Pq: Topic hurd-i386
Gbp-Pq: Name tg-remap_getcwd.diff

sysdeps/mach/hurd/getcwd.c

index 9b371b041a81a2b3b986ce6fcbbc3f340e309f33..192760bacd036771aa60cc56880ed9b420f8de7b 100644 (file)
@@ -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;
@@ -308,13 +303,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)