heim_disk/os/unix/
usage.rs

1bitflags::bitflags! {
2    /// Various options that were employed when mounting this filesystem (see `statvfs(3)`).
3    ///
4    /// See [UsageExt::flags] method, which returns that structure.
5    pub struct Flags: libc::c_ulong {
6        /// Mandatory locking is permitted on the filesystem (see `fcntl(2)`).
7        ///
8        /// ## Compatibility
9        ///
10        /// Not available for macOS.
11        #[cfg(not(target_os = "macos"))]
12        const MANDLOCK = libc::ST_MANDLOCK;
13
14        /// Do not update access times; see `mount(2)`.
15        ///
16        /// ## Compatibility
17        ///
18        /// Not available for macOS.
19        #[cfg(not(target_os = "macos"))]
20        const NOATIME = libc::ST_NOATIME;
21
22        /// Disallow access to device special files on this filesystem.
23        ///
24        /// ## Compatibility
25        ///
26        /// Not available for macOS.
27        #[cfg(not(target_os = "macos"))]
28        const NODEV = libc::ST_NODEV;
29
30        /// Do not update directory access times; see `mount(2)`.
31        ///
32        /// ## Compatibility
33        ///
34        /// Not available for macOS.
35        #[cfg(not(target_os = "macos"))]
36        const NODIRATIME = libc::ST_NODIRATIME;
37
38        /// Execution of programs is disallowed on this filesystem.
39        ///
40        /// ## Compatibility
41        ///
42        /// Not available for macOS.
43        #[cfg(not(target_os = "macos"))]
44        const NOEXEC = libc::ST_NOEXEC;
45
46        /// The set-user-ID and set-group-ID bits are ignored by `exec(3)`
47        /// for executable files on this filesystem.
48        const NOSUID = libc::ST_NOSUID;
49
50        /// This filesystem is mounted read-only.
51        const RDONLY = libc::ST_RDONLY;
52
53        /// Update `atime` relative to `mtime`/`ctime`; see `mount(2)`.
54        ///
55        /// ## Compatibility
56        ///
57        /// Not available for macOS or any `musl` target environment.
58        #[cfg(not(any(target_os = "macos", target_env = "musl")))]
59        const RELATIME = libc::ST_RELATIME;
60
61        /// Writes are synced to the filesystem immediately
62        /// (see the description of `O_SYNC` in `open(2)`).
63        ///
64        /// ## Compatibility
65        ///
66        /// Not available for macOS.
67        #[cfg(not(target_os = "macos"))]
68        const SYNCHRONOUS = libc::ST_SYNCHRONOUS;
69    }
70}
71
72/// Unix-specific extensions for [Usage] struct.
73///
74/// [Usage]: ../../struct.Usage.html
75pub trait UsageExt {
76    /// Returns [Flags] for current filesystem;
77    fn flags(&self) -> Flags;
78}
79
80#[cfg(unix)]
81impl UsageExt for crate::Usage {
82    fn flags(&self) -> Flags {
83        self.as_ref().flags()
84    }
85}