On 04/25/2011 09:02 AM, Nick Bowler wrote: Hi Nick, > * File A (sparse file created by lseek/write beyond end-of-file): > > data | hole 0 | data || hole 1 (virtual) > > * File B (sparse file created by truncate beyond end-of-file): > > data | hole 0 || hole 1 (virtual) > > Excluding the error description, the term "the last hole" is used in > two places in your proposal: > > * (for SEEK_HOLE): if offset falls within "the last hole", then the > file offset may be set to the file size instead. > > * (for SEEK_DATA): it shall be an error ... if offset falls within the > last hole. > > I imagine that both of these conditions are intended to address the > case where the offset falls within hole 0 in File B, that is, when > there is no non-hole data beyond the specified offset but the offset > is nevertheless less than the file size. Correct. > However, this looks (to me) > like the penultimate hole in the file, not the last hole. Furthermore, > these conditions are presumably *not* intended to apply to the > penultimate hole in File A, which has data after it. Good catch. > > I think my confusion can be avoided by talking about the last non-hole > data byte in the file (which is unambigious), instead of by talking > about the last hole. For instance, the SEEK_HOLE/SEEK_DATA descriptions > could be written as follows: > > If whence is SEEK_HOLE, the file offset shall be set to the smallest > location of a byte within a hole and not less than offset, except that > if offset falls beyond the last byte not within a hole, then the file > offset may be set to the file size instead. It shall be an error if > offset is greater or equal to the size of the file. > > If whence is SEEK_DATA, the file offset shall be set to the smallest > location of a byte not within a hole and not less than offset. It shall > be an error if no such byte exists. > > plus a corresponding update to the ENXIO description: > > ... or the whence argument is SEEK_DATA and the offset falls beyond > the last byte not within a hole. I've added your improved wording as a comment at http://austingroupbugs.net/view.php?id=415 -- Eric Blake eblake@xxxxxxxxxx +1-801-349-2682 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature