1//! POSIX-style filesystem functions which operate on bare paths.
2
3#[cfg(not(any(
4 solarish,
5 target_os = "haiku",
6 target_os = "netbsd",
7 target_os = "redox",
8 target_os = "wasi",
9)))]
10use crate::fs::StatFs;
11#[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "wasi")))]
12use {
13 crate::fs::StatVfs,
14 crate::{backend, io, path},
15};
16
17/// `statfs`—Queries filesystem metadata.
18///
19/// Compared to [`statvfs`], this function often provides more information,
20/// though it's less portable.
21///
22/// # References
23/// - [Linux]
24///
25/// [Linux]: https://man7.org/linux/man-pages/man2/statfs.2.html
26#[cfg(not(any(
27 solarish,
28 target_os = "haiku",
29 target_os = "netbsd",
30 target_os = "redox",
31 target_os = "wasi",
32)))]
33#[inline]
34pub fn statfs<P: path::Arg>(path: P) -> io::Result<StatFs> {
35 path.into_with_c_str(backend::fs::syscalls::statfs)
36}
37
38/// `statvfs`—Queries filesystem metadata, POSIX version.
39///
40/// Compared to [`statfs`], this function often provides less information,
41/// but it is more portable. But even so, filesystems are very diverse and not
42/// all the fields are meaningful for every filesystem. And `f_fsid` doesn't
43/// seem to have a clear meaning anywhere.
44///
45/// # References
46/// - [POSIX]
47/// - [Linux]
48///
49/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/statvfs.html
50/// [Linux]: https://man7.org/linux/man-pages/man2/statvfs.2.html
51#[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "wasi")))]
52#[inline]
53pub fn statvfs<P: path::Arg>(path: P) -> io::Result<StatVfs> {
54 path.into_with_c_str(backend::fs::syscalls::statvfs)
55}
56