Pavel Raiskup <prais...@redhat.com> wrote: > Hello all, > > I am trying to prepare patch which would reuse lseek's > SEEK_HOLE/SEEK_DATA, the [v1] is attached. Some info: > > Note that after discussion [1] I still think that existing ST_IS_SPARSE > macro is better for file-sparseness detection than using SEEK_HOLE (not > worth having additional syscalls open~>seek~>close).
Your code is not compatible to the SEEK_HOLE interface. A file is sparse in case that pathconf()/fpathconf(f, _PC_MIN_HOLE_SIZE) return a positive number and lseek(f, (off_t)0, SEEK_HOLE) returns a number < stat.st_size. see "man pathconf": 11. If a filesystem supports the reporting of holes (see lseek(2), pathconf() and fpathconf() return a positive number that represents the minimum hole size returned in bytes. The offsets of holes returned will be aligned to this same value. A spe- cial value of 1 is returned if the filesystem does not specify the minimum hole size but still reports holes. In other cases, the file stil may be sparse, but the filesystem does not support SEEK_HOLE. I e.g. doubt that Linux correctly implements SEEK_HOLE for NFS. Jörg -- EMail:jo...@schily.isdn.cs.tu-berlin.de (home) Jörg Schilling D-13353 Berlin j...@cs.tu-berlin.de (uni) joerg.schill...@fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/ URL: http://cdrecord.berlios.de/private/ ftp://ftp.berlios.de/pub/schily