go-fuse icon indicating copy to clipboard operation
go-fuse copied to clipboard

Lseek default implementation should return the end of the file for SEEK_HOLE

Open pierreis opened this issue 2 years ago • 0 comments

Currently, the default Lseeker implementation for SEEK_HOLE returns the current position + offset. This can cause issues, such as causing grep to consider a text file as binary.

From the man page: For the purposes of these operations, a hole is a sequence of zeros that (normally) has not been allocated in the underlying file storage. However, a filesystem is not obliged to report holes, so these operations are not a guaranteed mechanism for mapping the storage space actually allocated to a file. (Furthermore, a sequence of zeros that actually has been written to the underlying storage may not be reported as a hole.) In the simplest implementation, a filesystem can support the operations by making SEEK_HOLE always return the offset of the end of the file, and making SEEK_DATA always return offset (i.e., even if the location referred to by offset is a hole, it can be considered to consist of data that is a sequence of zeros).

Can the default implementation of Lseek be updated to report the end of the file on SEEK_HOLE?

pierreis avatar Feb 17 '22 10:02 pierreis