33 lines
1.7 KiB
Diff
33 lines
1.7 KiB
Diff
Upstream: no
|
|
Source: https://raw.githubusercontent.com/chimera-linux/cports/81f0a3c25df2a841c2d99d752e60296062bf7543/main/elogind/patches/getdents.patch
|
|
|
|
From dab02796780f00d689cc1c7a0ba81abe7c5f28d0 Mon Sep 17 00:00:00 2001
|
|
From: Khem Raj <raj.khem@gmail.com>
|
|
Date: Fri, 21 Jan 2022 15:15:11 -0800
|
|
Subject: [PATCH] pass correct parameters to getdents64
|
|
|
|
Fixes musl system only
|
|
../git/src/basic/recurse-dir.c:57:40: error: incompatible pointer types passing 'uint8_t *' (aka 'unsigned char *') to parameter of type 'struct dirent *' [-Werror,-Wincompatible-pointer-types]
|
|
n = getdents64(dir_fd, (uint8_t*) de->buffer + de->buffer_size, bs - de->buffer_size);
|
|
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
../git/src/basic/stat-util.c:102:28: error: incompatible pointer types passing 'union (unnamed union at ../git/src/basic/stat-util.c:78:9) *' to parameter of type 'struct dirent *' [-Werror,-Wincompatible-pointer-types]
|
|
n = getdents64(fd, &buffer, sizeof(buffer));
|
|
|
|
diff --git a/src/basic/recurse-dir.c b/src/basic/recurse-dir.c
|
|
index d16ca98..0480a69 100644
|
|
--- a/src/basic/recurse-dir.c
|
|
+++ b/src/basic/recurse-dir.c
|
|
@@ -54,7 +54,11 @@ int readdir_all(int dir_fd,
|
|
bs = MIN(MALLOC_SIZEOF_SAFE(de) - offsetof(DirectoryEntries, buffer), (size_t) SSIZE_MAX);
|
|
assert(bs > de->buffer_size);
|
|
|
|
+ #ifdef __GLIBC__
|
|
n = getdents64(dir_fd, (uint8_t*) de->buffer + de->buffer_size, bs - de->buffer_size);
|
|
+ #else
|
|
+ n = getdents(dir_fd, (struct dirent*)((uint8_t*) de->buffer + de->buffer_size), bs - de->buffer_size);
|
|
+ #endif
|
|
if (n < 0)
|
|
return -errno;
|
|
if (n == 0)
|