From 2c1a69c62021b1afff436cf7b156df094d056e25 Mon Sep 17 00:00:00 2001 From: GNU Libc Maintainers Date: Sun, 14 Jan 2018 10:24:48 +0000 Subject: [PATCH] git-dirfd-linknamespace commit 8f5238538d47e958cad2490732fbb27e7b1cd8ab Author: Samuel Thibault Date: Wed Sep 27 23:46:51 2017 +0200 hurd: Fix dirfd symbol exposition from ftw dirfd is XOPEN2K8 only, it should not be exposed along ftw which is earlier. * include/dirent.h (__dirfd): New declaration. * dirent/dirfd.c (dirfd): Rename to __dirfd, and redefine as weak alias. * sysdeps/posix/dirfd/dirfd.c (dirfd): Likewise. * sysdeps/mach/hurd/dirfd.c (dirfd): Likewise. * io/ftw.c (open_dir_stream, ftw_dir): Use __dirfd instead of dirfd. + glob in glibc 2.26, removed later Gbp-Pq: Topic hurd-i386 Gbp-Pq: Name git-dirfd-linknamespace.diff --- dirent/dirfd.c | 3 ++- include/dirent.h | 1 + io/ftw.c | 6 +++--- posix/glob.c | 2 +- sysdeps/mach/hurd/dirfd.c | 4 +++- sysdeps/posix/dirfd.c | 4 +++- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/dirent/dirfd.c b/dirent/dirfd.c index 7af77adf0..c1069ffb8 100644 --- a/dirent/dirfd.c +++ b/dirent/dirfd.c @@ -21,10 +21,11 @@ #include int -dirfd (DIR *dirp) +__dirfd (DIR *dirp) { __set_errno (ENOSYS); return -1; } +weak_alias (__dirfd, dirfd) stub_warning (dirfd) diff --git a/include/dirent.h b/include/dirent.h index c792e53c9..9e72ae3ca 100644 --- a/include/dirent.h +++ b/include/dirent.h @@ -48,6 +48,7 @@ extern DIR *__alloc_dir (int fd, bool close_fd, int flags, const struct stat64 *statp) internal_function attribute_hidden; extern __typeof (rewinddir) __rewinddir; +extern __typeof (dirfd) __dirfd; extern void __scandir_cancel_handler (void *arg) attribute_hidden; extern int __scandir_tail (DIR *dp, diff --git a/io/ftw.c b/io/ftw.c index 140a23774..c8123885f 100644 --- a/io/ftw.c +++ b/io/ftw.c @@ -363,7 +363,7 @@ open_dir_stream (int *dfdp, struct ftw_data *data, struct dir_data *dirp) result = -1; else { - dirp->streamfd = dirfd (dirp->stream); + dirp->streamfd = __dirfd (dirp->stream); dirp->content = NULL; data->dirstreams[data->actdir] = dirp; @@ -522,7 +522,7 @@ fail: /* If necessary, change to this directory. */ if (data->flags & FTW_CHDIR) { - if (__fchdir (dirfd (dir.stream)) < 0) + if (__fchdir (__dirfd (dir.stream)) < 0) { result = -1; goto fail; @@ -606,7 +606,7 @@ fail: /* Change back to the parent directory. */ int done = 0; if (old_dir->stream != NULL) - if (__fchdir (dirfd (old_dir->stream)) == 0) + if (__fchdir (__dirfd (old_dir->stream)) == 0) done = 1; if (!done) diff --git a/posix/glob.c b/posix/glob.c index b2273ea7b..8d36cb158 100644 --- a/posix/glob.c +++ b/posix/glob.c @@ -1520,7 +1520,7 @@ glob_in_dir (const char *pattern, const char *directory, int flags, else { int dfd = (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0) - ? -1 : dirfd ((DIR *) stream)); + ? -1 : __dirfd ((DIR *) stream)); int fnm_flags = ((!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0) | ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0)); flags |= GLOB_MAGCHAR; diff --git a/sysdeps/mach/hurd/dirfd.c b/sysdeps/mach/hurd/dirfd.c index 0ad290d51..65673336e 100644 --- a/sysdeps/mach/hurd/dirfd.c +++ b/sysdeps/mach/hurd/dirfd.c @@ -22,7 +22,7 @@ #include int -dirfd (DIR *dirp) +__dirfd (DIR *dirp) { int fd; @@ -41,3 +41,5 @@ dirfd (DIR *dirp) return fd; } + +weak_alias (__dirfd, dirfd) diff --git a/sysdeps/posix/dirfd.c b/sysdeps/posix/dirfd.c index fee8326d9..ce779c50a 100644 --- a/sysdeps/posix/dirfd.c +++ b/sysdeps/posix/dirfd.c @@ -22,7 +22,9 @@ #undef dirfd int -dirfd (DIR *dirp) +__dirfd (DIR *dirp) { return dirp->fd; } + +weak_alias (__dirfd, dirfd) -- 2.30.2