glibc/include/dirent.h
Joseph Myers 2f5c1b000a Fix __getcwd rewinddir namespace (bug 17584).
__getcwd is called from dcigettext.o (brought in by various ISO C
functionality), but calls rewinddir, which is not an ISO C function.
This patch makes __getcwd call __rewinddir instead and makes rewinddir
a weak alias for __rewinddir.

Since getcwd.c is shared with gnulib (albeit not merged in either
direction for a long time, and omitted from gnulib's
config/srclist.txt list of shared files) I put in a #ifndef _LIBC
define of __rewinddir to rewinddir, although a future merged version
of getcwd could end up looking significantly different.

Tested for x86_64 (testsuite, and that disassembly of installed shared
libraries is unchanged by this patch).

	[BZ #17584]
	* dirent/rewinddir.c (rewinddir): Rename to __rewinddir and define
	as weak alias of __rewinddir.  Don't use libc_hidden_def.
	(__rewinddir): Use libc_hidden_def.
	* sysdeps/mach/hurd/rewinddir.c: Rename to __rewinddir and define
	as weak alias of __rewinddir.  Don't use libc_hidden_def.
	(__rewinddir): Use libc_hidden_def.
	* sysdeps/posix/rewinddir.c: Rename to __rewinddir and define as
	weak alias of __rewinddir.  Don't use libc_hidden_def.
	(__rewinddir): Use libc_hidden_def.
	* include/dirent.h (rewinddir): Don't use libc_hidden_proto.
	(__rewinddir): Use libc_hidden_proto.
	* sysdeps/posix/getcwd.c [!_LIBC] (__rewinddir): Define to
	rewinddir.
	(__getcwd): Use __rewinddir instead of rewinddir.
2014-11-12 16:24:16 +00:00

58 lines
1.8 KiB
C

#ifndef _DIRENT_H
# ifndef _ISOMAC
# include <dirstream.h>
# endif
# include <dirent/dirent.h>
# ifndef _ISOMAC
# include <sys/stat.h>
# include <stdbool.h>
struct scandir_cancel_struct
{
DIR *dp;
void *v;
size_t cnt;
};
/* Now define the internal interfaces. */
extern DIR *__opendir (const char *__name);
extern DIR *__opendirat (int dfd, const char *__name) internal_function;
extern DIR *__fdopendir (int __fd);
extern int __closedir (DIR *__dirp);
extern struct dirent *__readdir (DIR *__dirp);
extern struct dirent64 *__readdir64 (DIR *__dirp);
extern int __readdir_r (DIR *__dirp, struct dirent *__entry,
struct dirent **__result);
extern int __readdir64_r (DIR *__dirp, struct dirent64 *__entry,
struct dirent64 **__result);
extern int __scandir64 (const char * __dir,
struct dirent64 *** __namelist,
int (*__selector) (const struct dirent64 *),
int (*__cmp) (const struct dirent64 **,
const struct dirent64 **));
extern __ssize_t __getdirentries (int __fd, char *__restrict __buf,
size_t __nbytes,
__off_t *__restrict __basep)
__THROW __nonnull ((2, 4));
extern __ssize_t __getdents (int __fd, char *__buf, size_t __nbytes)
internal_function;
extern __ssize_t __getdents64 (int __fd, char *__buf, size_t __nbytes)
internal_function;
extern int __alphasort64 (const struct dirent64 **a, const struct dirent64 **b)
__attribute_pure__;
extern int __versionsort64 (const struct dirent64 **a,
const struct dirent64 **b)
__attribute_pure__;
extern DIR *__alloc_dir (int fd, bool close_fd, int flags,
const struct stat64 *statp)
internal_function;
extern void __scandir_cancel_handler (void *arg);
extern __typeof (rewinddir) __rewinddir;
libc_hidden_proto (__rewinddir)
libc_hidden_proto (scandirat)
libc_hidden_proto (scandirat64)
# endif
#endif