Crate naughtyfy

Crate naughtyfy 

Source
Expand description

Linux file system monitoring library that uses fanotify underneath.

§Installation

Run the command in project root directory

cargo add naughtyfy

Or manually add it to Cargo.toml

[dependencies]
naughtyfy = "*"

§Example

let fd = &init(FAN_CLOEXEC | FAN_CLASS_CONTENT ,
                        O_RDONLY | O_LARGEFILE);
match fd {
    Ok(fd) => {
        let m = mark(fd, FAN_MARK_ADD | FAN_MARK_MOUNT, FAN_ACCESS, AT_FDCWD, "./");
        let events = read(fd).unwrap();
        for event in events {
            println!("{:#?}",event);
            close(event.fd);
        }
    }
    Err(e) => {
        // This can fail for multiple reason, most common being privileges.
        eprintln!("Cannot get fd due to {e}");
    }
}

Modules§

api
Low level function mapping for fanotify
errors
Defines all the Error that can be generated by fanotify at runtime. All errors comes with proper detailed description.
flags
1-1 mapping of all flags that fanotify.h has
This also includes all necessary falgs used in fanotify
types
Contains all the necessary structs needed for fanotify to work