at master 70 lines 2.3 kB view raw
1From 59f04ad8730034a205a1a792662d4b5dc2006b7c Mon Sep 17 00:00:00 2001 2From: Alyssa Ross <hi@alyssa.is> 3Date: Mon, 13 May 2024 09:53:23 +0200 4Subject: [PATCH] Fix sync_file_range() with musl 1.2.4 5 6musl 1.2.4 has removed the transitional LFS off64_t type. 7sync_file_range is declared with off_t in musl, which is always 64 8bits. 9 10This assumes that the same is true of any other libc which doesn't 11provide off64_t. If it's not, gcc will produce an error due to the 12conflicting types of sync_file_range(), so it will be caught and can 13be fixed. 14--- 15 configure.ac | 2 ++ 16 libeatmydata/libeatmydata.c | 11 +++++++++-- 17 2 files changed, 11 insertions(+), 2 deletions(-) 18 19diff --git a/configure.ac b/configure.ac 20index 4d101ba..f3c4a69 100644 21--- a/configure.ac 22+++ b/configure.ac 23@@ -37,6 +37,8 @@ AC_CHECK_HEADERS_ONCE(pthread.h) 24 AC_CHECK_SIZEOF(mode_t) 25 AC_CHECK_SIZEOF(int) 26 27+AC_CHECK_TYPES([off64_t]) 28+ 29 AC_CHECK_TYPE(pthread_barrier_t,,,[ 30 #ifdef HAVE_PTHREAD_H 31 #include <pthread.h> 32diff --git a/libeatmydata/libeatmydata.c b/libeatmydata/libeatmydata.c 33index 134afcd..0015f1f 100644 34--- a/libeatmydata/libeatmydata.c 35+++ b/libeatmydata/libeatmydata.c 36@@ -35,6 +35,12 @@ 37 #define CHECK_FILE "/tmp/eatmydata" 38 */ 39 40+#ifdef HAVE_OFF64_T 41+typedef off64_t sync_file_range_off; 42+#else 43+typedef off_t sync_file_range_off; 44+#endif 45+ 46 typedef int (*libc_open_t)(const char*, int, ...); 47 #ifdef HAVE_OPEN64 48 typedef int (*libc_open64_t)(const char*, int, ...); 49@@ -44,7 +50,7 @@ typedef int (*libc_sync_t)(void); 50 typedef int (*libc_fdatasync_t)(int); 51 typedef int (*libc_msync_t)(void*, size_t, int); 52 #ifdef HAVE_SYNC_FILE_RANGE 53-typedef int (*libc_sync_file_range_t)(int, off64_t, off64_t, unsigned int); 54+typedef int (*libc_sync_file_range_t)(int, sync_file_range_off, sync_file_range_off, unsigned int); 55 #endif 56 #ifdef HAVE_SYNCFS 57 typedef int (*libc_syncfs_t)(int); 58@@ -259,7 +265,8 @@ int LIBEATMYDATA_API msync(void *addr, size_t length, int flags) 59 } 60 61 #ifdef HAVE_SYNC_FILE_RANGE 62-int LIBEATMYDATA_API sync_file_range(int fd, off64_t offset, off64_t nbytes, 63+int LIBEATMYDATA_API sync_file_range(int fd, sync_file_range_off offset, 64+ sync_file_range_off nbytes, 65 unsigned int flags) 66 { 67 if (eatmydata_is_hungry()) { 68-- 692.45.1 70