]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
missing: add getdents64() syscall wrapper
authorLennart Poettering <lennart@poettering.net>
Fri, 8 Oct 2021 08:46:02 +0000 (10:46 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 11 Oct 2021 12:31:34 +0000 (14:31 +0200)
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
src/basic/missing_syscall.h

index 7d97ba2fe935a0380a7fd40ec4abbb821e8f0f11..6c5d4bb34cc16d035649727fd8ca8adae7124fe8 100644 (file)
@@ -546,6 +546,7 @@ foreach ident : [
         ['mount_setattr',     '''#include <sys/mount.h>'''],
         ['move_mount',        '''#include <sys/mount.h>'''],
         ['open_tree',         '''#include <sys/mount.h>'''],
+        ['getdents64',        '''#include <dirent.h>'''],
 ]
 
         have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
index 57dae77b5357d7b62039f307b3dca919faa399a1..5e80fa79fd0bf97e8318865930cc9bb2f27a9a06 100644 (file)
@@ -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