This uses the compiler to try to detect if fallocate is available (should be on any Linux since 2.6.23). With the old check, fallocate is never found on modern systems, since the real header file where it is defined is somewhere at /usr/include/<ARCH>/bits/fcntl-linux.h.
Why is this useful? I noticed that wit is really slow (without showing progress) when copying images to an ntfs-3g-mounted partition. Since ntfs-3g doesn't implement fallocate, posix_fallocate falls back to a very slow "emulation" (manpage, source)
PS: It would probably make sense to check the return value of fallocate/posix_fallocate for at lease EOPNOTSUPP to show a warning that the target filesystem doesn't support preallocation.
PPS: Feel free to take this contribution under any license you like (consider it BSD-0/GPL2+ dual-licensed ;))
This uses the compiler to try to detect if fallocate is available (should be on any Linux since 2.6.23). With the old check, fallocate is never found on modern systems, since the real header file where it is defined is somewhere at
/usr/include/<ARCH>/bits/fcntl-linux.h
.Why is this useful? I noticed that
wit
is really slow (without showing progress) when copying images to anntfs-3g
-mounted partition. Sincentfs-3g
doesn't implementfallocate
,posix_fallocate
falls back to a very slow "emulation" (manpage, source)PS: It would probably make sense to check the return value of
fallocate
/posix_fallocate
for at leaseEOPNOTSUPP
to show a warning that the target filesystem doesn't support preallocation.PPS: Feel free to take this contribution under any license you like (consider it BSD-0/GPL2+ dual-licensed ;))