summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAriadne Conill <ariadne@dereferenced.org>2021-12-13 11:47:57 -0600
committerAriadne Conill <ariadne@dereferenced.org>2021-12-14 12:57:47 -0600
commit8e5f4910f8ae653f4ff30c0b3c23a4b659036f9b (patch)
treee6934cb24041c83abb6639643931a98e52d96243
parent15971a7a6738abb18ed027f667b2cb15dc9c792d (diff)
downloadapk-tools-8e5f4910f8ae653f4ff30c0b3c23a4b659036f9b.tar.gz
apk-tools-8e5f4910f8ae653f4ff30c0b3c23a4b659036f9b.tar.bz2
apk-tools-8e5f4910f8ae653f4ff30c0b3c23a4b659036f9b.tar.xz
apk-tools-8e5f4910f8ae653f4ff30c0b3c23a4b659036f9b.zip
apk_defines: define stub stat64/fstatat64 symbols for macOS variants with only 64-bit ino_t
ref #10794
-rw-r--r--src/apk_defines.h5
-rw-r--r--src/io.c9
2 files changed, 5 insertions, 9 deletions
diff --git a/src/apk_defines.h b/src/apk_defines.h
index 3626495..f4b9c85 100644
--- a/src/apk_defines.h
+++ b/src/apk_defines.h
@@ -34,6 +34,11 @@
#define NULL 0L
#endif
+#if __DARWIN_ONLY_64_BIT_INO_T
+# define stat64 stat
+# define fstatat64 fstatat
+#endif
+
enum {
APKE_EOF = 1024,
APKE_DNS,
diff --git a/src/io.c b/src/io.c
index 5c871bd..498ba71 100644
--- a/src/io.c
+++ b/src/io.c
@@ -751,11 +751,7 @@ void apk_fileinfo_hash_xattr(struct apk_file_info *fi, uint8_t alg)
int apk_fileinfo_get(int atfd, const char *filename, unsigned int flags,
struct apk_file_info *fi, struct apk_atom_pool *atoms)
{
-#ifdef __linux__
struct stat64 st;
-#else
- struct stat st;
-#endif
unsigned int hash_alg = flags & 0xff;
unsigned int xattr_hash_alg = (flags >> 8) & 0xff;
int atflags = 0;
@@ -766,13 +762,8 @@ int apk_fileinfo_get(int atfd, const char *filename, unsigned int flags,
if (flags & APK_FI_NOFOLLOW)
atflags |= AT_SYMLINK_NOFOLLOW;
-#ifdef __linux__
if (fstatat64(atfd, filename, &st, atflags) != 0)
return -errno;
-#else
- if (fstatat(atfd, filename, &st, atflags) != 0)
- return -errno;
-#endif
*fi = (struct apk_file_info) {
.size = st.st_size,