Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fanotify API wrappers #2194

Merged
merged 11 commits into from
Nov 23, 2023
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ aio = ["pin-utils"]
dir = ["fs"]
env = []
event = []
fanotify = []
feature = []
fs = []
hostname = []
Expand Down
1 change: 1 addition & 0 deletions changelog/2194.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added new fanotify API: wrappers for `fanotify_init` and `fanotify_mark`
11 changes: 8 additions & 3 deletions src/fcntl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,14 @@ libc_bitflags! {
}
}

#[cfg(any(feature = "fs", feature = "term"))]
#[cfg(any(
feature = "fs",
feature = "term",
all(feature = "fanotify", target_os = "linux")
))]
libc_bitflags!(
/// Configuration options for opened files.
#[cfg_attr(docsrs, doc(cfg(any(feature = "fs", feature = "term"))))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "fs", feature = "term", all(feature = "fanotify", target_os = "linux")))))]
pub struct OFlag: c_int {
/// Mask for the access mode of the file.
O_ACCMODE;
Expand Down Expand Up @@ -194,7 +198,8 @@ libc_bitflags!(
/// Computes the raw fd consumed by a function of the form `*at`.
#[cfg(any(
all(feature = "fs", not(target_os = "redox")),
all(feature = "process", any(target_os = "android", target_os = "linux"))
all(feature = "process", any(target_os = "android", target_os = "linux")),
all(feature = "fanotify", target_os = "linux")
))]
pub(crate) fn at_rawfd(fd: Option<RawFd>) -> raw::c_int {
fd.unwrap_or(libc::AT_FDCWD)
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//! * `dir` - Stuff relating to directory iteration
//! * `env` - Manipulate environment variables
//! * `event` - Event-driven APIs, like `kqueue` and `epoll`
//! * `fanotify` - Linux's `fanotify` filesystem events monitoring API
//! * `feature` - Query characteristics of the OS at runtime
//! * `fs` - File system functionality
//! * `hostname` - Get and set the system's hostname
Expand Down Expand Up @@ -53,6 +54,7 @@
feature = "dir",
feature = "env",
feature = "event",
feature = "fanotify",
feature = "feature",
feature = "fs",
feature = "hostname",
Expand Down
Loading