From: Thomas Weißschuh Date: Sat, 1 Nov 2025 20:49:58 +0000 (+0100) Subject: fallocate: drop syscall() fallback for fallocate() X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=941265121258160db37ac4778f19b19baf7a5951;p=thirdparty%2Futil-linux.git fallocate: drop syscall() fallback for fallocate() The ABI of the fallocate() syscall is complicated and not properly handled by the open-coded fallback logic. As all recent libcs implement fallocate() properly, drop the open-coded systemcall fallback and depend on the libc implementation. Signed-off-by: Thomas Weißschuh --- diff --git a/configure.ac b/configure.ac index 297b9fb3f..fc66f2149 100644 --- a/configure.ac +++ b/configure.ac @@ -614,7 +614,6 @@ AC_CHECK_FUNCS([ \ explicit_bzero \ __fpending \ __fpurge \ - fallocate \ fpurge \ fnmatch \ fsconfig \ @@ -687,6 +686,7 @@ AC_CHECK_FUNCS([ \ ]) AC_FUNC_FSEEKO +AC_CHECK_FUNCS([fallocate], [have_fallocate=yes], [have_fallocate=no]) AC_CHECK_FUNCS([futimens], [have_futimens=yes]) AC_CHECK_FUNCS([getusershell], [have_getusershell=yes],[have_getusershell=no]) AC_CHECK_FUNCS([inotify_init1], [have_inotify_init1=yes]) @@ -1589,7 +1589,7 @@ AC_ARG_ENABLE([fallocate], ) UL_BUILD_INIT([fallocate]) UL_REQUIRES_LINUX([fallocate]) -UL_REQUIRES_SYSCALL_CHECK([fallocate], [UL_CHECK_SYSCALL([fallocate])]) +UL_REQUIRES_HAVE([fallocate], [fallocate], [fallocate functions]) AM_CONDITIONAL([BUILD_FALLOCATE], [test "x$build_fallocate" = xyes]) diff --git a/meson.build b/meson.build index 00c24c751..9d5206154 100644 --- a/meson.build +++ b/meson.build @@ -2041,7 +2041,10 @@ if opt and not is_disabler(exe) bashcompletions += ['mountpoint'] endif -opt = not get_option('build-fallocate').disabled() +opt = get_option('build-fallocate') \ + .require(LINUX) \ + .require(conf.get('HAVE_FALLOCATE').to_string() == '1') \ + .allowed() exe = executable( 'fallocate', fallocate_sources, diff --git a/sys-utils/fallocate.c b/sys-utils/fallocate.c index 686e4925e..244c1dfa4 100644 --- a/sys-utils/fallocate.c +++ b/sys-utils/fallocate.c @@ -33,10 +33,6 @@ #include #include -#ifndef HAVE_FALLOCATE -# include -#endif - #if defined(HAVE_LINUX_FALLOC_H) && \ (!defined(FALLOC_FL_KEEP_SIZE) || !defined(FALLOC_FL_PUNCH_HOLE) || \ !defined(FALLOC_FL_COLLAPSE_RANGE) || !defined(FALLOC_FL_ZERO_RANGE) || \ @@ -129,11 +125,8 @@ static void xfallocate(int fd, int mode, off_t offset, off_t length) { int error; -#ifdef HAVE_FALLOCATE error = fallocate(fd, mode, offset, length); -#else - error = syscall(SYS_fallocate, fd, mode, offset, length); -#endif + /* * EOPNOTSUPP: The FALLOC_FL_KEEP_SIZE is unsupported * ENOSYS: The filesystem does not support sys_fallocate