libeatmydata: patch out LFS64 usage (#324772)

This is a revised version of c7f51f003264 ("libeatmydata: patch out
LFS64 usage") (reverted in 7be23ec058c8 ("Revert "libeatmydata: patch
out LFS64 usage"")) that doesn't break 32-bit Glibc builds.

authored by Alyssa Ross and committed by GitHub daeb19c6 29d4a0f4

+75
+70
pkgs/development/libraries/libeatmydata/LFS64.patch
··· 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 5 + 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 8 + bits. 9 + 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 13 + be fixed. 14 + --- 15 + configure.ac | 2 ++ 16 + libeatmydata/libeatmydata.c | 11 +++++++++-- 17 + 2 files changed, 11 insertions(+), 2 deletions(-) 18 + 19 + diff --git a/configure.ac b/configure.ac 20 + index 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> 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 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 + -- 69 + 2.45.1 70 +
+5
pkgs/development/libraries/libeatmydata/default.nix
··· 17 17 sha256 = "sha256-0lrYDW51/KSr809whGwg9FYhzcLRfmoxipIgrK1zFCc="; 18 18 }; 19 19 20 + patches = [ 21 + # https://github.com/stewartsmith/libeatmydata/pull/36 22 + ./LFS64.patch 23 + ]; 24 + 20 25 postPatch = '' 21 26 patchShebangs . 22 27 '';