13 releases

0.2.1 Nov 29, 2023
0.2.0 Apr 20, 2023
0.1.1 Apr 2, 2023
0.1.0 Feb 22, 2023
0.0.5 Feb 28, 2023

#1028 in Filesystem

Download history 43/week @ 2024-02-10 4/week @ 2024-02-24 10/week @ 2024-03-09 2/week @ 2024-03-16 69/week @ 2024-03-30 15/week @ 2024-04-06

88 downloads per month

AGPL-3.0-only

67KB
698 lines

📁 Naughtyfy

A modern fanotify wrapper.

Open issue for any feature/bug.

Example

use naughtyfy::api::*;
use naughtyfy::flags::*;

fn main() {
    unsafe {
        // Use carefully in multi thread.
        FAN_EVENT_BUFFER_LEN = 230.into();
    }
    // Initialise fanotify
    let fd = &init(FAN_CLASS_NOTIF, 0).unwrap();

    // Mark file descriptor for events
    mark(fd, FAN_MARK_ADD | FAN_MARK_MOUNT, FAN_ACCESS, AT_FDCWD, "/").unwrap();

    // Try extracting events from the buffer and print it
    let mut iter = 1;
    loop {
        let res = read(fd).unwrap();
        println!("{res:#?}");
        res.iter().for_each(|e| close(e.fd).unwrap());
        iter += 1;
        if iter > 100 {
            break;
        }
    }
}

Docs

Goals

  • Safe
  • Less overhead
  • Documented
  • Desciptive errors
  • Only 1 dependency (libc)
  • and, Fast ofc.

TODO

  • Add more example
  • Higher level API maybe?

Thanks

Dependencies