Wiimm / wiimms-iso-tools

»Wiimms ISO Tools« is a set of command line tools to extract, modify and create Wii and GameCube ISO images and WBFS containers.
https://wit.wiimm.de
106 stars 13 forks source link

Slightly more robust fallocate detection #8

Open TobiX opened 3 years ago

TobiX commented 3 years ago

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 ;))