1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//! Linux file system monitoring library that uses
//! [fanotify](https://man7.org/linux/man-pages/man7/fanotify.7.html)
//! underneath.
//!
//! # Installation
//! Run the command in project root directory
//! ```bash
//! cargo add naughtyfy
//! ```
//! Or manually add it to `Cargo.toml`
//! ```toml
//! [dependencies]
//! naughtyfy = "*"
//! ```
//! # Example
//! ```rust
//! # use naughtyfy::flags::*;
//! # use naughtyfy::types::*;
//! # use naughtyfy::api::*;
//! 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}");
//! }
//! }
//! ```