Eric Blake wrote:
> > I have done some experiments and find out that
> > the behavior of lseek with whence set to SEEK_DATA is different from the 
> > behavior of Linux's lseek.
> > 
> > If the supplied offset is in the middle of a data region, it returns the
> > start of the next data region.  There may be many data regions in a big
> > file even though it has no hole.
> > 
> > return value of lseek with whence set to SEEK_DATA:
> > 
> > |--(offset)--Data----|(return value)----Data----|
> > |--(offset)--Data----|----Hole----|(return value)----Data----|
> 
> Ouch. That's a nasty bug in MacOS, and gnulib should be taught to work 
> around broken lseek(SEEK_DATA)

Why would that be important? As far as I understand the SEEK_DATA facility
from the man page [1], the most immediate way to make reasonable use of it is
to call
   offset = lseek (fd, SEEK_DATA, offset);
and
   offset = lseek (fd, SEEK_HOLE, offset);
alternatingly. On Linux, you may start with SEEK_DATA or SEEK_HOLE; on
macOS, you would need to start with SEEK_HOLE because starting with
SEEK_DATA won't work. Is it a _that_ big problem?

Bruno

[1] http://man7.org/linux/man-pages/man2/lseek.2.html


Reply via email to