diff options
author | Mike Frysinger <vapier@gentoo.org> | 2006-02-04 02:17:00 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2006-02-04 02:17:00 +0000 |
commit | bd5827f470708dae107797998ccd3022d52f1a9d (patch) | |
tree | 6251c5c0514d267e118d1feb8bfeb64927a6d1ec /libc/sysdeps/linux | |
parent | cfdee7ee021f45da878500d0a40c2a03fe99303a (diff) |
use just __getdents64 rather than either __getdents and __getdents64 when possible (saves space and gives us access to d_type most of the time)
Diffstat (limited to 'libc/sysdeps/linux')
-rw-r--r-- | libc/sysdeps/linux/common/getdents.c | 22 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/getdents64.c | 13 |
2 files changed, 24 insertions, 11 deletions
diff --git a/libc/sysdeps/linux/common/getdents.c b/libc/sysdeps/linux/common/getdents.c index 7056c3ebc..0c6eba658 100644 --- a/libc/sysdeps/linux/common/getdents.c +++ b/libc/sysdeps/linux/common/getdents.c @@ -16,6 +16,16 @@ #include <sys/types.h> #include <sys/syscall.h> +/* With newer versions of linux, the getdents syscall returns d_type + * information after the name field. Someday, we should add support for + * that instead of always calling getdents64 ... + * + * See __ASSUME_GETDENTS32_D_TYPE in glibc's kernel-features.h for specific + * version / arch details. + */ + +#if ! defined __UCLIBC_HAS_LFS__ || ! defined __NR_getdents64 + libc_hidden_proto(memcpy) libc_hidden_proto(lseek) @@ -25,10 +35,10 @@ libc_hidden_proto(lseek) struct kernel_dirent { - long d_ino; - __kernel_off_t d_off; - unsigned short d_reclen; - char d_name[256]; + long int d_ino; + __kernel_off_t d_off; + unsigned short int d_reclen; + char d_name[256]; }; #define __NR___syscall_getdents __NR_getdents @@ -89,3 +99,7 @@ ssize_t attribute_hidden __getdents (int fd, char *buf, size_t nbytes) } return (char *) dp - buf; } + +attribute_hidden strong_alias(__getdents,__getdents64) + +#endif diff --git a/libc/sysdeps/linux/common/getdents64.c b/libc/sysdeps/linux/common/getdents64.c index aa30bd661..da193ebab 100644 --- a/libc/sysdeps/linux/common/getdents64.c +++ b/libc/sysdeps/linux/common/getdents64.c @@ -17,7 +17,7 @@ #include <sys/types.h> #include <sys/syscall.h> -#if defined __UCLIBC_HAS_LFS__ && defined __NR_getdents64 +#if defined __UCLIBC_HAS_LFS__ && defined __NR_getdents64 libc_hidden_proto(memcpy) libc_hidden_proto(lseek64) @@ -94,10 +94,9 @@ ssize_t attribute_hidden __getdents64 (int fd, char *buf, size_t nbytes) } return (char *) dp - buf; } -#else -extern ssize_t __getdents (int fd, char *buf, size_t nbytes) attribute_hidden; -ssize_t attribute_hidden __getdents64 (int fd, char *buf, size_t nbytes) -{ - return(__getdents(fd, buf, nbytes)); -} + +/* since getdents doesnt give us d_type but getdents64 does, try and + * use getdents64 as much as possible */ +attribute_hidden strong_alias(__getdents64,__getdents) + #endif /* __UCLIBC_HAS_LFS__ */ |