]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fallocate: drop syscall() fallback for fallocate()
authorThomas Weißschuh <thomas@t-8ch.de>
Sat, 1 Nov 2025 20:49:58 +0000 (21:49 +0100)
committerThomas Weißschuh <thomas@t-8ch.de>
Sat, 8 Nov 2025 14:08:27 +0000 (15:08 +0100)
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 <thomas@t-8ch.de>
configure.ac
meson.build
sys-utils/fallocate.c

index 297b9fb3fea1bde69c406caa7b43c224d3bee23a..fc66f21495205e396d29fd29188dcf6737e14de5 100644 (file)
@@ -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])
 
 
index 00c24c751ec0d2397d02ba2c7509c3a81b32b620..9d520615459cfced344a4d37eea7602739d1c8fa 100644 (file)
@@ -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,
index 686e4925e240341504d76c7fcde707f8ac459398..244c1dfa4daefc701e370c6de187b8473f5a7643 100644 (file)
 #include <limits.h>
 #include <string.h>
 
-#ifndef HAVE_FALLOCATE
-# include <sys/syscall.h>
-#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