1 From 59f04ad8730034a205a1a792662d4b5dc2006b7c Mon Sep 17 00:00:00 2001
2 From: Alyssa Ross <hi@alyssa.is>
3 Date: Mon, 13 May 2024 09:53:23 +0200
4 Subject: [PATCH] Fix sync_file_range() with musl 1.2.4
6 musl 1.2.4 has removed the transitional LFS off64_t type.
7 sync_file_range is declared with off_t in musl, which is always 64
10 This assumes that the same is true of any other libc which doesn't
11 provide off64_t. If it's not, gcc will produce an error due to the
12 conflicting types of sync_file_range(), so it will be caught and can
16 libeatmydata/libeatmydata.c | 11 +++++++++--
17 2 files changed, 11 insertions(+), 2 deletions(-)
19 diff --git a/configure.ac b/configure.ac
20 index 4d101ba..f3c4a69 100644
23 @@ -37,6 +37,8 @@ AC_CHECK_HEADERS_ONCE(pthread.h)
24 AC_CHECK_SIZEOF(mode_t)
27 +AC_CHECK_TYPES([off64_t])
29 AC_CHECK_TYPE(pthread_barrier_t,,,[
32 diff --git a/libeatmydata/libeatmydata.c b/libeatmydata/libeatmydata.c
33 index 134afcd..0015f1f 100644
34 --- a/libeatmydata/libeatmydata.c
35 +++ b/libeatmydata/libeatmydata.c
37 #define CHECK_FILE "/tmp/eatmydata"
41 +typedef off64_t sync_file_range_off;
43 +typedef off_t sync_file_range_off;
46 typedef int (*libc_open_t)(const char*, int, ...);
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);
57 typedef int (*libc_syncfs_t)(int);
58 @@ -259,7 +265,8 @@ int LIBEATMYDATA_API msync(void *addr, size_t length, int flags)
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,
67 if (eatmydata_is_hungry()) {