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.
This commit is contained in:
Samuel Thibault 2017-09-27 23:46:51 +02:00
parent 825adeeed1
commit 2c7bbfaf4e
6 changed files with 21 additions and 6 deletions

View File

@ -1,3 +1,12 @@
2017-09-27 Samuel Thibault <samuel.thibault@ens-lyon.org>
* 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.
2017-09-26 H.J. Lu <hongjiu.lu@intel.com>
[BZ #18822]

View File

@ -21,10 +21,11 @@
#include <errno.h>
int
dirfd (DIR *dirp)
__dirfd (DIR *dirp)
{
__set_errno (ENOSYS);
return -1;
}
weak_alias (__dirfd, dirfd)
stub_warning (dirfd)

View File

@ -46,6 +46,7 @@ extern int __versionsort64 (const struct dirent64 **a,
extern DIR *__alloc_dir (int fd, bool close_fd, int flags,
const struct stat64 *statp) 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,

View File

@ -361,7 +361,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;
@ -518,7 +518,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;
@ -602,7 +602,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)

View File

@ -22,7 +22,7 @@
#include <errno.h>
int
dirfd (DIR *dirp)
__dirfd (DIR *dirp)
{
int fd;
@ -41,3 +41,5 @@ dirfd (DIR *dirp)
return fd;
}
weak_alias (__dirfd, dirfd)

View File

@ -22,7 +22,9 @@
#undef dirfd
int
dirfd (DIR *dirp)
__dirfd (DIR *dirp)
{
return dirp->fd;
}
weak_alias (__dirfd, dirfd)