diff options
author | Ulrich Drepper <drepper@gmail.com> | 2011-08-09 09:57:55 -0400 |
---|---|---|
committer | Ulrich Drepper <drepper@gmail.com> | 2011-08-09 09:57:55 -0400 |
commit | c55fbd1ea768f9fdef34a01377702c0d72cbc213 (patch) | |
tree | 0e67d339ad240756843292384535c40cad03df95 /sysdeps/unix/opendir.c | |
parent | 879165f25a1a6b13995e43c11e88b1a21b6f101e (diff) | |
download | glibc-c55fbd1ea768f9fdef34a01377702c0d72cbc213.tar.gz glibc-c55fbd1ea768f9fdef34a01377702c0d72cbc213.tar.xz glibc-c55fbd1ea768f9fdef34a01377702c0d72cbc213.zip |
Implement scandirat function
Diffstat (limited to 'sysdeps/unix/opendir.c')
-rw-r--r-- | sysdeps/unix/opendir.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/sysdeps/unix/opendir.c b/sysdeps/unix/opendir.c index c2d1ddaf88..58d31764da 100644 --- a/sysdeps/unix/opendir.c +++ b/sysdeps/unix/opendir.c @@ -17,6 +17,7 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#include <assert.h> #include <errno.h> #include <limits.h> #include <stddef.h> @@ -76,9 +77,9 @@ tryopen_o_directory (void) #endif -/* Open a directory stream on NAME. */ DIR * -__opendir (const char *name) +internal_function +__opendirat (int dfd, const char *name) { struct stat64 statbuf; struct stat64 *statp = NULL; @@ -116,7 +117,13 @@ __opendir (const char *name) #ifdef O_CLOEXEC flags |= O_CLOEXEC; #endif - int fd = open_not_cancel_2 (name, flags); + 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 (__builtin_expect (fd, 0) < 0) return NULL; @@ -140,6 +147,14 @@ __opendir (const char *name) return __alloc_dir (fd, true, 0, statp); } + + +/* Open a directory stream on NAME. */ +DIR * +__opendir (const char *name) +{ + return __opendirat (AT_FDCWD, name); +} weak_alias (__opendir, opendir) |