chore: cargo fmt
This commit is contained in:
parent
6cfdec1d3c
commit
4ea80a819b
@ -24,7 +24,9 @@ extern "C" fn interrupt_handler(_: i32) {
|
||||
}
|
||||
|
||||
#[derive(Debug, clap::Parser)]
|
||||
#[clap(about="fanotify demo", long_about="
|
||||
#[clap(
|
||||
about = "fanotify demo",
|
||||
long_about = "
|
||||
monitor filesystem changes demo
|
||||
|
||||
to use as storage provider:
|
||||
@ -35,7 +37,8 @@ to use as storage provider:
|
||||
--mask-flags FAN_ACCESS_PERM setup permission notification
|
||||
--mask-flags FAN_ON_DIR create events for directories itself
|
||||
--mask-flags FAN_EVENT_ON_CHILD create events for direct children
|
||||
")]
|
||||
"
|
||||
)]
|
||||
struct Args {
|
||||
#[clap(required(true))]
|
||||
path: Vec<String>,
|
||||
@ -146,7 +149,7 @@ fn main() -> Result<(), Error> {
|
||||
|
||||
let whitelist = args.whitelist;
|
||||
let storage_provider = args.providers;
|
||||
|
||||
|
||||
let mut ready = HashSet::new();
|
||||
let mut bufferdfds: HashMap<std::path::PathBuf, Vec<OwnedFd>> = HashMap::new();
|
||||
let mut arg0map = HashMap::new();
|
||||
@ -233,9 +236,7 @@ fn main() -> Result<(), Error> {
|
||||
// is a directory or filled with content
|
||||
metadata.is_dir() || ready.contains(&path)
|
||||
}
|
||||
Err(error) => {
|
||||
error.kind() == std::io::ErrorKind::NotFound
|
||||
}
|
||||
Err(error) => error.kind() == std::io::ErrorKind::NotFound,
|
||||
};
|
||||
if allowed || whitelist.contains(&arg0) || storage_provider.contains(&arg0) {
|
||||
info!("<<<<< {} allowed", fd.as_raw_fd());
|
||||
@ -252,7 +253,6 @@ fn main() -> Result<(), Error> {
|
||||
} else {
|
||||
bufferdfds.insert(path, vec![fd]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
MaskFlags::FAN_CLOSE_WRITE => {
|
||||
|
@ -12,7 +12,7 @@ impl Errno {
|
||||
Self { raw_errno: errno }
|
||||
}
|
||||
pub fn errno() -> Self {
|
||||
Self::new(unsafe { *libc::__errno_location() } )
|
||||
Self::new(unsafe { *libc::__errno_location() })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,8 @@ impl Fanotify {
|
||||
// (long)(meta) ->event_len >= (long)FAN_FAN_EVENT_METADATA_LEN && // struct contains valid size (not implemented)
|
||||
// (long)(meta) ->event_len <= (long)(len) // struct does not read over buffer boundary (not implemented)
|
||||
while offset + EVENT_SIZE <= nread {
|
||||
let mut uninited: MaybeUninit<libc::fanotify_event_metadata> = MaybeUninit::uninit();
|
||||
let mut uninited: MaybeUninit<libc::fanotify_event_metadata> =
|
||||
MaybeUninit::uninit();
|
||||
std::ptr::copy(
|
||||
buffer.as_ptr().add(offset),
|
||||
uninited.as_mut_ptr().cast(),
|
||||
@ -108,7 +109,7 @@ impl Fanotify {
|
||||
// meta = FAN_EVENT_NEXT(meta, len) translate to:
|
||||
// len -= meta->event_len; // shrink rest length
|
||||
// , // comma operator, evaluate first express, but not using its result
|
||||
//
|
||||
//
|
||||
// meta = (struct fanotify_event_metadata*) ( // cast pointer back to metadata type
|
||||
// ((char*)(meta)) // discard metadata type to increase pointer by 1
|
||||
// + (meta) -> event_len // add event_len to move to next
|
||||
|
@ -1,10 +1,10 @@
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
|
||||
pub mod consts;
|
||||
pub mod error;
|
||||
pub mod fanotify;
|
||||
pub mod consts;
|
||||
|
||||
pub use bitflags;
|
||||
|
||||
pub use fanotify::{Fanotify, Error, Response, Response as FanotifyResponse, Event};
|
||||
pub use fanotify::{Error, Event, Fanotify, Response, Response as FanotifyResponse};
|
||||
|
@ -37,7 +37,7 @@ macro_rules! fa_bitflags {
|
||||
}
|
||||
};
|
||||
|
||||
// from nix: input: accept a list of pub struct
|
||||
// from nix: input: accept a list of pub struct
|
||||
(
|
||||
// first
|
||||
$(#[$outer:meta])*
|
||||
@ -72,4 +72,4 @@ macro_rules! fa_bitflags {
|
||||
|
||||
// modified part: empty block don't produce anything.
|
||||
() => {}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user