Re: SRFI 170 file-space -> filesystem-space ??
Lassi Kortela 15 Sep 2020 17:16 UTC
> I was writing some flaky tests to see if it's returning true results,
> but the more I think of my assumptions, the harder this gets. For
> example, is there any filesystem almost guaranteed to be quiescent
> between two calls of it? /tmp is both iffy and not guaranteed to be a
> separate file system, neither is /. But maybe adding 32 MiB to
> whatever is /tmp and checking to see if there's less free space is safe
> enough.
>
> Advice is solicited; I have checked the results by hand with df, Linux
> is fine, but either I'm too out of it, or OpenBSD is lying.
Good questions.
Calling stat() on two pathnames and checking whether the device numbers
are equal (st_dev), you can check whether those pathnames are on the
same file system.
Other concerns:
- Do the results reflect the Unix quota system or not?
- Unix tends to reserve n% of each file system's space for the root user
only. The "Avail" column in `df` output reflects the space available for
use by normal plebs I think; if you compute Size-Used you may get more
than that, because root can use more than that. Does statvfs() give the
space free for root or for plebs?