fanotify_mark in naughtyfy::api - Rust
Description: Adds, removes, or modifies an fanotify mark on a filesystem object. The caller must have read permission on the filesystem object that is to be marked.
Keywords: rust, rustlang, rust-lang, fanotify_mark

# Function naughtyfy::api::fanotify_mark

source ·

    pub fn fanotify_mark<P: ?Sized + Path>(
        fanotify_fd: i32,
        flags: u32,
        mask: u64,
        dirfd: i32,
        path: &P
    ) -> Result<(), Error>

Expand description

Adds, removes, or modifies an fanotify mark on a filesystem object. The caller must have read permission on the filesystem object that is to be marked.

## Arguments

- `fanotify_fd` - File descriptor returned by `fanotify_init()`.

- `flags` - Bit mask describing the modification to perform.
  It must include exactly one of the following values:

  - `FAN_MARK_ADD`
  - `FAN_MARK_REMOVE`
  - `FAN_MARK_FLUSH`

  In addition, zero or more of the following values may be ORed into flags:

  - `FAN_MARK_DONT_FOLLOW`
  - `FAN_MARK_ONLYDIR`
  - `FAN_MARK_MOUNT`
  - `FAN_MARK_FILESYSTEM`
  - `FAN_MARK_IGNORED_MASK`
  - `FAN_MARK_IGNORED_SURV_MODIFY`

- `mask` - Which events shall be listened for (or which shall be ignored).
  It is a bit mask composed of the following values:

  - `FAN_ACCESS`
  - `FAN_MODIFY`
  - `FAN_CLOSE_WRITE`
  - `FAN_CLOSE_NOWRITE`
  - `FAN_OPEN`
  - `FAN_OPEN_EXEC`
  - `FAN_ATTRIB`
  - `FAN_CREATE`
  - `FAN_DELETE`
  - `FAN_DELETE_SELF`
  - `FAN_MOVED_FROM`
  - `FAN_MOVED_TO`
  - `FAN_MOVE_SELF`
  - `FAN_OPEN_PERM`
  - `FAN_OPEN_EXEC_PERM`
  - `FAN_ACCESS_PERM`
  - `FAN_ONDIR`
  - `FAN_EVENT_ON_CHILD`
  - `FAN_CLOSE`
  - `FAN_MOVE`

- `dirfd` - Defines the filesystem object to be marked.

- `path` - Filesystem path of file or diretory.

The filesystem object to be marked is determined by the file descriptor dirfd and the pathname specified in path:

- If pathname is `NULL`, dirfd defines the filesystem object to be marked.
- If pathname is `NULL`, and dirfd takes the special value `AT_FDCWD`, the current working directory is to be marked.
- If pathname is absolute, it defines the filesystem object to be marked, and dirfd is ignored.
- If pathname is relative, and dirfd does not have the value `AT_FDCWD`, then the filesystem object to be marked is determined by interpreting pathname relative the directory referred to by dirfd.
- If pathname is relative, and dirfd has the value `AT_FDCWD`, then the filesystem object to be marked is determined by interpreting pathname relative to the current working directory.

## Example

This example will panic due to absence of `CAP_SYS_ADMIN` capabilitity

    let fd = fanotify_init(FAN_CLASS_NOTIF, 0).unwrap();
    fanotify_mark(fd, FAN_MARK_ADD | FAN_MARK_MOUNT, FAN_ACCESS, libc::AT_FDCWD, "./");