+diff --git a/syscall.c b/syscall.c
+--- a/syscall.c
++++ b/syscall.c
+@@ -29,6 +29,10 @@
+ #include <sys/attr.h>
+ #endif
+
++#if defined HAVE_SYS_FALLOCATE && !defined HAVE_FALLOCATE
++#include <sys/syscall.h>
++#endif
++
+ extern int dry_run;
+ extern int am_root;
+ extern int read_only;
+@@ -282,3 +286,21 @@ OFF_T do_lseek(int fd, OFF_T offset, int whence)
+ return lseek(fd, offset, whence);
+ #endif
+ }
++
++#ifdef SUPPORT_PREALLOCATION
++int do_fallocate(int fd, OFF_T offset, OFF_T length)
++{
++ RETURN_ERROR_IF(dry_run, 0);
++ RETURN_ERROR_IF_RO_OR_LO;
++ /* TODO: Use FALLOC_FL_KEEP_SIZE to avoid the need to truncate. */
++#if defined HAVE_FALLOCATE
++ return fallocate(fd, 0, offset, length);
++#elif defined HAVE_SYS_FALLOCATE
++ return syscall(SYS_fallocate, fd, 0, (loff_t) offset, (loff_t) length);
++#elif defined HAVE_EFFICIENT_POSIX_FALLOCATE
++ return posix_fallocate(fd, offset, length);
++#else
++#error coding error in SUPPORT_PREALLOCATION
++#endif
++}
++#endif
+diff --git a/t_stub.c b/t_stub.c
+--- a/t_stub.c
++++ b/t_stub.c