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