]>
Commit | Line | Data |
---|---|---|
1 | .\" Copyright (C) 2013, Heinrich Schuchardt <xypron.glpk@gmx.de> | |
2 | .\" | |
3 | .\" %%%LICENSE_START(VERBATIM) | |
4 | .\" Permission is granted to make and distribute verbatim copies of this | |
5 | .\" manual provided the copyright notice and this permission notice are | |
6 | .\" preserved on all copies. | |
7 | .\" | |
8 | .\" Permission is granted to copy and distribute modified versions of | |
9 | .\" this manual under the conditions for verbatim copying, provided that | |
10 | .\" the entire resulting derived work is distributed under the terms of | |
11 | .\" a permission notice identical to this one. | |
12 | .\" | |
13 | .\" Since the Linux kernel and libraries are constantly changing, this | |
14 | .\" manual page may be incorrect or out-of-date. The author(s) assume. | |
15 | .\" no responsibility for errors or omissions, or for damages resulting. | |
16 | .\" from the use of the information contained herein. The author(s) may. | |
17 | .\" not have taken the same level of care in the production of this. | |
18 | .\" manual, which is licensed free of charge, as they might when working. | |
19 | .\" professionally. | |
20 | .\" | |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by | |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
23 | .\" %%%LICENSE_END | |
24 | .TH FANOTIFY_MARK 2 2016-10-08 "Linux" "Linux Programmer's Manual" | |
25 | .SH NAME | |
26 | fanotify_mark \- add, remove, or modify an fanotify mark on a filesystem | |
27 | object | |
28 | .SH SYNOPSIS | |
29 | .nf | |
30 | .B #include <sys/fanotify.h> | |
31 | .sp | |
32 | .BI "int fanotify_mark(int " fanotify_fd ", unsigned int " flags , | |
33 | .BI " uint64_t " mask ", int " dirfd \ | |
34 | ", const char *" pathname ); | |
35 | .fi | |
36 | .SH DESCRIPTION | |
37 | For an overview of the fanotify API, see | |
38 | .BR fanotify (7). | |
39 | .PP | |
40 | .BR fanotify_mark () | |
41 | adds, removes, or modifies an fanotify mark on a filesystem object. | |
42 | The caller must have read permission on the filesystem object that | |
43 | is to be marked. | |
44 | .PP | |
45 | The | |
46 | .I fanotify_fd | |
47 | argument is a file descriptor returned by | |
48 | .BR fanotify_init (2). | |
49 | .PP | |
50 | .I flags | |
51 | is a bit mask describing the modification to perform. | |
52 | It must include exactly one of the following values: | |
53 | .TP | |
54 | .B FAN_MARK_ADD | |
55 | The events in | |
56 | .I mask | |
57 | will be added to the mark mask (or to the ignore mask). | |
58 | .I mask | |
59 | must be nonempty or the error | |
60 | .B EINVAL | |
61 | will occur. | |
62 | .TP | |
63 | .B FAN_MARK_REMOVE | |
64 | The events in argument | |
65 | .I mask | |
66 | will be removed from the mark mask (or from the ignore mask). | |
67 | .I mask | |
68 | must be nonempty or the error | |
69 | .B EINVAL | |
70 | will occur. | |
71 | .TP | |
72 | .B FAN_MARK_FLUSH | |
73 | Remove either all mount or all non-mount marks from the fanotify group. | |
74 | If | |
75 | .I flags | |
76 | contains | |
77 | .BR FAN_MARK_MOUNT , | |
78 | all marks for mounts are removed from the group. | |
79 | Otherwise, all marks for directories and files are removed. | |
80 | No flag other than | |
81 | .B FAN_MARK_MOUNT | |
82 | can be used in conjunction with | |
83 | .BR FAN_MARK_FLUSH . | |
84 | .I mask | |
85 | is ignored. | |
86 | .PP | |
87 | If none of the values above is specified, or more than one is specified, | |
88 | the call fails with the error | |
89 | .BR EINVAL . | |
90 | .PP | |
91 | In addition, | |
92 | zero or more of the following values may be ORed into | |
93 | .IR flags : | |
94 | .TP | |
95 | .B FAN_MARK_DONT_FOLLOW | |
96 | If | |
97 | .I pathname | |
98 | is a symbolic link, mark the link itself, rather than the file to which it | |
99 | refers. | |
100 | (By default, | |
101 | .BR fanotify_mark () | |
102 | dereferences | |
103 | .I pathname | |
104 | if it is a symbolic link.) | |
105 | .TP | |
106 | .B FAN_MARK_ONLYDIR | |
107 | If the filesystem object to be marked is not a directory, the error | |
108 | .B ENOTDIR | |
109 | shall be raised. | |
110 | .TP | |
111 | .B FAN_MARK_MOUNT | |
112 | Mark the mount point specified by | |
113 | .IR pathname . | |
114 | If | |
115 | .I pathname | |
116 | is not itself a mount point, the mount point containing | |
117 | .I pathname | |
118 | will be marked. | |
119 | All directories, subdirectories, and the contained files of the mount point | |
120 | will be monitored. | |
121 | .TP | |
122 | .B FAN_MARK_IGNORED_MASK | |
123 | The events in | |
124 | .I mask | |
125 | shall be added to or removed from the ignore mask. | |
126 | .TP | |
127 | .B FAN_MARK_IGNORED_SURV_MODIFY | |
128 | The ignore mask shall survive modify events. | |
129 | If this flag is not set, | |
130 | the ignore mask is cleared when a modify event occurs | |
131 | for the ignored file or directory. | |
132 | .PP | |
133 | .I mask | |
134 | defines which events shall be listened for (or which shall be ignored). | |
135 | It is a bit mask composed of the following values: | |
136 | .TP | |
137 | .B FAN_ACCESS | |
138 | Create an event when a file or directory (but see BUGS) is accessed (read). | |
139 | .TP | |
140 | .B FAN_MODIFY | |
141 | Create an event when a file is modified (write). | |
142 | .TP | |
143 | .B FAN_CLOSE_WRITE | |
144 | Create an event when a writable file is closed. | |
145 | .TP | |
146 | .B FAN_CLOSE_NOWRITE | |
147 | Create an event when a read-only file or directory is closed. | |
148 | .TP | |
149 | .B FAN_OPEN | |
150 | Create an event when a file or directory is opened. | |
151 | .TP | |
152 | .B FAN_Q_OVERFLOW | |
153 | Create an event when an overflow of the event queue occurs. | |
154 | The size of the event queue is limited to 16384 entries if | |
155 | .B FAN_UNLIMITED_QUEUE | |
156 | is not set in | |
157 | .BR fanotify_init (2). | |
158 | .TP | |
159 | .B FAN_OPEN_PERM | |
160 | Create an event when a permission to open a file or directory is requested. | |
161 | An fanotify file descriptor created with | |
162 | .B FAN_CLASS_PRE_CONTENT | |
163 | or | |
164 | .B FAN_CLASS_CONTENT | |
165 | is required. | |
166 | .TP | |
167 | .B FAN_ACCESS_PERM | |
168 | Create an event when a permission to read a file or directory is requested. | |
169 | An fanotify file descriptor created with | |
170 | .B FAN_CLASS_PRE_CONTENT | |
171 | or | |
172 | .B FAN_CLASS_CONTENT | |
173 | is required. | |
174 | .TP | |
175 | .B FAN_ONDIR | |
176 | Create events for directories\(emfor example, when | |
177 | .BR opendir (3), | |
178 | .BR readdir (3) | |
179 | (but see BUGS), and | |
180 | .BR closedir (3) | |
181 | are called. | |
182 | Without this flag, only events for files are created. | |
183 | .TP | |
184 | .B FAN_EVENT_ON_CHILD | |
185 | Events for the immediate children of marked directories shall be created. | |
186 | The flag has no effect when marking mounts. | |
187 | Note that events are not generated for children of the subdirectories | |
188 | of marked directories. | |
189 | To monitor complete directory trees it is necessary to mark the relevant | |
190 | mount. | |
191 | .PP | |
192 | The following composed value is defined: | |
193 | .TP | |
194 | .B FAN_CLOSE | |
195 | A file is closed | |
196 | .RB ( FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE ). | |
197 | .PP | |
198 | The filesystem object to be marked is determined by the file descriptor | |
199 | .I dirfd | |
200 | and the pathname specified in | |
201 | .IR pathname : | |
202 | .IP * 3 | |
203 | If | |
204 | .I pathname | |
205 | is NULL, | |
206 | .I dirfd | |
207 | defines the filesystem object to be marked. | |
208 | .IP * | |
209 | If | |
210 | .I pathname | |
211 | is NULL, and | |
212 | .I dirfd | |
213 | takes the special value | |
214 | .BR AT_FDCWD , | |
215 | the current working directory is to be marked. | |
216 | .IP * | |
217 | If | |
218 | .I pathname | |
219 | is absolute, it defines the filesystem object to be marked, and | |
220 | .I dirfd | |
221 | is ignored. | |
222 | .IP * | |
223 | If | |
224 | .I pathname | |
225 | is relative, and | |
226 | .I dirfd | |
227 | does not have the value | |
228 | .BR AT_FDCWD , | |
229 | then the filesystem object to be marked is determined by interpreting | |
230 | .I pathname | |
231 | relative the directory referred to by | |
232 | .IR dirfd . | |
233 | .IP * | |
234 | If | |
235 | .I pathname | |
236 | is relative, and | |
237 | .I dirfd | |
238 | has the value | |
239 | .BR AT_FDCWD , | |
240 | then the filesystem object to be marked is determined by interpreting | |
241 | .I pathname | |
242 | relative the current working directory. | |
243 | .SH RETURN VALUE | |
244 | On success, | |
245 | .BR fanotify_mark () | |
246 | returns 0. | |
247 | On error, \-1 is returned, and | |
248 | .I errno | |
249 | is set to indicate the error. | |
250 | .SH ERRORS | |
251 | .TP | |
252 | .B EBADF | |
253 | An invalid file descriptor was passed in | |
254 | .IR fanotify_fd . | |
255 | .TP | |
256 | .B EINVAL | |
257 | An invalid value was passed in | |
258 | .IR flags | |
259 | or | |
260 | .IR mask , | |
261 | or | |
262 | .I fanotify_fd | |
263 | was not an fanotify file descriptor. | |
264 | .TP | |
265 | .B EINVAL | |
266 | The fanotify file descriptor was opened with | |
267 | .B FAN_CLASS_NOTIF | |
268 | and mask contains a flag for permission events | |
269 | .RB ( FAN_OPEN_PERM | |
270 | or | |
271 | .BR FAN_ACCESS_PERM ). | |
272 | .TP | |
273 | .B ENOENT | |
274 | The filesystem object indicated by | |
275 | .IR dirfd | |
276 | and | |
277 | .IR pathname | |
278 | does not exist. | |
279 | This error also occurs when trying to remove a mark from an object | |
280 | which is not marked. | |
281 | .TP | |
282 | .B ENOMEM | |
283 | The necessary memory could not be allocated. | |
284 | .TP | |
285 | .B ENOSPC | |
286 | The number of marks exceeds the limit of 8192 and the | |
287 | .B FAN_UNLIMITED_MARKS | |
288 | flag was not specified when the fanotify file descriptor was created with | |
289 | .BR fanotify_init (2). | |
290 | .TP | |
291 | .B ENOSYS | |
292 | This kernel does not implement | |
293 | .BR fanotify_mark (). | |
294 | The fanotify API is available only if the kernel was configured with | |
295 | .BR CONFIG_FANOTIFY . | |
296 | .TP | |
297 | .B ENOTDIR | |
298 | .I flags | |
299 | contains | |
300 | .BR FAN_MARK_ONLYDIR , | |
301 | and | |
302 | .I dirfd | |
303 | and | |
304 | .I pathname | |
305 | do not specify a directory. | |
306 | .SH VERSIONS | |
307 | .BR fanotify_mark () | |
308 | was introduced in version 2.6.36 of the Linux kernel and enabled in version | |
309 | 2.6.37. | |
310 | .SH CONFORMING TO | |
311 | This system call is Linux-specific. | |
312 | .SH BUGS | |
313 | The following bugs were present in Linux kernels before version 3.16: | |
314 | .IP * 3 | |
315 | .\" Fixed by commit 0a8dd2db579f7a0ac7033d6b857c3d5dbaa77563 | |
316 | If | |
317 | .I flags | |
318 | contains | |
319 | .BR FAN_MARK_FLUSH , | |
320 | .I dirfd | |
321 | and | |
322 | .I pathname | |
323 | must specify a valid filesystem object, even though this object is not used. | |
324 | .IP * | |
325 | .\" Fixed by commit d4c7cf6cffb1bc711a833b5e304ba5bcfe76398b | |
326 | .BR readdir (2) | |
327 | does not generate a | |
328 | .B FAN_ACCESS | |
329 | event. | |
330 | .IP * | |
331 | .\" Fixed by commit cc299a98eb13a9853675a9cbb90b30b4011e1406 | |
332 | If | |
333 | .BR fanotify_mark () | |
334 | is called with | |
335 | .BR FAN_MARK_FLUSH , | |
336 | .I flags | |
337 | is not checked for invalid values. | |
338 | .SH SEE ALSO | |
339 | .BR fanotify_init (2), | |
340 | .BR fanotify (7) |