]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - hurd/lookup-at.c
ldbl-opt: Reuse test cases from misc/ that check long double
[thirdparty/glibc.git] / hurd / lookup-at.c
index 7f55527d8be0759e5efe8f7536fba0ee130a64da..43430b57621e46cf4d293806588c8464e3f93e2f 100644 (file)
@@ -1,5 +1,5 @@
 /* Lookup helper function for Hurd implementation of *at functions.
-   Copyright (C) 2006,2010 Free Software Foundation, Inc.
+   Copyright (C) 2006-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -13,9 +13,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <hurd.h>
 #include <hurd/lookup.h>
@@ -29,20 +28,39 @@ __file_name_lookup_at (int fd, int at_flags,
 {
   error_t err;
   file_t result;
+  int empty = at_flags & AT_EMPTY_PATH;
 
-  flags |= (at_flags & AT_SYMLINK_NOFOLLOW) ? O_NOLINK : 0;
-  at_flags &= ~AT_SYMLINK_NOFOLLOW;
-  if (at_flags != 0)
-    return (__hurd_fail (EINVAL), MACH_PORT_NULL);
+  at_flags &= ~AT_EMPTY_PATH;
+
+  err = __hurd_at_flags (&at_flags, &flags);
+  if (err)
+    return (__hurd_fail (err), MACH_PORT_NULL);
 
   if (fd == AT_FDCWD || file_name[0] == '/')
     return __file_name_lookup (file_name, flags, mode);
 
+  if (empty != 0 && file_name[0] == '\0')
+    {
+      enum retry_type doretry;
+      char retryname[1024];    /* XXX string_t LOSES! */
+
+      err = HURD_DPORT_USE (fd, __dir_lookup (port, "", flags, mode,
+                                             &doretry, retryname,
+                                             &result));
+
+      if (! err)
+       err = __hurd_file_name_lookup_retry (&_hurd_ports_use, &__getdport,
+                                            NULL, doretry, retryname,
+                                            flags, mode, &result);
+
+      return err ? (__hurd_dfail (fd, err), MACH_PORT_NULL) : result;
+    }
+
   file_t startdir;
   error_t use_init_port (int which, error_t (*operate) (mach_port_t))
     {
-      return (which == INIT_PORT_CWDIR ? (*operate) (startdir) :
-             _hurd_ports_use (which, operate));
+      return (which == INIT_PORT_CWDIR ? (*operate) (startdir)
+             _hurd_ports_use (which, operate));
     }
 
   err = HURD_DPORT_USE (fd, (startdir = port,
@@ -71,8 +89,8 @@ __file_name_split_at (int fd, const char *file_name, char **name)
   file_t startdir;
   error_t use_init_port (int which, error_t (*operate) (mach_port_t))
   {
-    return (which == INIT_PORT_CWDIR ? (*operate) (startdir) :
-           _hurd_ports_use (which, operate));
+    return (which == INIT_PORT_CWDIR ? (*operate) (startdir)
+           _hurd_ports_use (which, operate));
   }
 
   err = HURD_DPORT_USE (fd, (startdir = port,
@@ -96,8 +114,8 @@ __directory_name_split_at (int fd, const char *directory_name, char **name)
   file_t startdir;
   error_t use_init_port (int which, error_t (*operate) (mach_port_t))
     {
-      return (which == INIT_PORT_CWDIR ? (*operate) (startdir) :
-             _hurd_ports_use (which, operate));
+      return (which == INIT_PORT_CWDIR ? (*operate) (startdir)
+             _hurd_ports_use (which, operate));
     }
 
   err = HURD_DPORT_USE (fd, (startdir = port,