Paul Eggert wrote:
> On 07/31/2012 12:05 AM, Jim Meyering wrote:
>> Given the knowledge that we're using one of those non-compressing file
>> systems, the legacy heuristic will work.
>
> I originally coded it up that way, using the st_fstype member
> that Solaris has -- this is more convenient and more accurate
> than the dance with statvfs.  But I gave it up on the grounds
> that any system sane enough to have st_fstype already has
> a working SEEK_HOLE (or is so old that we don't care about it....).
>
> Maybe while we're asking for SEEK_HOLE, we can also ask for
> st_fstype?  The problem with the statvfs dance is that it opens
> up race conditions when some other process is doing mounts.

I did something similar in gnulib's fts.c when deciding
whether it needs to sort directory entries on inode number
in order to avoid an O(N^2) seek storm.  There, I used fstatfs
to get each device's statfs.f_type, so far without complaint.
Then, since we're using a file descriptor, there would be no race.

Reply via email to