aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <[email protected]>2017-10-11 15:38:39 +0000
committerWerner Koch <[email protected]>2017-10-12 07:00:09 +0000
commit00daac15530eabed5e61d841b2df939c2242667c (patch)
treebe95b0950651e2fa975f348bb1f36c9422a37715
parentcore: Allow disabling the use of SYS_getdents for Linux. (diff)
downloadgpgme-00daac15530eabed5e61d841b2df939c2242667c.tar.gz
gpgme-00daac15530eabed5e61d841b2df939c2242667c.zip
core: use getdents64 syscall on linux instead of getdents.
* 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 <[email protected]>
-rw-r--r--src/posix-io.c15
1 files 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;