dirent-util: introduce simple wrapper of posix_getdents()

glibc exports getdents64 syscall as is, but musl exports it as
posix_getdents(). Let's introduce a simple wrapper of posix_getdents().

Note, our baseline for glibc is 2.31. Hence, we can assume getdents64()
always defined when building with glibc.
This commit is contained in:
Yu Watanabe
2025-03-04 04:23:57 +09:00
parent ec32732043
commit e86a492ff0
5 changed files with 11 additions and 15 deletions
+1 -2
View File
@@ -19,7 +19,6 @@
#include "macro.h"
#include "missing_fs.h"
#include "missing_magic.h"
#include "missing_syscall.h"
#include "mountpoint-util.h"
#include "nulstr-util.h"
#include "parse-util.h"
@@ -172,7 +171,7 @@ int dir_is_empty_at(int dir_fd, const char *path, bool ignore_hidden_or_backup)
struct dirent *de;
ssize_t n;
n = getdents64(fd, buf, m);
n = posix_getdents(fd, buf, m, /* flags = */ 0);
if (n < 0)
return -errno;
if (n == 0)