Skip to main content

endpoint_sec/event/
event_remount.rs

1//! [`EventRemount`]
2
3use endpoint_sec_sys::{es_event_remount_t, statfs};
4#[cfg(feature = "macos_15_0_0")]
5use endpoint_sec_sys::es_mount_disposition_t;
6
7/// Remount a file system event.
8#[doc(alias = "es_event_remount_t")]
9#[cfg_attr(not(feature = "macos_15_0_0"), allow(dead_code))]
10pub struct EventRemount<'a> {
11    /// Raw event
12    pub(crate) raw: &'a es_event_remount_t,
13    /// The version of the message.
14    pub(crate) version: u32,
15}
16
17impl<'a> EventRemount<'a> {
18    /// The file system stats for the file system being mounted.
19    #[inline(always)]
20    pub fn statfs(&self) -> &'a statfs {
21        // Safety: 'a tied to self, object obtained through ES
22        unsafe { self.raw.statfs() }
23    }
24
25    /// The provided remount flags.
26    ///
27    /// Field available only if message version >= 8.
28    #[inline(always)]
29    #[cfg(feature = "macos_15_0_0")]
30    pub fn remount_flags(&self) -> Option<u64> {
31        (self.version >= 8).then_some(self.raw.remount_flags)
32    }
33
34    /// The device disposition of the f_mntfromname.
35    ///
36    /// Field available only if message version >= 8.
37    #[inline(always)]
38    #[cfg(feature = "macos_15_0_0")]
39    pub fn disposition(&self) -> Option<es_mount_disposition_t> {
40        (self.version >= 8).then_some(self.raw.disposition)
41    }
42}
43
44// Safety: safe to send across threads: does not contain any interior mutability nor depend on current thread state
45unsafe impl Send for EventRemount<'_> {}
46// Safety: safe to share across threads: does not contain any interior mutability nor depend on current thread state
47unsafe impl Sync for EventRemount<'_> {}
48
49impl_debug_eq_hash_with_functions!(EventRemount<'a>;
50    statfs,
51    #[cfg(feature = "macos_15_0_0")] remount_flags,
52    #[cfg(feature = "macos_15_0_0")] disposition
53);