Commit MetaInfo

Revision52d0bbddfaa9492f4c57347e0f9040e2bb09001f (tree)
Zeit2016-01-04 22:19:28
AutorYoshinori Sato <ysato@user...>
CommiterYoshinori Sato

Log Message

getdents is deprecated.
So redirect to readdir64 in ARCH_HAS_DEPRECATED_SYSCALLS.

Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>

Ändern Zusammenfassung

Diff

--- /dev/null
+++ b/libc/misc/dirent/__readdir.c
@@ -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+}
--- a/libc/misc/dirent/readdir.c
+++ b/libc/misc/dirent/readdir.c
@@ -10,53 +10,16 @@
1010 #include <stddef.h>
1111 #include "dirstream.h"
1212
13-#ifndef __READDIR
13+#if !defined __ARCH_HAS_DEPRECATED_SYSCALLS__
1414 # define __READDIR readdir
1515 # define __DIRENT_TYPE struct dirent
1616 # 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;
5017
51- /* Skip deleted files. */
52- } while (de->d_ino == 0);
18+# include "__readdir.c"
5319
54-all_done:
55- __UCLIBC_MUTEX_UNLOCK(dir->dd_lock);
56- return de;
57-}
5820 libc_hidden_def(__READDIR)
59-#if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64
21+# if WORDSIZE == 64
6022 strong_alias_untyped(readdir,readdir64)
6123 libc_hidden_def(readdir64)
24+# endif
6225 #endif
--- a/libc/misc/dirent/readdir64.c
+++ b/libc/misc/dirent/readdir64.c
@@ -6,11 +6,17 @@
66
77 #include <_lfs_64.h>
88 #include <dirent.h>
9+#include <errno.h>
10+#define __need_NULL
11+#include <stddef.h>
12+#include "dirstream.h"
913
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
1417
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)
Show on old repository browser