mirror of git://git.musl-libc.org/musl
statvfs: allocate spare for f_type
This is the only missing part in struct statvfs. The LSB calls
[f]statfs() deprecated, and its weird types are definitely
off-putting. However, its use is required to get f_type.
Instead, allocate one of the six spares to f_type, copied directly
from struct statfs. This then becomes a small extension to the
standard interface on Linux, instead of two different interfaces, one
of which is quite odd due to being an ABI type, and there no longer is
any reason to use statfs().
The underlying kernel type is a mess, but all architectures agree on u32
(or more) for the ABI, and all filesystem magicks are 32-bit integers.
Since commit 6567db65f4
(prior to
1.0.0), the spare slots have been zero-filled, so on all versions that
may be reasonably be encountered in the wild, applications can rely on
a nonzero f_type as indication that the new field has been filled in.
This commit is contained in:
parent
39e43f0881
commit
7291c6c66a
|
@ -23,7 +23,8 @@ struct statvfs {
|
|||
unsigned long f_fsid;
|
||||
#endif
|
||||
unsigned long f_flag, f_namemax;
|
||||
int __reserved[6];
|
||||
unsigned int f_type;
|
||||
int __reserved[5];
|
||||
};
|
||||
|
||||
int statvfs (const char *__restrict, struct statvfs *__restrict);
|
||||
|
|
|
@ -39,6 +39,7 @@ static void fixup(struct statvfs *out, const struct statfs *in)
|
|||
out->f_fsid = in->f_fsid.__val[0];
|
||||
out->f_flag = in->f_flags;
|
||||
out->f_namemax = in->f_namelen;
|
||||
out->f_type = in->f_type;
|
||||
}
|
||||
|
||||
int statvfs(const char *restrict path, struct statvfs *restrict buf)
|
||||
|
|
Loading…
Reference in New Issue