[GPGME PATCH] core: use getdents64 syscall on linux instead of getdents.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Wed Oct 11 17:38:39 CEST 2017
* src/posix-io.c (get_max_fds): use getdents64 instead of getdents.
--
getdents64 was introduced in linux 2.4, so it should be widely
available. some Linux architectures which post-date 2.4 (e.g. arm64)
appear to not have getdents at all, so it's probably better to use the
more modern interface.
Signed-off-by: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
---
src/posix-io.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/posix-io.c b/src/posix-io.c
index 9b7b181d..0448d296 100644
--- a/src/posix-io.c
+++ b/src/posix-io.c
@@ -282,13 +282,14 @@ _gpgme_io_set_nonblocking (int fd)
#ifdef USE_LINUX_GETDENTS
-/* This is not declared in public headers; getdents(2) says that we must
+/* This is not declared in public headers; getdents64(2) says that we must
* define it ourselves. */
-struct linux_dirent
+struct linux_dirent64
{
- unsigned long d_ino;
- unsigned long d_off;
+ ino64_t d_ino;
+ off64_t d_off;
unsigned short d_reclen;
+ unsigned char d_type;
char d_name[];
};
@@ -316,7 +317,7 @@ get_max_fds (void)
{
int dir_fd;
char dir_buf[DIR_BUF_SIZE];
- struct linux_dirent *dir_entry;
+ struct linux_dirent64 *dir_entry;
int r, pos;
const char *s;
int x;
@@ -326,7 +327,7 @@ get_max_fds (void)
{
for (;;)
{
- r = syscall(SYS_getdents, dir_fd, dir_buf, DIR_BUF_SIZE);
+ r = syscall(SYS_getdents64, dir_fd, dir_buf, DIR_BUF_SIZE);
if (r == -1)
{
/* Fall back to other methods. */
@@ -338,7 +339,7 @@ get_max_fds (void)
for (pos = 0; pos < r; pos += dir_entry->d_reclen)
{
- dir_entry = (struct linux_dirent *) (dir_buf + pos);
+ dir_entry = (struct linux_dirent64 *) (dir_buf + pos);
s = dir_entry->d_name;
if (*s < '0' || *s > '9')
continue;
--
2.14.2
More information about the Gnupg-devel
mailing list