chore: cargo fmt

This commit is contained in:
guochao 2025-04-03 14:12:21 +00:00
parent 6cfdec1d3c
commit 4ea80a819b
5 changed files with 15 additions and 14 deletions

View File

@ -24,7 +24,9 @@ extern "C" fn interrupt_handler(_: i32) {
} }
#[derive(Debug, clap::Parser)] #[derive(Debug, clap::Parser)]
#[clap(about="fanotify demo", long_about=" #[clap(
about = "fanotify demo",
long_about = "
monitor filesystem changes demo monitor filesystem changes demo
to use as storage provider: 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_ACCESS_PERM setup permission notification
--mask-flags FAN_ON_DIR create events for directories itself --mask-flags FAN_ON_DIR create events for directories itself
--mask-flags FAN_EVENT_ON_CHILD create events for direct children --mask-flags FAN_EVENT_ON_CHILD create events for direct children
")] "
)]
struct Args { struct Args {
#[clap(required(true))] #[clap(required(true))]
path: Vec<String>, path: Vec<String>,
@ -233,9 +236,7 @@ fn main() -> Result<(), Error> {
// is a directory or filled with content // is a directory or filled with content
metadata.is_dir() || ready.contains(&path) metadata.is_dir() || ready.contains(&path)
} }
Err(error) => { Err(error) => error.kind() == std::io::ErrorKind::NotFound,
error.kind() == std::io::ErrorKind::NotFound
}
}; };
if allowed || whitelist.contains(&arg0) || storage_provider.contains(&arg0) { if allowed || whitelist.contains(&arg0) || storage_provider.contains(&arg0) {
info!("<<<<< {} allowed", fd.as_raw_fd()); info!("<<<<< {} allowed", fd.as_raw_fd());
@ -252,7 +253,6 @@ fn main() -> Result<(), Error> {
} else { } else {
bufferdfds.insert(path, vec![fd]); bufferdfds.insert(path, vec![fd]);
} }
} }
} }
MaskFlags::FAN_CLOSE_WRITE => { MaskFlags::FAN_CLOSE_WRITE => {

View File

@ -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)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) // (long)(meta) ->event_len <= (long)(len) // struct does not read over buffer boundary (not implemented)
while offset + EVENT_SIZE <= nread { 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( std::ptr::copy(
buffer.as_ptr().add(offset), buffer.as_ptr().add(offset),
uninited.as_mut_ptr().cast(), uninited.as_mut_ptr().cast(),

View File

@ -1,10 +1,10 @@
#[macro_use] #[macro_use]
mod macros; mod macros;
pub mod consts;
pub mod error; pub mod error;
pub mod fanotify; pub mod fanotify;
pub mod consts;
pub use bitflags; pub use bitflags;
pub use fanotify::{Fanotify, Error, Response, Response as FanotifyResponse, Event}; pub use fanotify::{Error, Event, Fanotify, Response, Response as FanotifyResponse};