aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@schwinge.name>2012-05-10 15:23:51 -0700
committerRoland McGrath <roland@hack.frob.com>2012-05-10 15:57:26 -0700
commit80b4e5f3ef231702b24d44c33e8dceb70abb3a06 (patch)
treee8f734417310d2f1c1869d97a3a9d79082bcbd45
parentedadcbd6247ca741756e234b6aa5f3db895bdd3d (diff)
downloadtermbaud-80b4e5f3ef231702b24d44c33e8dceb70abb3a06.tar.gz
termbaud-80b4e5f3ef231702b24d44c33e8dceb70abb3a06.tar.xz
termbaud-80b4e5f3ef231702b24d44c33e8dceb70abb3a06.zip
Hurd: opendirat
-rw-r--r--ChangeLog4
-rw-r--r--sysdeps/mach/hurd/opendir.c37
2 files changed, 41 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 739ee9689ea..22b2605d43e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2012-05-10 Thomas Schwinge <thomas@schwinge.name>
+
+ * sysdeps/mach/hurd/opendir.c (__opendirat): New function.
+
2012-05-10 Samuel Thibault <samuel.thibault@ens-lyon.org>
* hurd/hurdchdir.c (_hurd_change_directory_port_from_name):
diff --git a/sysdeps/mach/hurd/opendir.c b/sysdeps/mach/hurd/opendir.c
index c71cb18a658..175944418cb 100644
--- a/sysdeps/mach/hurd/opendir.c
+++ b/sysdeps/mach/hurd/opendir.c
@@ -28,6 +28,7 @@
#include <stdio.h>
#include <hurd.h>
#include <hurd/fd.h>
+#include <not-cancel.h>
#include "dirstream.h"
@@ -67,10 +68,45 @@ _hurd_fd_opendir (struct hurd_fd *d)
}
+DIR *
+internal_function
+__opendirat (int dfd, const char *name)
+{
+ if (name[0] == '\0')
+ {
+ /* POSIX.1-1990 says an empty name gets ENOENT;
+ but `open' might like it fine. */
+ __set_errno (ENOENT);
+ return NULL;
+ }
+
+ int flags = O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC;
+ int fd;
+#ifdef IS_IN_rtld
+ assert (dfd == AT_FDCWD);
+ fd = open_not_cancel_2 (name, flags);
+#else
+ fd = openat_not_cancel_3 (dfd, name, flags);
+#endif
+ if (fd < 0)
+ return NULL;
+
+ /* Extract the pointer to the descriptor structure. */
+ DIR *dirp = _hurd_fd_opendir (_hurd_fd_get (fd));
+ if (dirp == NULL)
+ __close (fd);
+
+ return dirp;
+}
+
+
/* Open a directory stream on NAME. */
DIR *
__opendir (const char *name)
{
+#if 0 /* TODO. */
+ return __opendirat (AT_FDCWD, name);
+#else
if (name[0] == '\0')
{
/* POSIX.1-1990 says an empty name gets ENOENT;
@@ -89,5 +125,6 @@ __opendir (const char *name)
__close (fd);
return dirp;
+#endif
}
weak_alias (__opendir, opendir)