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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// This file is part of file-descriptors. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/file-descriptors/master/COPYRIGHT. No part of file-descriptors, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
// Copyright © 2018-2019 The developers of file-descriptors. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/file-descriptors/master/COPYRIGHT.
extern "C"
/// Create an event when a file or directory is accessed (read).
pub const FAN_ACCESS: u64 = 0x01;
/// Create an event when a file is modified (write).
pub const FAN_MODIFY: u64 = 0x02;
/// Create an event when a writable file is closed.
pub const FAN_CLOSE_WRITE: u64 = 0x08;
/// Create an event when a read-only file or directory is closed.
pub const FAN_CLOSE_NOWRITE: u64 = 0x10;
/// Create an event when a file or directory is opened.
pub const FAN_OPEN: u64 = 0x20;
/// Create an event when an overflow of the event queue occurs.
///
/// The size of the event queue is limited to 16384 entries if `FAN_UNLIMITED_QUEUE` is not set in `fanotify_init()`.
pub const FAN_Q_OVERFLOW: u64 = 0x4000;
/// Create an event when a permission to open a file or directory is requested.
///
/// A fanotify file descriptor created with `FAN_CLASS_PRE_CONTENT` or `FAN_CLASS_CONTENT` is required.
pub const FAN_OPEN_PERM: u64 = 0x10000;
/// Create an event when a permission to read a file or directory is requested.
///
/// A fanotify file descriptor created with `FAN_CLASS_PRE_CONTENT` or `FAN_CLASS_CONTENT` is required.
pub const FAN_ACCESS_PERM: u64 = 0x20000;
/// Create events for directories.
///
/// For example, when `opendir()`, `readdir()` or `closedir()` are called.
///
/// Without this flag, only events for files are created.
pub const FAN_ONDIR: u64 = 0x40000000;
/// Events for the immediate children of marked directories shall be created.
///
/// The flag has no effect when marking file system mounts.
/// Note that events are not generated for children of the subdirectories of marked directories.
/// To monitor complete directory trees it is necessary to mark the relevant mount.
pub const FAN_EVENT_ON_CHILD: u64 = 0x08000000;
/// A file is closed.
///
/// This is the combination of `FAN_CLOSE_WRITE` and `FAN_CLOSE_NOWRITE`.
pub const FAN_CLOSE: u64 = FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE;
/// This is a combination of `FAN_ACCESS`, `FAN_MODIFY`, `FAN_CLOSE` and `FAN_OPEN`.
pub const FAN_ALL_EVENTS: u64 = FAN_ACCESS | FAN_MODIFY | FAN_CLOSE | FAN_OPEN;
/// This is a combination of `FAN_OPEN_PERM` and `FAN_ACCESS_PERM`.
pub const FAN_ALL_PERM_EVENTS: u64 = FAN_OPEN_PERM | FAN_ACCESS_PERM;
/// This is a combination of `FAN_ALL_EVENTS`, `FAN_ALL_PERM_EVENTS` and `FAN_Q_OVERFLOW`.
pub const FAN_ALL_OUTGOING_EVENTS: u64 = FAN_ALL_EVENTS | FAN_ALL_PERM_EVENTS | FAN_Q_OVERFLOW;
/// The events in `mask` will be added to the mark mask (or to the ignore mask).
///
/// `mask` must be nonempty or the error `EINVAL` will occur.
pub const FAN_MARK_ADD: c_uint = 0x01;
/// The events in argument `mask` will be removed from the mark mask (or from the ignore mask).
///
/// `mask` must be nonempty or the error `EINVAL` will occur.
pub const FAN_MARK_REMOVE: c_uint = 0x02;
/// Remove either all mount or all non-mount marks from the fanotify group.
///
/// If flags contains `FAN_MARK_MOUNT`, all marks for mounts are removed from the group.
/// Otherwise, all marks for directories and files are removed.
/// No flag other than `FAN_MARK_MOUNT` can be used in conjunction with `FAN_MARK_FLUSH`.
///
/// `mask is ignored`.
pub const FAN_MARK_FLUSH: c_uint = 0x80;
/// If `pathname` is a symbolic link, mark the link itself, rather than the file to which it refers.
///
/// (By default, `fanotify_mark()` dereferences pathname if it is a symbolic link).
pub const FAN_MARK_DONT_FOLLOW: c_uint = 0x04;
/// If the filesystem object to be marked is not a directory, the error `ENOTDIR` shall be raised.
pub const FAN_MARK_ONLYDIR: c_uint = 0x08;
/// Mark the mount point specified by pathname.
///
/// If `pathname` is not itself a mount point, the mount point containing `pathname` will be marked.
/// All directories, subdirectories, and the contained files of the mount point will be monitored.
pub const FAN_MARK_MOUNT: c_uint = 0x10;
/// The events in mask shall be added to or removed from the ignore mask.
pub const FAN_MARK_IGNORED_MASK: c_uint = 0x20;
/// The ignore mask shall survive modify events.
///
/// If this flag is not set, the ignore mask is cleared when a modify event occurs for the ignored file or directory.
pub const FAN_MARK_IGNORED_SURV_MODIFY: c_uint = 0x40;
/// This is a combination of `FAN_MARK_ADD`, `FAN_MARK_REMOVE`, `FAN_MARK_DONT_FOLLOW`, `FAN_MARK_ONLYDIR`, `FAN_MARK_MOUNT`, `FAN_MARK_IGNORED_MASK`, `FAN_MARK_IGNORED_SURV_MODIFY` and `FAN_MARK_FLUSH`.
pub const FAN_ALL_MARK_FLAGS: c_uint = FAN_MARK_ADD | FAN_MARK_REMOVE | FAN_MARK_DONT_FOLLOW | FAN_MARK_ONLYDIR | FAN_MARK_MOUNT | FAN_MARK_IGNORED_MASK | FAN_MARK_IGNORED_SURV_MODIFY | FAN_MARK_FLUSH;