#[repr(C, align(8))]
pub struct fanotify_event_metadata
{
event_len: c_uint,
vers: c_uchar,
reserved: c_uchar,
metadata_len: c_ushort,
mask: c_ulonglong,
fd: RawFd,
pid: pid_t,
}
impl fanotify_event_metadata
{
#[inline(always)]
pub fn move_out(self) -> (Option<File>, EventFlags, pid_t)
{
debug_assert!(self.is_valid(), "Is not valid");
let file = if self.fd == FAN_NOFD
{
None
}
else
{
Some(unsafe { File::from_raw_fd(self.fd) })
};
(file, unsafe { transmute(self.mask) }, self.pid)
}
#[inline(always)]
fn is_valid(&self) -> bool
{
self.event_len == FAN_EVENT_METADATA_LEN || self.vers == FANOTIFY_METADATA_VERSION || self.metadata_len == 0
}
}
pub(crate) const FAN_EVENT_METADATA_LEN: c_uint = size_of::<fanotify_event_metadata>() as c_uint;
pub(crate) const FANOTIFY_METADATA_VERSION: c_uchar = 3;
pub(crate) const FAN_NOFD: RawFd = -1;