From aab35b1e5907a7ac0a218b4f220c66e6d79eb39a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 8 Oct 2021 10:46:02 +0200 Subject: [PATCH] missing: add getdents64() syscall wrapper glibc 2.30 (Aug 2019) added a wrapper for getdents64(). For older versions let's define our own. (This syscall exists since Linux 2.4, hence should be safe to use for us) --- meson.build | 1 + src/basic/missing_syscall.h | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/meson.build b/meson.build index 7d97ba2fe93..6c5d4bb34cc 100644 --- a/meson.build +++ b/meson.build @@ -546,6 +546,7 @@ foreach ident : [ ['mount_setattr', '''#include '''], ['move_mount', '''#include '''], ['open_tree', '''#include '''], + ['getdents64', '''#include '''], ] have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE') diff --git a/src/basic/missing_syscall.h b/src/basic/missing_syscall.h index 57dae77b535..5e80fa79fd0 100644 --- a/src/basic/missing_syscall.h +++ b/src/basic/missing_syscall.h @@ -540,3 +540,19 @@ static inline int missing_move_mount( # define move_mount missing_move_mount #endif + +/* ======================================================================= */ + +#if !HAVE_GETDENTS64 + +static inline ssize_t missing_getdents64(int fd, void *buffer, size_t length) { +# if defined __NR_getdents64 && __NR_getdents64 >= 0 + return syscall(__NR_getdents64, fd, buffer, length); +# else + errno = ENOSYS; + return -1; +# endif +} + +# define getdents64 missing_getdents64 +#endif