POSIX statvfs required behavior
The POSIX statvfs () description says:
The following flags may be returned in the f_flag member:
- ST_RDONLY is a read-only file system.
- ST_NOSUID - Setuid / setgid bit ignored by exec.
It is not known whether all members of the statvfs structure have meaningful values ββacross all file systems.
See also sys / statvfs.h description:
The header
<sys/statvfs.h>
must define the following symbolic constants for the f_flag member:
- ST_RDONLY is a read-only file system.
- ST_NOSUID - Does not support the semantics of the ST_ISUID and ST_ISGID file mode bits.
How to interpret this correctly? I mean:
- does this allow a POSIX-compatible system to return nonsense, where
ST_RDONLY
does it make sense? - If a statvfs member makes sense for a particular filesystem, is the OS allowed to return nonsense (I understand that some fields might not make any sense for synthetic filesystems like / proc)?
Is there any OS known to return the wrong ST_RDONLY
or ST_NOSUID
for the filesystems used to store data / executables while claiming POSIX compatibility is implemented in it statvfs()
?
source to share
The POSIX specification requires very little statvfs()
other than its existence.
In particular, this requires statvfs()
filling the specified buffer with struct statvfs *
"file system information", but does not guarantee the value of this information. In other words, it can be complete garbage and is actually found on many systems (including HFS + on OS X).
This one includes a member f_flag
struct statvfs
that can be masqueraded as ST_RDONLY
and / or ST_NOSUID
, but many of them do not apply to all filesystems (even if needed).
If you need to reliably retrieve filesystem information across multiple platforms, you can (ironically) resort to a non-standard function like statfs()
. However, Linux statvfs()
behaves quite well on most non-synthetic filesystems.
source to share