[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Switch to getdents64 syscall.
From: |
Andrius Štikonas |
Subject: |
[PATCH] Switch to getdents64 syscall. |
Date: |
Sun, 28 Jan 2024 19:13:25 +0000 |
It returns different dirent stuct than getdents syscall,
so we cannot use the same struct for different syscalls.
* lib/linux/getdents.c: use getdents64 syscall.
* include/linux/x86/syscall.h: getdents64 syscall.
* include/dirent.h: adjust struct for getdents64 syscall
---
include/dirent.h | 2 --
include/linux/x86/syscall.h | 2 +-
lib/linux/getdents.c | 5 ++---
3 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/include/dirent.h b/include/dirent.h
index 7b4a0787..6cc25ea3 100644
--- a/include/dirent.h
+++ b/include/dirent.h
@@ -48,9 +48,7 @@ struct dirent
ino_t d_ino;
off_t d_off;
unsigned short int d_reclen;
-#if 0
unsigned char d_type;
-#endif
char d_name[256]; /* We must not include limits.h! */
};
diff --git a/include/linux/x86/syscall.h b/include/linux/x86/syscall.h
index 24c9493f..feb6dcc8 100644
--- a/include/linux/x86/syscall.h
+++ b/include/linux/x86/syscall.h
@@ -81,7 +81,7 @@
#define SYS_setitimer 0x68
#define SYS_fstat 0x6c
#define SYS_nanosleep 0xa2
-#define SYS_getdents 0x8d
+#define SYS_getdents64 0xdc
/* bash */
#define SYS_setuid 0x17
diff --git a/lib/linux/getdents.c b/lib/linux/getdents.c
index 16563b42..e47b564a 100644
--- a/lib/linux/getdents.c
+++ b/lib/linux/getdents.c
@@ -2,6 +2,7 @@
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
+ * Copyright © 2024 Andrius Štikonas <andrius@stikonas.eu>
*
* This file is part of GNU Mes.
*
@@ -26,9 +27,7 @@
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);
#else
#error No usable getdents syscall
--
2.43.0
- [PATCH] Switch to getdents64 syscall.,
Andrius Štikonas <=