[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] lib: Fix getdents64 syscall.
From: |
Andrius Štikonas |
Subject: |
[PATCH] lib: Fix getdents64 syscall. |
Date: |
Sun, 28 Jan 2024 21:20:12 +0000 |
getdents64 syscall returns slightly different dirent struct.
* include/linux/x86_64/syscall.h (SYS_getdents): Remove define.
(getdents64): Add define.
* lib/linux/getdents.c (getdents): Prioritize getdents64 syscall.
* include/dirent.h (struct dirent): Adjust for getdents64 syscall.
---
include/dirent.h | 2 +-
include/linux/x86_64/syscall.h | 2 +-
lib/linux/getdents.c | 6 +++---
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/dirent.h b/include/dirent.h
index 7b4a0787..470c3aa8 100644
--- a/include/dirent.h
+++ b/include/dirent.h
@@ -48,7 +48,7 @@ struct dirent
ino_t d_ino;
off_t d_off;
unsigned short int d_reclen;
-#if 0
+#if defined (SYS_getdents64)
unsigned char d_type;
#endif
char d_name[256]; /* We must not include limits.h! */
diff --git a/include/linux/x86_64/syscall.h b/include/linux/x86_64/syscall.h
index 1c04cfcc..cee16361 100644
--- a/include/linux/x86_64/syscall.h
+++ b/include/linux/x86_64/syscall.h
@@ -79,7 +79,7 @@
#define SYS_setitimer 0x26
#define SYS_fstat 0x05
#define SYS_nanosleep 0x33
-#define SYS_getdents 0x4e
+#define SYS_getdents64 0xd9
// bash
#define SYS_setuid 0x69
diff --git a/lib/linux/getdents.c b/lib/linux/getdents.c
index 16563b42..53dd9664 100644
--- a/lib/linux/getdents.c
+++ b/lib/linux/getdents.c
@@ -26,10 +26,10 @@
int
getdents (int filedes, char *buffer, size_t nbytes)
{
-#if defined (SYS_getdents)
- return _sys_call3 (SYS_getdents, (int) filedes, (long) buffer, (long)
nbytes);
-#elif defined (SYS_getdents64)
+#if defined (SYS_getdents64)
return _sys_call3 (SYS_getdents64, (int) filedes, (long) buffer, (long)
nbytes);
+#elif defined (SYS_getdents)
+ return _sys_call3 (SYS_getdents, (int) filedes, (long) buffer, (long)
nbytes);
#else
#error No usable getdents syscall
#endif
--
2.43.0
- [PATCH] lib: Fix getdents64 syscall.,
Andrius Štikonas <=