posix_fallocate is not allowed to generate sparse files, due to the
following restriction: "If posix_fallocate() returns successfully,
subsequent writes to the specified file data shall not fail due to
the lack of free space on the file system storage media." See
http://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html
Therefore only ftruncate and lseek potentially generate sparse
files. On second thought, I don't quite understand what you mean by
"use posix_fallocate() as a means of identifying a file that must
not be sparse". Can you explain, please?
Since we know that an executable must NOT be sparse in order to make it
more efficient with the Windows loader, then gcc should use
posix_fallocate() to guarantee that the file is NOT sparse, even if it
happens to issue a sequence of lseek() that would default to making it
sparse without the fallocate.
In other words, I'm proposing that we delete nothing from cygwin1.dll,
and instead fix the problem apps (gcc, emacs unexec) that actually
create executables, so that the files they create are non-sparse because
we have proven that they should not be sparse for performance reasons.
Meanwhile, all non-executable files (such as virtual machine disk
images, which are typically much bigger than executables, and where
being sparse really does matter) do not have to jump through extra hoops
of using ftruncate() when plain lseek() would do to keep them sparse.