Revision | 52d0bbddfaa9492f4c57347e0f9040e2bb09001f (tree) |
---|---|
Zeit | 2016-01-04 22:19:28 |
Autor | Yoshinori Sato <ysato@user...> |
Commiter | Yoshinori Sato |
getdents is deprecated.
So redirect to readdir64 in ARCH_HAS_DEPRECATED_SYSCALLS.
Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
@@ -0,0 +1,39 @@ | ||
1 | +__DIRENT_TYPE *__READDIR(DIR * dir) | |
2 | +{ | |
3 | + ssize_t bytes; | |
4 | + __DIRENT_TYPE *de; | |
5 | + | |
6 | + if (!dir) { | |
7 | + __set_errno(EBADF); | |
8 | + return NULL; | |
9 | + } | |
10 | + | |
11 | + __UCLIBC_MUTEX_LOCK(dir->dd_lock); | |
12 | + | |
13 | + do { | |
14 | + if (dir->dd_size <= dir->dd_nextloc) { | |
15 | + /* read dir->dd_max bytes of directory entries. */ | |
16 | + bytes = __GETDENTS(dir->dd_fd, dir->dd_buf, dir->dd_max); | |
17 | + if (bytes <= 0) { | |
18 | + de = NULL; | |
19 | + goto all_done; | |
20 | + } | |
21 | + dir->dd_size = bytes; | |
22 | + dir->dd_nextloc = 0; | |
23 | + } | |
24 | + | |
25 | + de = (__DIRENT_TYPE *) (((char *) dir->dd_buf) + dir->dd_nextloc); | |
26 | + | |
27 | + /* Am I right? H.J. */ | |
28 | + dir->dd_nextloc += de->d_reclen; | |
29 | + | |
30 | + /* We have to save the next offset here. */ | |
31 | + dir->dd_nextoff = de->d_off; | |
32 | + | |
33 | + /* Skip deleted files. */ | |
34 | + } while (de->d_ino == 0); | |
35 | + | |
36 | +all_done: | |
37 | + __UCLIBC_MUTEX_UNLOCK(dir->dd_lock); | |
38 | + return de; | |
39 | +} |
@@ -10,53 +10,16 @@ | ||
10 | 10 | #include <stddef.h> |
11 | 11 | #include "dirstream.h" |
12 | 12 | |
13 | -#ifndef __READDIR | |
13 | +#if !defined __ARCH_HAS_DEPRECATED_SYSCALLS__ | |
14 | 14 | # define __READDIR readdir |
15 | 15 | # define __DIRENT_TYPE struct dirent |
16 | 16 | # define __GETDENTS __getdents |
17 | -#endif | |
18 | - | |
19 | -__DIRENT_TYPE *__READDIR(DIR * dir) | |
20 | -{ | |
21 | - ssize_t bytes; | |
22 | - __DIRENT_TYPE *de; | |
23 | - | |
24 | - if (!dir) { | |
25 | - __set_errno(EBADF); | |
26 | - return NULL; | |
27 | - } | |
28 | - | |
29 | - __UCLIBC_MUTEX_LOCK(dir->dd_lock); | |
30 | - | |
31 | - do { | |
32 | - if (dir->dd_size <= dir->dd_nextloc) { | |
33 | - /* read dir->dd_max bytes of directory entries. */ | |
34 | - bytes = __GETDENTS(dir->dd_fd, dir->dd_buf, dir->dd_max); | |
35 | - if (bytes <= 0) { | |
36 | - de = NULL; | |
37 | - goto all_done; | |
38 | - } | |
39 | - dir->dd_size = bytes; | |
40 | - dir->dd_nextloc = 0; | |
41 | - } | |
42 | - | |
43 | - de = (__DIRENT_TYPE *) (((char *) dir->dd_buf) + dir->dd_nextloc); | |
44 | - | |
45 | - /* Am I right? H.J. */ | |
46 | - dir->dd_nextloc += de->d_reclen; | |
47 | - | |
48 | - /* We have to save the next offset here. */ | |
49 | - dir->dd_nextoff = de->d_off; | |
50 | 17 | |
51 | - /* Skip deleted files. */ | |
52 | - } while (de->d_ino == 0); | |
18 | +# include "__readdir.c" | |
53 | 19 | |
54 | -all_done: | |
55 | - __UCLIBC_MUTEX_UNLOCK(dir->dd_lock); | |
56 | - return de; | |
57 | -} | |
58 | 20 | libc_hidden_def(__READDIR) |
59 | -#if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64 | |
21 | +# if WORDSIZE == 64 | |
60 | 22 | strong_alias_untyped(readdir,readdir64) |
61 | 23 | libc_hidden_def(readdir64) |
24 | +# endif | |
62 | 25 | #endif |
@@ -6,11 +6,17 @@ | ||
6 | 6 | |
7 | 7 | #include <_lfs_64.h> |
8 | 8 | #include <dirent.h> |
9 | +#include <errno.h> | |
10 | +#define __need_NULL | |
11 | +#include <stddef.h> | |
12 | +#include "dirstream.h" | |
9 | 13 | |
10 | -#if __WORDSIZE != 64 | |
11 | -# define __READDIR readdir64 | |
12 | -# define __DIRENT_TYPE struct dirent64 | |
13 | -# define __GETDENTS __getdents64 | |
14 | +#define __READDIR readdir64 | |
15 | +#define __DIRENT_TYPE struct dirent64 | |
16 | +#define __GETDENTS __getdents64 | |
14 | 17 | |
15 | -# include "readdir.c" | |
16 | -#endif | |
18 | +# include "__readdir.c" | |
19 | + | |
20 | +libc_hidden_def(__READDIR) | |
21 | +strong_alias_untyped(readdir64,readdir) | |
22 | +libc_hidden_def(readdir) |