https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=d5dcb484c705a214b30826c82b9fd8bf83772093
commit d5dcb484c705a214b30826c82b9fd8bf83772093 Author: Corinna Vinschen <[email protected]> AuthorDate: Sat Nov 25 18:07:10 2023 +0100 Commit: Corinna Vinschen <[email protected]> CommitDate: Sat Nov 25 18:07:23 2023 +0100 Cygwin: lseek: check for file sparseness, not for mount point sparseness The code introducing the lseek(2) code for the GNU extensions SEEK_DATA and SEEK_HOLE accidentally checks if the mount point has the "sparse" flag set and, if not, emulates SEEK_DATA/SEEK_HOLE per the Linux specs. However, the mount point "sparse" flag only determines whether files should be made sparse or not. Files may be sparse independently of that, obviously. Fix that by checking for the FILE_ATTRIBUTE_SPARSE_FILE attribute instead. Fixes: edfa581d3c5a ("Cygwin: lseek: implement SEEK_DATA and SEEK_HOLE for files") Signed-off-by: Corinna Vinschen <[email protected]> Diff: --- winsup/cygwin/fhandler/base.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winsup/cygwin/fhandler/base.cc b/winsup/cygwin/fhandler/base.cc index cdef01a2da67..a57ffcb86429 100644 --- a/winsup/cygwin/fhandler/base.cc +++ b/winsup/cygwin/fhandler/base.cc @@ -1140,7 +1140,7 @@ fhandler_base::lseek (off_t offset, int whence) set_errno (ENXIO); return -1; } - if (!pc.support_sparse ()) + if (!has_attribute (FILE_ATTRIBUTE_SPARSE_FILE)) { /* Default behaviour if sparse files are not supported: SEEK_DATA: seek to offset
