On 09/07/2018 01:04 PM, Yan-Jie Wang 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----|
** Patch added: "macOS-lseek.patch"
https://bugs.launchpad.net/qemu/+bug/1776920/+attachment/5186138/+files/macOS-lseek.patch
While a developer can chase a URL, our CI tools can't. Can you please
also send that patch directly to qemu-devel@nongnu.org, so that it gets
the same level of review as other patches?
But I am very reluctant to take your patch. MacOS is flat-out buggy and
in violation of the specification of lseek(SEEK_DATA), so making all
applications work around their bug is not going to scale as well as
having them fix their bug in the first place.
Here's the proposed POSIX specification for what lseek(SEEK_DATA) is
supposed to do:
http://austingroupbugs.net/view.php?id=415#c862
That text has been present for 7 years now - so anyone implementing
SEEK_DATA should really be paying attention to interoperability with
that text.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org