heim_disk/os/macos/partitions.rs
1bitflags::bitflags! {
2 // These flags are declared at `bsd/sys/mount.h`
3 /// Partition mount flags.
4 pub struct Flags: libc::c_uint {
5 // User specifiable flags
6
7 /// Read only filesystem
8 const MNT_RDONLY = 0x0000_0001;
9 /// File system written synchronously
10 const MNT_SYNCHRONOUS = 0x0000_0002;
11 /// Can't exec from filesystem
12 const MNT_NOEXEC = 0x0000_0004;
13 /// Don't honor `setuid` bits on fs
14 const MNT_NOSUID = 0x0000_0008;
15 /// Don't interpret special files
16 const MNT_NODEV = 0x0000_0010;
17 /// Union with underlying filesystem
18 const MNT_UNION = 0x0000_0020;
19 /// File system written asynchronously
20 const MNT_ASYNC = 0x0000_0040;
21 /// File system supports content protection
22 const MNT_CPROTECT = 0x0000_0080;
23
24 // NFS export related mount flags
25
26 /// File system is exported
27 const MNT_EXPORTED = 0x0000_0100;
28
29 // MAC labeled / "quarantined" flag
30
31 /// File system is quarantined
32 const MNT_QUARANTINE = 0x0000_0400;
33
34 // Flags set by internal operations
35
36 /// Filesystem is stored locally
37 const MNT_LOCAL = 0x0000_1000;
38 /// Quotas are enabled on filesystem
39 const MNT_QUOTA = 0x0000_2000;
40 /// Identifies the root filesystem
41 const MNT_ROOTFS = 0x0000_4000;
42 /// FS supports `volfs` (deprecated flag in Mac OS X 10.5)
43 const MNT_DOVOLFS = 0x0000_8000;
44
45 /// File system is not appropriate path to user data
46 const MNT_DONTBROWSE = 0x0010_0000;
47 /// VFS will ignore ownership information on filesystem objects
48 const MNT_IGNORE_OWNERSHIP = 0x0020_0000;
49 /// Filesystem was mounted by automounter
50 const MNT_AUTOMOUNTED = 0x0040_0000;
51 /// Filesystem is journaled
52 const MNT_JOURNALED = 0x0080_0000;
53 /// Don't allow user extended attributes
54 const MNT_NOUSERXATTR = 0x0100_0000;
55 /// Filesystem should defer writes
56 const MNT_DEFWRITE = 0x0200_0000;
57 /// MAC support for individual labels
58 const MNT_MULTILABEL = 0x0400_0000;
59 /// Disable update of file access time
60 const MNT_NOATIME = 0x1000_0000;
61
62 // External filesystem command modifier flags
63
64 /// Not a real mount, just an update
65 const MNT_UPDATE = 0x0001_0000;
66 /// Don't block unmount if not responding
67 const MNT_NOBLOCK = 0x0002_0000;
68 /// Reload filesystem data
69 const MNT_RELOAD = 0x0004_0000;
70 /// Force unmount or readonly change
71 const MNT_FORCE = 0x0008_0000;
72
73 // TODO: It is declared at `mount.h`, but it is hard to find what does it means.
74 // Should we have it at all?
75
76 // `bitflags` at this point is not allowing to use other constants
77 // MNT_UPDATE | MNT_NOBLOCK | MNT_RELOAD | MNT_FORCE
78 // const MNT_CMDFLAGS = 0x0001_0000 | 0x0002_0000 | 0x0004_0000 | 0x0008_0000;
79 }
80}
81
82/// macOS-specific extension for [Partition] struct.
83///
84/// [Partition]: ../../struct.Partition.html
85pub trait PartitionExt {
86 /// Mount flags
87 fn flags(&self) -> Flags;
88}
89
90#[cfg(target_os = "macos")]
91impl PartitionExt for crate::Partition {
92 fn flags(&self) -> Flags {
93 Flags::from_bits_truncate(self.as_ref().raw_flags())
94 }
95}