macosx impl if possible, or document why impossible
Data point from my horribly out of date, pre-APFS OSX 10.12.6 system:
- Man lseek mentions
SEEK_DATA
andSEEK_HOLE
. - However they are missing from
/usr/include/sys/unistd.h
(where the other SEEK_* are defined) - And when the unix impl is enabled for
target_os = macosx
, tests fail withunresolved imports:
libc::SEEK_DATA,
libc::SEEK_HOLE`
From 0000415: add SEEK_HOLE, SEEK_DATA to lseek - Austin Group Defect Tracker
I've learned that MacOS currently has yet a different implementation of lseek(SEEK_DATA), which really ought to be repaired to comply with the text in this proposal rather than forcing applications to work around the subtle semantic differences. On MacOS, at least with the APFS file system, files are composed of multiple extents; if your current offset is in the middle of a data extent (rather than aligned to the beginning of one), then lseek(SEEK_DATA) incorrectly returns the offset of the NEXT data extent (even if that skips a hole) rather than the current offset.
See https://lists.gnu.org/archive/html/bug-gnulib/2018-09/msg00054.html [^] for a discussion of some of the problems (including data corruption) that result from MacOS's different implementation.
Based on this it seems likely that with APFS SEEK_DATA and SEEK_HOLE are defined (but may require special handling).
Next step: test on a newer OS release.
It may be necessary to build differently depending on the OSX version.