Debian Codegraph @

po/es/man7/fanotify.7.po

raw
1 # Spanish translation of manpages
2 # This file is distributed under the same license as the manpages-l10n package.
3 # Copyright © of this file:
4 msgid ""
5 msgstr ""
6 "Project-Id-Version: manpages-l10n 4.11.0\n"
7 "POT-Creation-Date: 2026-06-05 06:24+0200\n"
8 "PO-Revision-Date: 2021-09-10 15:37+0200\n"
9 "Last-Translator: Automatically generated\n"
10 "Language-Team: Spanish <[email protected]>\n"
11 "Language: es\n"
12 "MIME-Version: 1.0\n"
13 "Content-Type: text/plain; charset=UTF-8\n"
14 "Content-Transfer-Encoding: 8bit\n"
15 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
17 #. type: TH
18 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
19 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
20 #, fuzzy, no-wrap
21 #| msgid "B<notify>"
22 msgid "fanotify"
23 msgstr "B<notify>"
24
25 #. type: TH
26 #: archlinux debian-unstable opensuse-leap-16-1 opensuse-tumbleweed
27 #, no-wrap
28 msgid "2026-02-14"
29 msgstr "14 Febrero 2026"
30
31 #. type: TH
32 #: archlinux debian-unstable
33 #, fuzzy, no-wrap
34 #| msgid "Linux man-pages 6.17"
35 msgid "Linux man-pages 6.18"
36 msgstr "Páginas de Manual de Linux 6.17"
37
38 #. type: SH
39 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
40 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
41 #, no-wrap
42 msgid "NAME"
43 msgstr "NOMBRE"
44
45 #. type: Plain text
46 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
47 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
48 msgid "fanotify - monitoring filesystem events"
49 msgstr ""
50
51 #. type: SH
52 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
53 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
54 #, no-wrap
55 msgid "DESCRIPTION"
56 msgstr "DESCRIPCIÓN"
57
58 #. type: Plain text
59 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
60 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
61 msgid ""
62 "The fanotify API provides notification and interception of filesystem "
63 "events. Use cases include virus scanning and hierarchical storage "
64 "management. In the original fanotify API, only a limited set of events was "
65 "supported. In particular, there was no support for create, delete, and move "
66 "events. The support for those events was added in Linux 5.1. (See "
67 "B<inotify>(7) for details of an API that did notify those events pre Linux "
68 "5.1.)"
69 msgstr ""
70
71 #. type: Plain text
72 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
73 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
74 msgid ""
75 "Additional capabilities compared to the B<inotify>(7) API include the "
76 "ability to monitor all of the objects in a mounted filesystem, the ability "
77 "to make access permission decisions, and the possibility to read or modify "
78 "files before access by other applications."
79 msgstr ""
80
81 #. type: Plain text
82 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
83 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
84 msgid ""
85 "The following system calls are used with this API: B<fanotify_init>(2), "
86 "B<fanotify_mark>(2), B<read>(2), B<write>(2), and B<close>(2)."
87 msgstr ""
88
89 #. type: SS
90 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
91 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
92 #, no-wrap
93 msgid "fanotify_init(), fanotify_mark(), and notification groups"
94 msgstr ""
95
96 #. type: Plain text
97 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
98 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
99 msgid ""
100 "The B<fanotify_init>(2) system call creates and initializes an fanotify "
101 "notification group and returns a file descriptor referring to it."
102 msgstr ""
103
104 #. type: Plain text
105 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
106 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
107 msgid ""
108 "An fanotify notification group is a kernel-internal object that holds a list "
109 "of files, directories, filesystems, and mounts for which events shall be "
110 "created."
111 msgstr ""
112
113 #. type: Plain text
114 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
115 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
116 msgid ""
117 "For each entry in an fanotify notification group, two bit masks exist: the "
118 "I<mark> mask and the I<ignore> mask. The mark mask defines file activities "
119 "for which an event shall be created. The ignore mask defines activities for "
120 "which no event shall be generated. Having these two types of masks permits "
121 "a filesystem, mount, or directory to be marked for receiving events, while "
122 "at the same time ignoring events for specific objects under a mount or "
123 "directory."
124 msgstr ""
125
126 #. type: Plain text
127 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
128 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
129 msgid ""
130 "The B<fanotify_mark>(2) system call adds a file, directory, filesystem, or "
131 "mount to a notification group and specifies which events shall be reported "
132 "(or ignored), or removes or modifies such an entry."
133 msgstr ""
134
135 #. type: Plain text
136 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
137 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
138 msgid ""
139 "A possible usage of the ignore mask is for a file cache. Events of interest "
140 "for a file cache are modification of a file and closing of the same. Hence, "
141 "the cached directory or mount is to be marked to receive these events. "
142 "After receiving the first event informing that a file has been modified, the "
143 "corresponding cache entry will be invalidated. No further modification "
144 "events for this file are of interest until the file is closed. Hence, the "
145 "modify event can be added to the ignore mask. Upon receiving the close "
146 "event, the modify event can be removed from the ignore mask and the file "
147 "cache entry can be updated."
148 msgstr ""
149
150 #. type: Plain text
151 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
152 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
153 msgid ""
154 "The entries in the fanotify notification groups refer to files and "
155 "directories via their inode number and to mounts via their mount ID. If "
156 "files or directories are renamed or moved within the same mount, the "
157 "respective entries survive. If files or directories are deleted or moved to "
158 "another mount or if filesystems or mounts are unmounted, the corresponding "
159 "entries are deleted."
160 msgstr ""
161
162 #. type: SS
163 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
164 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
165 #, no-wrap
166 msgid "The event queue"
167 msgstr ""
168
169 #. type: Plain text
170 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
171 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
172 msgid ""
173 "As events occur on the filesystem objects monitored by a notification group, "
174 "the fanotify system generates events that are collected in a queue. These "
175 "events can then be read (using B<read>(2) or similar) from the fanotify "
176 "file descriptor returned by B<fanotify_init>(2)."
177 msgstr ""
178
179 #. type: Plain text
180 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
181 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
182 msgid ""
183 "Two types of events are generated: I<notification> events and I<permission> "
184 "events. Notification events are merely informative and require no action to "
185 "be taken by the receiving application with one exception: if a valid file "
186 "descriptor is provided within a generic event, the file descriptor must be "
187 "closed. Permission events are requests to the receiving application to "
188 "decide whether permission for a file access shall be granted. For these "
189 "events, the recipient must write a response which decides whether access is "
190 "granted or not."
191 msgstr ""
192
193 #. type: Plain text
194 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
195 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
196 msgid ""
197 "An event is removed from the event queue of the fanotify group when it has "
198 "been read. Permission events that have been read are kept in an internal "
199 "list of the fanotify group until either a permission decision has been taken "
200 "by writing to the fanotify file descriptor or the fanotify file descriptor "
201 "is closed."
202 msgstr ""
203
204 #. type: SS
205 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
206 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
207 #, no-wrap
208 msgid "Reading fanotify events"
209 msgstr ""
210
211 #. type: Plain text
212 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
213 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
214 msgid ""
215 "Calling B<read>(2) for the file descriptor returned by B<fanotify_init>(2) "
216 "blocks (if the flag B<FAN_NONBLOCK> is not specified in the call to "
217 "B<fanotify_init>(2)) until either a file event occurs or the call is "
218 "interrupted by a signal (see B<signal>(7))."
219 msgstr ""
220
221 #. type: Plain text
222 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
223 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
224 msgid ""
225 "After a successful B<read>(2), the read buffer contains one or more of the "
226 "following structures:"
227 msgstr ""
228
229 #. type: Plain text
230 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
231 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
232 #, no-wrap
233 msgid ""
234 "struct fanotify_event_metadata {\n"
235 " __u32 event_len;\n"
236 " __u8 vers;\n"
237 " __u8 reserved;\n"
238 " __u16 metadata_len;\n"
239 " __aligned_u64 mask;\n"
240 " __s32 fd;\n"
241 " __s32 pid;\n"
242 "};\n"
243 msgstr ""
244
245 #. type: Plain text
246 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
247 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
248 msgid ""
249 "Information records are supplemental pieces of information that may be "
250 "provided alongside the generic I<fanotify_event_metadata> structure. The "
251 "I<flags> passed to B<fanotify_init>(2) have influence over the type of "
252 "information records that may be returned for an event. For example, if a "
253 "notification group is initialized with B<FAN_REPORT_FID> or "
254 "B<FAN_REPORT_DIR_FID>, then event listeners should also expect to receive a "
255 "I<fanotify_event_info_fid> structure alongside the "
256 "I<fanotify_event_metadata> structure, whereby file handles are used to "
257 "identify filesystem objects rather than file descriptors. Information "
258 "records may also be stacked, meaning that using the various B<FAN_REPORT_*> "
259 "flags in conjunction with one another is supported. In such cases, multiple "
260 "information records can be returned for an event alongside the generic "
261 "I<fanotify_event_metadata> structure. For example, if a notification group "
262 "is initialized with B<FAN_REPORT_TARGET_FID> and B<FAN_REPORT_PIDFD>, then "
263 "an event listener should expect to receive up to two "
264 "I<fanotify_event_info_fid> information records and one "
265 "I<fanotify_event_info_pidfd> information record alongside the generic "
266 "I<fanotify_event_metadata> structure. Importantly, fanotify provides no "
267 "guarantee around the ordering of information records when a notification "
268 "group is initialized with a stacked based configuration. Each information "
269 "record has a nested structure of type I<fanotify_event_info_header>. It is "
270 "imperative for event listeners to inspect the I<info_type> field of this "
271 "structure in order to determine the type of information record that had been "
272 "received for a given event."
273 msgstr ""
274
275 #. type: Plain text
276 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
277 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
278 msgid ""
279 "In cases where an fanotify group identifies filesystem objects by file "
280 "handles, event listeners should also expect to receive one or more of the "
281 "below information record objects alongside the generic "
282 "I<fanotify_event_metadata> structure within the read buffer:"
283 msgstr ""
284
285 #. type: Plain text
286 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
287 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
288 #, no-wrap
289 msgid ""
290 "struct fanotify_event_info_fid {\n"
291 " struct fanotify_event_info_header hdr;\n"
292 " __kernel_fsid_t fsid;\n"
293 " unsigned char handle[];\n"
294 "};\n"
295 msgstr ""
296
297 #. type: Plain text
298 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
299 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
300 msgid ""
301 "In cases where an fanotify group is initialized with B<FAN_REPORT_PIDFD>, "
302 "event listeners should expect to receive the below information record object "
303 "alongside the generic I<fanotify_event_metadata> structure within the read "
304 "buffer:"
305 msgstr ""
306
307 #. type: Plain text
308 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
309 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
310 #, no-wrap
311 msgid ""
312 "struct fanotify_event_info_pidfd {\n"
313 " struct fanotify_event_info_header hdr;\n"
314 " __s32 pidfd;\n"
315 "};\n"
316 msgstr ""
317
318 #. type: Plain text
319 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
320 #: opensuse-tumbleweed
321 msgid ""
322 "In cases where an fanotify group is initialized with B<FAN_REPORT_MNT>, "
323 "event listeners should expect to receive the below information record object "
324 "alongside the generic I<fanotify_event_metadata> structure within the read "
325 "buffer. This structure is defined as follows:"
326 msgstr ""
327
328 #. type: Plain text
329 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
330 #: opensuse-tumbleweed
331 #, no-wrap
332 msgid ""
333 "struct fanotify_event_info_mnt {\n"
334 " struct fanotify_event_info_header hdr;\n"
335 " __u64 mnt_id;\n"
336 "};\n"
337 msgstr ""
338
339 #. type: Plain text
340 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
341 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
342 msgid ""
343 "In case of a B<FAN_FS_ERROR> event, an additional information record "
344 "describing the error that occurred is returned alongside the generic "
345 "I<fanotify_event_metadata> structure within the read buffer. This structure "
346 "is defined as follows:"
347 msgstr ""
348
349 #. type: Plain text
350 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
351 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
352 #, no-wrap
353 msgid ""
354 "struct fanotify_event_info_error {\n"
355 " struct fanotify_event_info_header hdr;\n"
356 " __s32 error;\n"
357 " __u32 error_count;\n"
358 "};\n"
359 msgstr ""
360
361 #. type: Plain text
362 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
363 #: opensuse-tumbleweed
364 msgid ""
365 "In case of B<FAN_PRE_ACCESS> events, an additional information record "
366 "describing the access range is returned alongside the generic "
367 "I<fanotify_event_metadata> structure within the read buffer. This structure "
368 "is defined as follows:"
369 msgstr ""
370
371 #. type: Plain text
372 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
373 #: opensuse-tumbleweed
374 #, no-wrap
375 msgid ""
376 "struct fanotify_event_info_range {\n"
377 " struct fanotify_event_info_header hdr;\n"
378 " __u32 pad;\n"
379 " __u64 offset;\n"
380 " __u64 count;\n"
381 "};\n"
382 msgstr ""
383
384 #. type: Plain text
385 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
386 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
387 msgid ""
388 "All information records contain a nested structure of type "
389 "I<fanotify_event_info_header>. This structure holds meta-information about "
390 "the information record that may have been returned alongside the generic "
391 "I<fanotify_event_metadata> structure. This structure is defined as follows:"
392 msgstr ""
393
394 #. type: Plain text
395 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
396 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
397 #, no-wrap
398 msgid ""
399 "struct fanotify_event_info_header {\n"
400 "\t__u8 info_type;\n"
401 "\t__u8 pad;\n"
402 "\t__u16 len;\n"
403 "};\n"
404 msgstr ""
405
406 #. type: Plain text
407 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
408 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
409 msgid ""
410 "For performance reasons, it is recommended to use a large buffer size (for "
411 "example, 4096 bytes), so that multiple events can be retrieved by a single "
412 "B<read>(2)."
413 msgstr ""
414
415 #. type: Plain text
416 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
417 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
418 msgid ""
419 "The return value of B<read>(2) is the number of bytes placed in the buffer, "
420 "or -1 in case of an error (but see BUGS)."
421 msgstr ""
422
423 #. type: Plain text
424 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
425 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
426 msgid "The fields of the I<fanotify_event_metadata> structure are as follows:"
427 msgstr ""
428
429 #. type: TP
430 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
431 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
432 #, no-wrap
433 msgid "I<event_len>"
434 msgstr ""
435
436 #. type: Plain text
437 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
438 #: opensuse-leap-16-1 opensuse-tumbleweed
439 msgid ""
440 "This is the size of the data for the current event and the offset to the "
441 "next event in the buffer. Unless the group identifies filesystem objects by "
442 "file handles, the value of I<event_len> is always "
443 "B<FAN_EVENT_METADATA_LEN>. For a group that identifies filesystem objects "
444 "by file handles, I<event_len> also includes the variable size file "
445 "identifier records."
446 msgstr ""
447
448 #. type: TP
449 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
450 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
451 #, no-wrap
452 msgid "I<vers>"
453 msgstr ""
454
455 #. type: Plain text
456 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
457 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
458 msgid ""
459 "This field holds a version number for the structure. It must be compared to "
460 "B<FANOTIFY_METADATA_VERSION> to verify that the structures returned at run "
461 "time match the structures defined at compile time. In case of a mismatch, "
462 "the application should abandon trying to use the fanotify file descriptor."
463 msgstr ""
464
465 #. type: TP
466 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
467 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
468 #, no-wrap
469 msgid "I<reserved>"
470 msgstr ""
471
472 #. type: Plain text
473 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
474 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
475 msgid "This field is not used."
476 msgstr ""
477
478 #. type: TP
479 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
480 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
481 #, no-wrap
482 msgid "I<metadata_len>"
483 msgstr ""
484
485 #. type: Plain text
486 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
487 #: opensuse-leap-16-1 opensuse-tumbleweed
488 msgid ""
489 "This is the size of the structure. The field was introduced to facilitate "
490 "the implementation of optional headers per event type. No such optional "
491 "headers exist in the current implementation."
492 msgstr ""
493
494 #. type: TP
495 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
496 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
497 #, no-wrap
498 msgid "I<mask>"
499 msgstr "I<mask>"
500
501 #. type: Plain text
502 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
503 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
504 msgid "This is a bit mask describing the event (see below)."
505 msgstr ""
506
507 #. type: TP
508 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
509 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
510 #, no-wrap
511 msgid "I<fd>"
512 msgstr "I<fd>"
513
514 #. type: Plain text
515 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
516 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
517 msgid ""
518 "This is an open file descriptor for the object being accessed, or "
519 "B<FAN_NOFD> if a queue overflow occurred. With an fanotify group that "
520 "identifies filesystem objects by file handles, applications should expect "
521 "this value to be set to B<FAN_NOFD> for each event that is received. The "
522 "file descriptor can be used to access the contents of the monitored file or "
523 "directory. The reading application is responsible for closing this file "
524 "descriptor."
525 msgstr ""
526
527 #. type: Plain text
528 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
529 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
530 msgid ""
531 "When calling B<fanotify_init>(2), the caller may specify (via the "
532 "I<event_f_flags> argument) various file status flags that are to be set on "
533 "the open file description that corresponds to this file descriptor. In "
534 "addition, the (kernel-internal) B<FMODE_NONOTIFY> file status flag is set "
535 "on the open file description. This flag suppresses fanotify event "
536 "generation. Hence, when the receiver of the fanotify event accesses the "
537 "notified file or directory using this file descriptor, no additional events "
538 "will be created."
539 msgstr ""
540
541 #. type: Plain text
542 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
543 #: opensuse-tumbleweed
544 msgid ""
545 "When an fanotify group is initialized using B<FAN_REPORT_FD_ERROR>, this "
546 "field will contain a negative error value in case a file descriptor could "
547 "not be opened and in case of a queue overflow, the value will be B<-EBADF>."
548 msgstr ""
549
550 #. type: TP
551 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
552 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
553 #, no-wrap
554 msgid "I<pid>"
555 msgstr ""
556
557 #. type: Plain text
558 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
559 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
560 msgid ""
561 "If flag B<FAN_REPORT_TID> was set in B<fanotify_init>(2), this is the TID of "
562 "the thread that caused the event. Otherwise, this the PID of the process "
563 "that caused the event."
564 msgstr ""
565
566 #. type: Plain text
567 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
568 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
569 msgid ""
570 "A program listening to fanotify events can compare this PID to the PID "
571 "returned by B<getpid>(2), to determine whether the event is caused by the "
572 "listener itself, or is due to a file access by another process."
573 msgstr ""
574
575 #. type: Plain text
576 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
577 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
578 msgid ""
579 "The bit mask in I<mask> indicates which events have occurred for a single "
580 "filesystem object. Multiple bits may be set in this mask, if more than one "
581 "event occurred for the monitored filesystem object. In particular, "
582 "consecutive events for the same filesystem object and originating from the "
583 "same process may be merged into a single event, with the exception that two "
584 "permission events are never merged into one queue entry."
585 msgstr ""
586
587 #. type: Plain text
588 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
589 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
590 msgid "The bits that may appear in I<mask> are as follows:"
591 msgstr ""
592
593 #. type: TP
594 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
595 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
596 #, no-wrap
597 msgid "B<FAN_ACCESS>"
598 msgstr ""
599
600 #. type: Plain text
601 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
602 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
603 msgid "A file or a directory (but see BUGS) was accessed (read)."
604 msgstr ""
605
606 #. type: TP
607 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
608 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
609 #, no-wrap
610 msgid "B<FAN_OPEN>"
611 msgstr ""
612
613 #. type: Plain text
614 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
615 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
616 msgid "A file or a directory was opened."
617 msgstr ""
618
619 #. type: TP
620 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
621 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
622 #, no-wrap
623 msgid "B<FAN_OPEN_EXEC>"
624 msgstr ""
625
626 #. type: Plain text
627 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
628 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
629 msgid ""
630 "A file was opened with the intent to be executed. See NOTES in "
631 "B<fanotify_mark>(2) for additional details."
632 msgstr ""
633
634 #. type: TP
635 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
636 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
637 #, no-wrap
638 msgid "B<FAN_ATTRIB>"
639 msgstr ""
640
641 #. type: Plain text
642 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
643 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
644 msgid "A file or directory metadata was changed."
645 msgstr ""
646
647 #. type: TP
648 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
649 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
650 #, no-wrap
651 msgid "B<FAN_CREATE>"
652 msgstr ""
653
654 #. type: Plain text
655 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
656 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
657 msgid "A child file or directory was created in a watched parent."
658 msgstr ""
659
660 #. type: TP
661 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
662 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
663 #, no-wrap
664 msgid "B<FAN_DELETE>"
665 msgstr ""
666
667 #. type: Plain text
668 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
669 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
670 msgid "A child file or directory was deleted in a watched parent."
671 msgstr ""
672
673 #. type: TP
674 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
675 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
676 #, no-wrap
677 msgid "B<FAN_DELETE_SELF>"
678 msgstr ""
679
680 #. type: Plain text
681 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
682 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
683 msgid "A watched file or directory was deleted."
684 msgstr ""
685
686 #. type: TP
687 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
688 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
689 #, fuzzy, no-wrap
690 #| msgid "B<LOGNAME>"
691 msgid "B<FAN_RENAME>"
692 msgstr "B<LOGNAME>"
693
694 #. type: Plain text
695 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
696 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
697 msgid ""
698 "A file or directory has been moved to or from a watched parent directory."
699 msgstr ""
700
701 #. type: TP
702 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
703 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
704 #, no-wrap
705 msgid "B<FAN_MOVED_FROM>"
706 msgstr ""
707
708 #. type: Plain text
709 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
710 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
711 msgid "A file or directory has been moved from a watched parent directory."
712 msgstr ""
713
714 #. type: TP
715 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
716 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
717 #, no-wrap
718 msgid "B<FAN_MOVED_TO>"
719 msgstr ""
720
721 #. type: Plain text
722 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
723 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
724 msgid "A file or directory has been moved to a watched parent directory."
725 msgstr ""
726
727 #. type: TP
728 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
729 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
730 #, no-wrap
731 msgid "B<FAN_MOVE_SELF>"
732 msgstr ""
733
734 #. type: Plain text
735 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
736 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
737 msgid "A watched file or directory was moved."
738 msgstr ""
739
740 #. type: TP
741 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
742 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
743 #, no-wrap
744 msgid "B<FAN_MODIFY>"
745 msgstr ""
746
747 #. type: Plain text
748 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
749 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
750 msgid "A file was modified."
751 msgstr ""
752
753 #. type: TP
754 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
755 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
756 #, no-wrap
757 msgid "B<FAN_CLOSE_WRITE>"
758 msgstr ""
759
760 #. type: Plain text
761 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
762 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
763 msgid ""
764 "A file that was opened for writing (B<O_WRONLY> or B<O_RDWR>) was closed."
765 msgstr ""
766
767 #. type: TP
768 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
769 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
770 #, no-wrap
771 msgid "B<FAN_CLOSE_NOWRITE>"
772 msgstr ""
773
774 #. type: Plain text
775 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
776 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
777 msgid ""
778 "A file or directory that was opened read-only (B<O_RDONLY>) was closed."
779 msgstr ""
780
781 #. type: TP
782 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
783 #: opensuse-tumbleweed
784 #, fuzzy, no-wrap
785 #| msgid "B<LOGNAME>"
786 msgid "B<FAN_MNT_ATTACH>"
787 msgstr "B<LOGNAME>"
788
789 #. type: Plain text
790 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
791 #: opensuse-tumbleweed
792 msgid "A mount was attached to mount namespace."
793 msgstr ""
794
795 #. type: TP
796 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
797 #: opensuse-tumbleweed
798 #, fuzzy, no-wrap
799 #| msgid "B<LOGNAME>"
800 msgid "B<FAN_MNT_DETACH>"
801 msgstr "B<LOGNAME>"
802
803 #. type: Plain text
804 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
805 #: opensuse-tumbleweed
806 msgid "A mount was detached from mount namespace."
807 msgstr ""
808
809 #. type: TP
810 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
811 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
812 #, fuzzy, no-wrap
813 #| msgid "B<FAN_Q_OVERFLOW>"
814 msgid "B<FAN_FS_ERROR>"
815 msgstr "B<FAN_Q_OVERFLOW>"
816
817 #. type: Plain text
818 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
819 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
820 msgid "A filesystem error was detected."
821 msgstr ""
822
823 #. type: TP
824 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
825 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
826 #, no-wrap
827 msgid "B<FAN_Q_OVERFLOW>"
828 msgstr "B<FAN_Q_OVERFLOW>"
829
830 #. type: Plain text
831 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
832 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
833 msgid ""
834 "The event queue exceeded the limit on number of events. This limit can be "
835 "overridden by specifying the B<FAN_UNLIMITED_QUEUE> flag when calling "
836 "B<fanotify_init>(2)."
837 msgstr ""
838
839 #. type: TP
840 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
841 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
842 #, no-wrap
843 msgid "B<FAN_ACCESS_PERM>"
844 msgstr ""
845
846 #. type: Plain text
847 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
848 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
849 msgid ""
850 "An application wants to read a file or directory, for example using "
851 "B<read>(2) or B<readdir>(2). The reader must write a response (as "
852 "described below) that determines whether the permission to access the "
853 "filesystem object shall be granted."
854 msgstr ""
855
856 #. type: TP
857 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
858 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
859 #, no-wrap
860 msgid "B<FAN_OPEN_PERM>"
861 msgstr ""
862
863 #. type: Plain text
864 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
865 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
866 msgid ""
867 "An application wants to open a file or directory. The reader must write a "
868 "response that determines whether the permission to open the filesystem "
869 "object shall be granted."
870 msgstr ""
871
872 #. type: TP
873 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
874 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
875 #, no-wrap
876 msgid "B<FAN_OPEN_EXEC_PERM>"
877 msgstr ""
878
879 #. type: Plain text
880 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
881 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
882 msgid ""
883 "An application wants to open a file for execution. The reader must write a "
884 "response that determines whether the permission to open the filesystem "
885 "object for execution shall be granted. See NOTES in B<fanotify_mark>(2) "
886 "for additional details."
887 msgstr ""
888
889 #. type: Plain text
890 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
891 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
892 msgid "To check for any close event, the following bit mask may be used:"
893 msgstr ""
894
895 #. type: TP
896 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
897 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
898 #, no-wrap
899 msgid "B<FAN_CLOSE>"
900 msgstr ""
901
902 #. type: Plain text
903 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
904 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
905 msgid "A file was closed. This is a synonym for:"
906 msgstr ""
907
908 #. type: Plain text
909 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
910 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
911 #, no-wrap
912 msgid "FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE\n"
913 msgstr ""
914
915 #. type: Plain text
916 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
917 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
918 msgid "To check for any move event, the following bit mask may be used:"
919 msgstr ""
920
921 #. type: TP
922 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
923 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
924 #, no-wrap
925 msgid "B<FAN_MOVE>"
926 msgstr ""
927
928 #. type: Plain text
929 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
930 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
931 msgid "A file or directory was moved. This is a synonym for:"
932 msgstr ""
933
934 #. type: Plain text
935 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
936 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
937 #, no-wrap
938 msgid "FAN_MOVED_FROM | FAN_MOVED_TO\n"
939 msgstr ""
940
941 #. type: Plain text
942 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
943 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
944 msgid ""
945 "The following bits may appear in I<mask> only in conjunction with other "
946 "event type bits:"
947 msgstr ""
948
949 #. type: TP
950 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
951 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
952 #, no-wrap
953 msgid "B<FAN_ONDIR>"
954 msgstr ""
955
956 #. type: Plain text
957 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
958 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
959 msgid ""
960 "The events described in the I<mask> have occurred on a directory object. "
961 "Reporting events on directories requires setting this flag in the mark "
962 "mask. See B<fanotify_mark>(2) for additional details. The B<FAN_ONDIR> "
963 "flag is reported in an event mask only if the fanotify group identifies "
964 "filesystem objects by file handles."
965 msgstr ""
966
967 #. type: Plain text
968 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
969 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
970 msgid ""
971 "Information records that are supplied alongside the generic "
972 "I<fanotify_event_metadata> structure will always contain a nested structure "
973 "of type I<fanotify_event_info_header>. The fields of the "
974 "I<fanotify_event_info_header> are as follows:"
975 msgstr ""
976
977 #. type: TP
978 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
979 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
980 #, no-wrap
981 msgid "I<info_type>"
982 msgstr ""
983
984 #. type: Plain text
985 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
986 #: opensuse-tumbleweed
987 msgid ""
988 "A unique integer value representing the type of information record object "
989 "received for an event. The value of this field can be set to one of the "
990 "following."
991 msgstr ""
992
993 #. type: TP
994 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
995 #: opensuse-tumbleweed
996 #, no-wrap
997 msgid "B<FAN_EVENT_INFO_TYPE_FID>"
998 msgstr ""
999
1000 #. type: TQ
1001 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1002 #: opensuse-tumbleweed
1003 #, no-wrap
1004 msgid "B<FAN_EVENT_INFO_TYPE_DFID>"
1005 msgstr ""
1006
1007 #. type: TQ
1008 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1009 #: opensuse-tumbleweed
1010 #, no-wrap
1011 msgid "B<FAN_EVENT_INFO_TYPE_DFID_NAME>"
1012 msgstr ""
1013
1014 #. type: TQ
1015 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1016 #: opensuse-tumbleweed
1017 #, no-wrap
1018 msgid "B<FAN_EVENT_INFO_TYPE_PIDFD>"
1019 msgstr ""
1020
1021 #. type: TQ
1022 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1023 #: opensuse-tumbleweed
1024 #, fuzzy, no-wrap
1025 #| msgid "B<FAN_Q_OVERFLOW>"
1026 msgid "B<FAN_EVENT_INFO_TYPE_ERROR>"
1027 msgstr "B<FAN_Q_OVERFLOW>"
1028
1029 #. type: TQ
1030 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1031 #: opensuse-tumbleweed
1032 #, no-wrap
1033 msgid "B<FAN_EVENT_INFO_TYPE_RANGE>"
1034 msgstr ""
1035
1036 #. type: TQ
1037 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1038 #: opensuse-tumbleweed
1039 #, no-wrap
1040 msgid "B<FAN_EVENT_INFO_TYPE_MNT>"
1041 msgstr ""
1042
1043 #. type: Plain text
1044 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1045 #: opensuse-tumbleweed
1046 msgid ""
1047 "The value set for this field is dependent on the flags that have been "
1048 "supplied to B<fanotify_init>(2). Refer to the field details of each "
1049 "information record object type below to understand the different cases in "
1050 "which the I<info_type> values can be set."
1051 msgstr ""
1052
1053 #. type: TP
1054 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1055 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1056 #, no-wrap
1057 msgid "I<pad>"
1058 msgstr ""
1059
1060 #. type: Plain text
1061 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1062 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1063 msgid ""
1064 "This field is currently not used by any information record object type and "
1065 "therefore is set to zero."
1066 msgstr ""
1067
1068 #. type: TP
1069 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1070 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1071 #, no-wrap
1072 msgid "I<len>"
1073 msgstr ""
1074
1075 #. type: Plain text
1076 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1077 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1078 msgid ""
1079 "The value of I<len> is set to the size of the information record object, "
1080 "including the I<fanotify_event_info_header>. The total size of all "
1081 "additional information records is not expected to be larger than "
1082 "(I<event_len> - I<metadata_len>)."
1083 msgstr ""
1084
1085 #. type: Plain text
1086 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1087 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1088 msgid "The fields of the I<fanotify_event_info_fid> structure are as follows:"
1089 msgstr ""
1090
1091 #. type: TP
1092 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1093 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1094 #, no-wrap
1095 msgid "I<hdr>"
1096 msgstr ""
1097
1098 #. type: Plain text
1099 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1100 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1101 msgid ""
1102 "This is a structure of type I<fanotify_event_info_header>. For example, "
1103 "when an fanotify file descriptor is created using B<FAN_REPORT_FID>, a "
1104 "single information record is expected to be attached to the event with "
1105 "I<info_type> field value of B<FAN_EVENT_INFO_TYPE_FID>. When an fanotify "
1106 "file descriptor is created using the combination of B<FAN_REPORT_FID> and "
1107 "B<FAN_REPORT_DIR_FID>, there may be two information records attached to the "
1108 "event: one with I<info_type> field value of B<FAN_EVENT_INFO_TYPE_DFID>, "
1109 "identifying a parent directory object, and one with I<info_type> field value "
1110 "of B<FAN_EVENT_INFO_TYPE_FID>, identifying a child object. Note that for "
1111 "the directory entry modification events B<FAN_CREATE>, B<FAN_DELETE>, "
1112 "B<FAN_MOVE>, and B<FAN_RENAME>, an information record identifying the "
1113 "created/deleted/moved child object is reported only if an fanotify group was "
1114 "initialized with the flag B<FAN_REPORT_TARGET_FID>."
1115 msgstr ""
1116
1117 #. type: TP
1118 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1119 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1120 #, no-wrap
1121 msgid "I<fsid>"
1122 msgstr ""
1123
1124 #. type: Plain text
1125 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1126 #: opensuse-leap-16-1 opensuse-tumbleweed
1127 msgid ""
1128 "This is a unique identifier of the filesystem containing the object "
1129 "associated with the event. It is a structure of type I<__kernel_fsid_t> and "
1130 "contains the same value as I<f_fsid> when calling B<statfs>(2). Note that "
1131 "some filesystems (e.g., B<fuse>(4)) report zero I<fsid>. In these cases, "
1132 "it is not possible to use I<fsid> to associate the event with a specific "
1133 "filesystem instance, so monitoring different filesystem instances that "
1134 "report zero I<fsid> with the same fanotify group is not supported."
1135 msgstr ""
1136
1137 #. type: TP
1138 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1139 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1140 #, no-wrap
1141 msgid "I<handle>"
1142 msgstr ""
1143
1144 #. type: Plain text
1145 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1146 #: opensuse-leap-16-1 opensuse-tumbleweed
1147 msgid ""
1148 "This field contains a variable-size structure of type I<struct "
1149 "file_handle>. It is an opaque handle that corresponds to a specified object "
1150 "on a filesystem as returned by B<name_to_handle_at>(2). It can be used to "
1151 "uniquely identify a file on a filesystem and can be passed as an argument to "
1152 "B<open_by_handle_at>(2). If the value of I<info_type> field is "
1153 "B<FAN_EVENT_INFO_TYPE_DFID_NAME>, the file handle is followed by a null "
1154 "terminated string that identifies the created/deleted/moved directory entry "
1155 "name. For other events such as B<FAN_OPEN>, B<FAN_ATTRIB>, "
1156 "B<FAN_DELETE_SELF>, and B<FAN_MOVE_SELF>, if the value of I<info_type> field "
1157 "is B<FAN_EVENT_INFO_TYPE_FID>, the I<handle> identifies the object "
1158 "correlated to the event. If the value of I<info_type> field is "
1159 "B<FAN_EVENT_INFO_TYPE_DFID>, the I<handle> identifies the directory object "
1160 "correlated to the event or the parent directory of a non-directory object "
1161 "correlated to the event. If the value of I<info_type> field is "
1162 "B<FAN_EVENT_INFO_TYPE_DFID_NAME>, the I<handle> identifies the same "
1163 "directory object that would be reported with B<FAN_EVENT_INFO_TYPE_DFID> and "
1164 "the file handle is followed by a null terminated string that identifies the "
1165 "name of a directory entry in that directory, or '.' to identify the "
1166 "directory object itself."
1167 msgstr ""
1168
1169 #. type: Plain text
1170 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1171 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1172 msgid ""
1173 "The fields of the I<fanotify_event_info_pidfd> structure are as follows:"
1174 msgstr ""
1175
1176 #. type: Plain text
1177 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1178 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1179 msgid ""
1180 "This is a structure of type I<fanotify_event_info_header>. When an fanotify "
1181 "group is initialized using B<FAN_REPORT_PIDFD>, the I<info_type> field value "
1182 "of the I<fanotify_event_info_header> is set to B<FAN_EVENT_INFO_TYPE_PIDFD>."
1183 msgstr ""
1184
1185 #. type: TP
1186 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1187 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1188 #, no-wrap
1189 msgid "I<pidfd>"
1190 msgstr ""
1191
1192 #. type: Plain text
1193 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1194 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1195 msgid ""
1196 "This is a process file descriptor that refers to the process responsible for "
1197 "generating the event. The returned process file descriptor is no different "
1198 "from one which could be obtained manually if B<pidfd_open>(2) were to be "
1199 "called on I<fanotify_event_metadata.pid>. In the instance that an error is "
1200 "encountered during pidfd creation, one of two possible error types "
1201 "represented by a negative integer value may be returned in this I<pidfd> "
1202 "field. In cases where the process responsible for generating the event has "
1203 "terminated prior to the event listener being able to read events from the "
1204 "notification queue, B<FAN_NOPIDFD> is returned. The pidfd creation for an "
1205 "event is only performed at the time the events are read from the "
1206 "notification queue. All other possible pidfd creation failures are "
1207 "represented by B<FAN_EPIDFD>. Once the event listener has dealt with an "
1208 "event and the pidfd is no longer required, the pidfd should be closed via "
1209 "B<close>(2)."
1210 msgstr ""
1211
1212 #. type: Plain text
1213 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1214 #: opensuse-tumbleweed
1215 msgid ""
1216 "When an fanotify group is initialized using B<FAN_REPORT_FD_ERROR>, this "
1217 "field will contain a negative error value in case a pidfd creation failure "
1218 "and in case of a terminated process, the value will be B<-ESRCH>."
1219 msgstr ""
1220
1221 #. type: Plain text
1222 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1223 #: opensuse-tumbleweed
1224 #, fuzzy
1225 #| msgid "The elements of this structure are as follows:"
1226 msgid "The fields of the I<fanotify_event_info_mnt> structure are as follows:"
1227 msgstr "Los elementos de esta estructura son de la siguiente manera:"
1228
1229 #. type: TP
1230 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1231 #: opensuse-tumbleweed
1232 #, no-wrap
1233 msgid "I<.hdr>"
1234 msgstr ""
1235
1236 #. type: Plain text
1237 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1238 #: opensuse-tumbleweed
1239 msgid ""
1240 "This is a structure of type I<fanotify_event_info_header>. The "
1241 "I<.info_type> field is set to B<FAN_EVENT_INFO_TYPE_MNT>."
1242 msgstr ""
1243
1244 #. type: TP
1245 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1246 #: opensuse-tumbleweed
1247 #, fuzzy, no-wrap
1248 #| msgid "I<mnt_id>"
1249 msgid "I<.mnt_id>"
1250 msgstr "I<mnt_id>"
1251
1252 #. type: Plain text
1253 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1254 #: opensuse-tumbleweed
1255 msgid ""
1256 "Identifies the mount associated with the event. It is a 64-bit unique mount "
1257 "id as the one returned by B<statx>(2) with the B<STATX_MNT_ID_UNIQUE> flag."
1258 msgstr ""
1259
1260 #. type: Plain text
1261 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1262 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1263 msgid ""
1264 "The fields of the I<fanotify_event_info_error> structure are as follows:"
1265 msgstr ""
1266
1267 #. type: Plain text
1268 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1269 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1270 msgid ""
1271 "This is a structure of type I<fanotify_event_info_header>. The I<info_type> "
1272 "field is set to B<FAN_EVENT_INFO_TYPE_ERROR>."
1273 msgstr ""
1274
1275 #. type: TP
1276 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1277 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1278 #, fuzzy, no-wrap
1279 #| msgid "B<errtrace>"
1280 msgid "I<error>"
1281 msgstr "B<errtrace>"
1282
1283 #. type: Plain text
1284 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1285 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1286 msgid "Identifies the type of error that occurred."
1287 msgstr ""
1288
1289 #. type: TP
1290 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1291 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1292 #, no-wrap
1293 msgid "I<error_count>"
1294 msgstr ""
1295
1296 #. type: Plain text
1297 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1298 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1299 msgid ""
1300 "This is a counter of the number of errors suppressed since the last error "
1301 "was read."
1302 msgstr ""
1303
1304 #. type: Plain text
1305 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1306 #: opensuse-tumbleweed
1307 #, fuzzy
1308 #| msgid "The elements of this structure are as follows:"
1309 msgid ""
1310 "The fields of the I<fanotify_event_info_range> structure are as follows:"
1311 msgstr "Los elementos de esta estructura son de la siguiente manera:"
1312
1313 #. type: Plain text
1314 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1315 #: opensuse-tumbleweed
1316 msgid ""
1317 "This is a structure of type I<fanotify_event_info_header>. The I<info_type> "
1318 "field is set to B<FAN_EVENT_INFO_TYPE_RANGE>."
1319 msgstr ""
1320
1321 #. type: TP
1322 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1323 #: opensuse-tumbleweed
1324 #, fuzzy, no-wrap
1325 #| msgid "I<RefCount>:"
1326 msgid "I<count>"
1327 msgstr "I<RefCount>:"
1328
1329 #. type: Plain text
1330 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1331 #: opensuse-tumbleweed
1332 msgid "The number of bytes being read or written to the file."
1333 msgstr ""
1334
1335 #. type: TP
1336 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1337 #: opensuse-tumbleweed
1338 #, fuzzy, no-wrap
1339 #| msgid "B<-d> I<offset>"
1340 msgid "I<offset>"
1341 msgstr "B<-d> I<posición>"
1342
1343 #. type: Plain text
1344 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1345 #: opensuse-tumbleweed
1346 msgid "The offset from which bytes are read or written to the file."
1347 msgstr ""
1348
1349 #. type: Plain text
1350 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1351 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1352 msgid ""
1353 "The following macros are provided to iterate over a buffer containing "
1354 "fanotify event metadata returned by a B<read>(2) from an fanotify file "
1355 "descriptor:"
1356 msgstr ""
1357
1358 #. type: TP
1359 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1360 #: opensuse-leap-16-1 opensuse-tumbleweed
1361 #, no-wrap
1362 msgid "B<FAN_EVENT_OK(meta, size)>"
1363 msgstr ""
1364
1365 #. type: Plain text
1366 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1367 #: opensuse-leap-16-1 opensuse-tumbleweed
1368 msgid ""
1369 "This macro checks the remaining size I<size> of the buffer I<meta> against "
1370 "the size of the metadata structure and the I<event_len> field of the first "
1371 "metadata structure in the buffer."
1372 msgstr ""
1373
1374 #. type: TP
1375 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1376 #: opensuse-leap-16-1 opensuse-tumbleweed
1377 #, no-wrap
1378 msgid "B<FAN_EVENT_NEXT(meta, size)>"
1379 msgstr ""
1380
1381 #. type: Plain text
1382 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1383 #: opensuse-leap-16-1 opensuse-tumbleweed
1384 msgid ""
1385 "This macro uses the size indicated in the I<event_len> field of the metadata "
1386 "structure pointed to by I<meta> to calculate the address of the next "
1387 "metadata structure that follows I<meta>. I<size> is the number of bytes of "
1388 "metadata that currently remain in the buffer. The macro returns a pointer "
1389 "to the next metadata structure that follows I<meta>, and reduces I<size> by "
1390 "the number of bytes in the metadata structure that has been skipped over "
1391 "(i.e., it subtracts I<meta-E<gt>event_len> from I<size>)."
1392 msgstr ""
1393
1394 #. type: Plain text
1395 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1396 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1397 msgid "In addition, there is:"
1398 msgstr ""
1399
1400 #. type: TP
1401 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1402 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1403 #, no-wrap
1404 msgid "B<FAN_EVENT_METADATA_LEN>"
1405 msgstr ""
1406
1407 #. type: Plain text
1408 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1409 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1410 msgid ""
1411 "This macro returns the size (in bytes) of the structure "
1412 "I<fanotify_event_metadata>. This is the minimum size (and currently the "
1413 "only size) of any event metadata."
1414 msgstr ""
1415
1416 #. type: SS
1417 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1418 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1419 #, no-wrap
1420 msgid "Monitoring an fanotify file descriptor for events"
1421 msgstr ""
1422
1423 #. type: Plain text
1424 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1425 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1426 msgid ""
1427 "When an fanotify event occurs, the fanotify file descriptor indicates as "
1428 "readable when passed to B<epoll>(7), B<poll>(2), or B<select>(2)."
1429 msgstr ""
1430
1431 #. type: SS
1432 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1433 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1434 #, no-wrap
1435 msgid "Dealing with permission events"
1436 msgstr ""
1437
1438 #. type: Plain text
1439 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1440 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1441 msgid ""
1442 "For permission events, the application must B<write>(2) a structure of the "
1443 "following form to the fanotify file descriptor:"
1444 msgstr ""
1445
1446 #. type: Plain text
1447 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1448 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1449 #, no-wrap
1450 msgid ""
1451 "struct fanotify_response {\n"
1452 " __s32 fd;\n"
1453 " __u32 response;\n"
1454 "};\n"
1455 msgstr ""
1456
1457 #. type: Plain text
1458 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1459 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1460 msgid "The fields of this structure are as follows:"
1461 msgstr ""
1462
1463 #. type: Plain text
1464 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1465 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1466 msgid ""
1467 "This is the file descriptor from the structure I<fanotify_event_metadata>."
1468 msgstr ""
1469
1470 #. type: TP
1471 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1472 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1473 #, no-wrap
1474 msgid "I<response>"
1475 msgstr ""
1476
1477 #. type: Plain text
1478 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1479 #: opensuse-tumbleweed
1480 msgid ""
1481 "This field indicates whether or not the permission is to be granted. Its "
1482 "value must contain either the flag B<FAN_ALLOW> to allow the file operation "
1483 "or B<FAN_DENY> to deny the file operation."
1484 msgstr ""
1485
1486 #. commit b4b2ff4f61ded819bfa22e50fdec7693f51cbbee
1487 #. type: Plain text
1488 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1489 #: opensuse-tumbleweed
1490 msgid ""
1491 "If access is denied, the requesting application call will receive an "
1492 "B<EPERM> error. Since Linux 6.13, if a notification group is initialized "
1493 "with class B<FAN_CLASS_PRE_CONTENT>, the file operation can be denied with "
1494 "errors other than B<EPERM>. For example, for the requesting application to "
1495 "get the B<EIO> error, the event listener can write the response "
1496 "B<FAN_DENY_ERRNO>(B<EIO>). At the time of writing, only the following error "
1497 "values could be returned to the application with "
1498 "B<FAN_DENY_ERRNO>(\\f[I]e\\fR) macro: B<EPERM>, B<EIO>, B<EBUSY>, "
1499 "B<ETXTBSY>, B<EAGAIN>, B<ENOSPC>, B<EDQUOT>."
1500 msgstr ""
1501
1502 #. type: Plain text
1503 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1504 #: opensuse-tumbleweed
1505 msgid ""
1506 "Additionally, if the notification group has been created with the "
1507 "B<FAN_ENABLE_AUDIT> flag, then the B<FAN_AUDIT> flag can be set in the "
1508 "I<response> field. In that case, the audit subsystem will log information "
1509 "about the access decision to the audit logs."
1510 msgstr ""
1511
1512 #. commit 70529a199574c15a40f46b14256633b02ba10ca2
1513 #. type: Plain text
1514 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1515 #: opensuse-tumbleweed
1516 msgid ""
1517 "Since Linux 6.3, the B<FAN_INFO> flag can be set in the I<.response> field. "
1518 "It indicates that an extra variable-length response record follows the "
1519 "I<fanotify_response> structure. Extra response records start with a common "
1520 "header:"
1521 msgstr ""
1522
1523 #. type: Plain text
1524 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1525 #: opensuse-tumbleweed
1526 #, no-wrap
1527 msgid ""
1528 "struct fanotify_response_info_header {\n"
1529 " __u8 type;\n"
1530 " __u8 pad;\n"
1531 " __u16 len;\n"
1532 "};\n"
1533 msgstr ""
1534
1535 #. type: Plain text
1536 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1537 #: opensuse-tumbleweed
1538 msgid ""
1539 "The value of I<.type> determines the format of the extra response record."
1540 msgstr ""
1541
1542 #. type: TP
1543 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1544 #: opensuse-tumbleweed
1545 #, no-wrap
1546 msgid "B<FAN_RESPONSE_INFO_AUDIT_RULE>"
1547 msgstr ""
1548
1549 #. type: Plain text
1550 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1551 #: opensuse-tumbleweed
1552 msgid ""
1553 "The following response record is expected with extra details for the audit "
1554 "log:"
1555 msgstr ""
1556
1557 #. type: Plain text
1558 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1559 #: opensuse-tumbleweed
1560 #, no-wrap
1561 msgid ""
1562 "struct fanotify_response_info_audit_rule {\n"
1563 " struct fanotify_response_info_header hdr;\n"
1564 " __u32 rule_number;\n"
1565 " __u32 subj_trust;\n"
1566 " __u32 obj_trust;\n"
1567 "};\n"
1568 msgstr ""
1569
1570 #. type: SS
1571 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1572 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1573 #, no-wrap
1574 msgid "Monitoring filesystems for errors"
1575 msgstr ""
1576
1577 #. type: Plain text
1578 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1579 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1580 msgid ""
1581 "A single B<FAN_FS_ERROR> event is stored per filesystem at once. Extra "
1582 "error messages are suppressed and accounted for in the I<error_count> field "
1583 "of the existing B<FAN_FS_ERROR> event record, but details about the errors "
1584 "are lost."
1585 msgstr ""
1586
1587 #. type: Plain text
1588 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1589 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1590 msgid ""
1591 "Errors reported by B<FAN_FS_ERROR> are generic I<errno> values, but not all "
1592 "kinds of error types are reported by all filesystems."
1593 msgstr ""
1594
1595 #. type: Plain text
1596 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
1597 #: opensuse-tumbleweed
1598 msgid ""
1599 "Errors not directly related to a file (i.e., super block corruption) are "
1600 "reported with an invalid I<handle>. For these errors, the I<handle> will "
1601 "have the field I<handle_type> set to B<FILEID_INVALID>, and the handle "
1602 "buffer size set to B<0>."
1603 msgstr ""
1604
1605 #. type: SS
1606 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1607 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1608 #, no-wrap
1609 msgid "Closing the fanotify file descriptor"
1610 msgstr ""
1611
1612 #. type: Plain text
1613 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1614 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1615 msgid ""
1616 "When all file descriptors referring to the fanotify notification group are "
1617 "closed, the fanotify group is released and its resources are freed for reuse "
1618 "by the kernel. Upon B<close>(2), outstanding permission events will be set "
1619 "to allowed."
1620 msgstr ""
1621
1622 #. type: SS
1623 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1624 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1625 #, no-wrap
1626 msgid "/proc interfaces"
1627 msgstr "Interfaces /proc"
1628
1629 #. type: Plain text
1630 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1631 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1632 msgid ""
1633 "The file I</proc/>pidI</fdinfo/>fd contains information about fanotify marks "
1634 "for file descriptor I<fd> of process I<pid>. See B<proc>(5) for details."
1635 msgstr ""
1636
1637 #. commit 5b8fea65d197f408bb00b251c70d842826d6b70b
1638 #. type: Plain text
1639 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1640 #: opensuse-leap-16-1 opensuse-tumbleweed
1641 msgid ""
1642 "Since Linux 5.13 (and 5.10.220), the following interfaces can be used to "
1643 "control the amount of kernel resources consumed by fanotify:"
1644 msgstr ""
1645
1646 #. type: TP
1647 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1648 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1649 #, no-wrap
1650 msgid "I</proc/sys/fs/fanotify/max_queued_events>"
1651 msgstr ""
1652
1653 #. commit 5b8fea65d197f408bb00b251c70d842826d6b70b
1654 #. type: Plain text
1655 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1656 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1657 msgid ""
1658 "The value in this file is used when an application calls "
1659 "B<fanotify_init>(2) to set an upper limit on the number of events that can "
1660 "be queued to the corresponding fanotify group. Events in excess of this "
1661 "limit are dropped, but an B<FAN_Q_OVERFLOW> event is always generated. "
1662 "Prior to Linux kernel 5.13, the hardcoded limit was 16384 events."
1663 msgstr ""
1664
1665 #. type: TP
1666 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1667 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1668 #, no-wrap
1669 msgid "I</proc/sys/fs/fanotify/max_user_group>"
1670 msgstr ""
1671
1672 #. commit 5b8fea65d197f408bb00b251c70d842826d6b70b
1673 #. type: Plain text
1674 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1675 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1676 msgid ""
1677 "This specifies an upper limit on the number of fanotify groups that can be "
1678 "created per real user ID. Prior to Linux kernel 5.13, the hardcoded limit "
1679 "was 128 groups per user."
1680 msgstr ""
1681
1682 #. type: TP
1683 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1684 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1685 #, no-wrap
1686 msgid "I</proc/sys/fs/fanotify/max_user_marks>"
1687 msgstr ""
1688
1689 #. commit 5b8fea65d197f408bb00b251c70d842826d6b70b
1690 #. type: Plain text
1691 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1692 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1693 msgid ""
1694 "This specifies an upper limit on the number of fanotify marks that can be "
1695 "created per real user ID. Prior to Linux kernel 5.13, the hardcoded limit "
1696 "was 8192 marks per group (not per user)."
1697 msgstr ""
1698
1699 #. type: SH
1700 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1701 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1702 #, no-wrap
1703 msgid "ERRORS"
1704 msgstr "ERRORES"
1705
1706 #. type: Plain text
1707 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1708 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1709 msgid ""
1710 "In addition to the usual errors for B<read>(2), the following errors can "
1711 "occur when reading from the fanotify file descriptor:"
1712 msgstr ""
1713
1714 #. type: TP
1715 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1716 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1717 #, no-wrap
1718 msgid "B<EINVAL>"
1719 msgstr "B<EINVAL>"
1720
1721 #. type: Plain text
1722 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1723 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1724 msgid "The buffer is too small to hold the event."
1725 msgstr ""
1726
1727 #. type: TP
1728 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1729 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1730 #, no-wrap
1731 msgid "B<EMFILE>"
1732 msgstr "B<EMFILE>"
1733
1734 #. type: Plain text
1735 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1736 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1737 msgid ""
1738 "The per-process limit on the number of open files has been reached. See the "
1739 "description of B<RLIMIT_NOFILE> in B<getrlimit>(2)."
1740 msgstr ""
1741
1742 #. type: TP
1743 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1744 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1745 #, no-wrap
1746 msgid "B<ENFILE>"
1747 msgstr "B<ENFILE>"
1748
1749 #. type: Plain text
1750 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1751 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1752 msgid ""
1753 "The system-wide limit on the total number of open files has been reached. "
1754 "See I</proc/sys/fs/file-max> in B<proc>(5)."
1755 msgstr ""
1756
1757 #. type: TP
1758 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1759 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1760 #, no-wrap
1761 msgid "B<ETXTBSY>"
1762 msgstr "B<ETXTBSY>"
1763
1764 #. type: Plain text
1765 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1766 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1767 msgid ""
1768 "This error is returned by B<read>(2) if B<O_RDWR> or B<O_WRONLY> was "
1769 "specified in the I<event_f_flags> argument when calling B<fanotify_init>(2) "
1770 "and an event occurred for a monitored file that is currently being executed."
1771 msgstr ""
1772
1773 #. type: Plain text
1774 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1775 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1776 msgid ""
1777 "In addition to the usual errors for B<write>(2), the following errors can "
1778 "occur when writing to the fanotify file descriptor:"
1779 msgstr ""
1780
1781 #. type: Plain text
1782 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1783 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1784 msgid ""
1785 "Fanotify access permissions are not enabled in the kernel configuration or "
1786 "the value of I<response> in the response structure is not valid."
1787 msgstr ""
1788
1789 #. type: TP
1790 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1791 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1792 #, no-wrap
1793 msgid "B<ENOENT>"
1794 msgstr "B<ENOENT>"
1795
1796 #. type: Plain text
1797 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1798 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1799 msgid ""
1800 "The file descriptor I<fd> in the response structure is not valid. This may "
1801 "occur when a response for the permission event has already been written."
1802 msgstr ""
1803
1804 #. type: SH
1805 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1806 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1807 #, no-wrap
1808 msgid "STANDARDS"
1809 msgstr "ESTÁNDARES"
1810
1811 #. type: Plain text
1812 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1813 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1814 msgid "Linux."
1815 msgstr "Linux."
1816
1817 #. type: SH
1818 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1819 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1820 #, no-wrap
1821 msgid "HISTORY"
1822 msgstr "HISTORIAL"
1823
1824 #. type: Plain text
1825 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1826 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1827 msgid ""
1828 "The fanotify API was introduced in Linux 2.6.36 and enabled in Linux "
1829 "2.6.37. fdinfo support was added in Linux 3.8."
1830 msgstr ""
1831
1832 #. type: SH
1833 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1834 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1835 #, no-wrap
1836 msgid "NOTES"
1837 msgstr "NOTAS"
1838
1839 #. type: Plain text
1840 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1841 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1842 msgid ""
1843 "The fanotify API is available only if the kernel was built with the "
1844 "B<CONFIG_FANOTIFY> configuration option enabled. In addition, fanotify "
1845 "permission handling is available only if the "
1846 "B<CONFIG_FANOTIFY_ACCESS_PERMISSIONS> configuration option is enabled."
1847 msgstr ""
1848
1849 #. type: SS
1850 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1851 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1852 #, no-wrap
1853 msgid "Limitations and caveats"
1854 msgstr ""
1855
1856 #. type: Plain text
1857 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1858 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1859 msgid ""
1860 "Fanotify reports only events that a user-space program triggers through the "
1861 "filesystem API. As a result, it does not catch remote events that occur on "
1862 "network filesystems."
1863 msgstr ""
1864
1865 #. type: Plain text
1866 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1867 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1868 msgid ""
1869 "The fanotify API does not report file accesses and modifications that may "
1870 "occur because of B<mmap>(2), B<msync>(2), and B<munmap>(2)."
1871 msgstr ""
1872
1873 #. type: Plain text
1874 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1875 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1876 msgid ""
1877 "Events for directories are created only if the directory itself is opened, "
1878 "read, and closed. Adding, removing, or changing children of a marked "
1879 "directory does not create events for the monitored directory itself."
1880 msgstr ""
1881
1882 #. type: Plain text
1883 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1884 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1885 msgid ""
1886 "Fanotify monitoring of directories is not recursive: to monitor "
1887 "subdirectories under a directory, additional marks must be created. The "
1888 "B<FAN_CREATE> event can be used for detecting when a subdirectory has been "
1889 "created under a marked directory. An additional mark must then be set on "
1890 "the newly created subdirectory. This approach is racy, because it can lose "
1891 "events that occurred inside the newly created subdirectory, before a mark is "
1892 "added on that subdirectory. Monitoring mounts offers the capability to "
1893 "monitor a whole directory tree in a race-free manner. Monitoring "
1894 "filesystems offers the capability to monitor changes made from any mount of "
1895 "a filesystem instance in a race-free manner."
1896 msgstr ""
1897
1898 #. type: Plain text
1899 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1900 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1901 msgid "The event queue can overflow. In this case, events are lost."
1902 msgstr ""
1903
1904 #. type: SH
1905 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1906 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1907 #, no-wrap
1908 msgid "BUGS"
1909 msgstr "ERRORES"
1910
1911 #. commit 820c12d5d6c0890bc93dd63893924a13041fdc35
1912 #. type: Plain text
1913 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1914 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1915 msgid ""
1916 "Before Linux 3.19, B<fallocate>(2) did not generate fanotify events. Since "
1917 "Linux 3.19, calls to B<fallocate>(2) generate B<FAN_MODIFY> events."
1918 msgstr ""
1919
1920 #. type: Plain text
1921 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1922 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1923 msgid "As of Linux 3.17, the following bugs exist:"
1924 msgstr ""
1925
1926 #. type: IP
1927 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1928 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1929 #, no-wrap
1930 msgid "\\[bu]"
1931 msgstr "\\[bu]"
1932
1933 #. type: Plain text
1934 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1935 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1936 msgid ""
1937 "On Linux, a filesystem object may be accessible through multiple paths, for "
1938 "example, a part of a filesystem may be remounted using the I<--bind> option "
1939 "of B<mount>(8). A listener that marked a mount will be notified only of "
1940 "events that were triggered for a filesystem object using the same mount. "
1941 "Any other event will pass unnoticed."
1942 msgstr ""
1943
1944 #. FIXME . A patch was proposed.
1945 #. type: Plain text
1946 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1947 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1948 msgid ""
1949 "When an event is generated, no check is made to see whether the user ID of "
1950 "the receiving process has authorization to read or write the file before "
1951 "passing a file descriptor for that file. This poses a security risk, when "
1952 "the B<CAP_SYS_ADMIN> capability is set for programs executed by unprivileged "
1953 "users."
1954 msgstr ""
1955
1956 #. type: Plain text
1957 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
1958 #: opensuse-leap-16-1 opensuse-tumbleweed
1959 msgid ""
1960 "If a call to B<read>(2) processes multiple events from the fanotify queue "
1961 "and an error occurs, the return value will be the total size of the events "
1962 "successfully copied to the user-space buffer before the error occurred. The "
1963 "return value will not be -1, and I<errno> will not be set. Thus, the "
1964 "reading application has no way to detect the error."
1965 msgstr ""
1966
1967 #. type: SH
1968 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1969 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1970 #, no-wrap
1971 msgid "EXAMPLES"
1972 msgstr "EJEMPLOS"
1973
1974 #. type: Plain text
1975 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1976 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1977 msgid ""
1978 "The two example programs below demonstrate the usage of the fanotify API."
1979 msgstr ""
1980
1981 #. type: SS
1982 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1983 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1984 #, no-wrap
1985 msgid "Example program: fanotify_example.c"
1986 msgstr ""
1987
1988 #. type: Plain text
1989 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
1990 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
1991 msgid ""
1992 "The first program is an example of fanotify being used with its event object "
1993 "information passed in the form of a file descriptor. The program marks the "
1994 "mount passed as a command-line argument and waits for events of type "
1995 "B<FAN_OPEN_PERM> and B<FAN_CLOSE_WRITE>. When a permission event occurs, a "
1996 "B<FAN_ALLOW> response is given."
1997 msgstr ""
1998
1999 #. type: Plain text
2000 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2001 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2002 msgid ""
2003 "The following shell session shows an example of running this program. This "
2004 "session involved editing the file I</home/user/temp/notes>. Before the file "
2005 "was opened, a B<FAN_OPEN_PERM> event occurred. After the file was closed, a "
2006 "B<FAN_CLOSE_WRITE> event occurred. Execution of the program ends when the "
2007 "user presses the ENTER key."
2008 msgstr ""
2009
2010 #. type: Plain text
2011 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
2012 #: opensuse-tumbleweed
2013 #, no-wrap
2014 msgid ""
2015 "#B< ./fanotify_example /home>;\n"
2016 "Press enter key to terminate.\n"
2017 "Listening for events.\n"
2018 "FAN_OPEN_PERM: File /home/user/temp/notes\n"
2019 "FAN_CLOSE_WRITE: File /home/user/temp/notes\n"
2020 "\\&\n"
2021 "Listening for events stopped.\n"
2022 msgstr ""
2023
2024 #. type: SS
2025 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2026 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2027 #, no-wrap
2028 msgid "Program source: fanotify_example.c"
2029 msgstr ""
2030
2031 #. type: Plain text
2032 #: archlinux debian-unstable opensuse-leap-16-1 opensuse-tumbleweed
2033 #, no-wrap
2034 msgid ""
2035 "#define _GNU_SOURCE /* Needed to get O_LARGEFILE definition */\n"
2036 "#include E<lt>errno.hE<gt>\n"
2037 "#include E<lt>fcntl.hE<gt>\n"
2038 "#include E<lt>limits.hE<gt>\n"
2039 "#include E<lt>poll.hE<gt>\n"
2040 "#include E<lt>stdio.hE<gt>\n"
2041 "#include E<lt>stdlib.hE<gt>\n"
2042 "#include E<lt>sys/fanotify.hE<gt>\n"
2043 "#include E<lt>unistd.hE<gt>\n"
2044 "\\&\n"
2045 "/* Read all available fanotify events from the file descriptor \\[aq]fd\\[aq]. */\n"
2046 "\\&\n"
2047 "static void\n"
2048 "handle_events(int fd)\n"
2049 "{\n"
2050 " const struct fanotify_event_metadata *metadata;\n"
2051 " struct fanotify_event_metadata buf[200];\n"
2052 " ssize_t size;\n"
2053 " char path[PATH_MAX];\n"
2054 " ssize_t path_len;\n"
2055 " char procfd_path[PATH_MAX];\n"
2056 " struct fanotify_response response;\n"
2057 "\\&\n"
2058 " /* Loop while events can be read from fanotify file descriptor. */\n"
2059 "\\&\n"
2060 " for (;;) {\n"
2061 "\\&\n"
2062 " /* Read some events. */\n"
2063 "\\&\n"
2064 " size = read(fd, buf, sizeof(buf));\n"
2065 " if (size == -1 && errno != EAGAIN) {\n"
2066 " perror(\"read\");\n"
2067 " exit(EXIT_FAILURE);\n"
2068 " }\n"
2069 "\\&\n"
2070 " /* Check if end of available data reached. */\n"
2071 "\\&\n"
2072 " if (size E<lt>= 0)\n"
2073 " break;\n"
2074 "\\&\n"
2075 " /* Point to the first event in the buffer. */\n"
2076 "\\&\n"
2077 " metadata = buf;\n"
2078 "\\&\n"
2079 " /* Loop over all events in the buffer. */\n"
2080 "\\&\n"
2081 " while (FAN_EVENT_OK(metadata, size)) {\n"
2082 "\\&\n"
2083 " /* Check that run-time and compile-time structures match. */\n"
2084 "\\&\n"
2085 " if (metadata-E<gt>vers != FANOTIFY_METADATA_VERSION) {\n"
2086 " fprintf(stderr,\n"
2087 " \"Mismatch of fanotify metadata version.\\[rs]n\");\n"
2088 " exit(EXIT_FAILURE);\n"
2089 " }\n"
2090 "\\&\n"
2091 " /* metadata-E<gt>fd contains either FAN_NOFD, indicating a\n"
2092 " queue overflow, or a file descriptor (a nonnegative\n"
2093 " integer). Here, we simply ignore queue overflow. */\n"
2094 "\\&\n"
2095 " if (metadata-E<gt>fd E<gt>= 0) {\n"
2096 "\\&\n"
2097 " /* Handle open permission event. */\n"
2098 "\\&\n"
2099 " if (metadata-E<gt>mask & FAN_OPEN_PERM) {\n"
2100 " printf(\"FAN_OPEN_PERM: \");\n"
2101 "\\&\n"
2102 " /* Allow file to be opened. */\n"
2103 "\\&\n"
2104 " response.fd = metadata-E<gt>fd;\n"
2105 " response.response = FAN_ALLOW;\n"
2106 " write(fd, &response, sizeof(response));\n"
2107 " }\n"
2108 "\\&\n"
2109 " /* Handle closing of writable file event. */\n"
2110 "\\&\n"
2111 " if (metadata-E<gt>mask & FAN_CLOSE_WRITE)\n"
2112 " printf(\"FAN_CLOSE_WRITE: \");\n"
2113 "\\&\n"
2114 " /* Retrieve and print pathname of the accessed file. */\n"
2115 "\\&\n"
2116 " snprintf(procfd_path, sizeof(procfd_path),\n"
2117 " \"/proc/self/fd/%d\", metadata-E<gt>fd);\n"
2118 " path_len = readlink(procfd_path, path,\n"
2119 " sizeof(path) - 1);\n"
2120 " if (path_len == -1) {\n"
2121 " perror(\"readlink\");\n"
2122 " exit(EXIT_FAILURE);\n"
2123 " }\n"
2124 "\\&\n"
2125 " path[path_len] = \\[aq]\\[rs]0\\[aq];\n"
2126 " printf(\"File %s\\[rs]n\", path);\n"
2127 "\\&\n"
2128 " /* Close the file descriptor of the event. */\n"
2129 "\\&\n"
2130 " close(metadata-E<gt>fd);\n"
2131 " }\n"
2132 "\\&\n"
2133 " /* Advance to next event. */\n"
2134 "\\&\n"
2135 " metadata = FAN_EVENT_NEXT(metadata, size);\n"
2136 " }\n"
2137 " }\n"
2138 "}\n"
2139 "\\&\n"
2140 "int\n"
2141 "main(int argc, char *argv[])\n"
2142 "{\n"
2143 " char buf;\n"
2144 " int fd, poll_num;\n"
2145 " nfds_t nfds;\n"
2146 " struct pollfd fds[2];\n"
2147 "\\&\n"
2148 " /* Check mount point is supplied. */\n"
2149 "\\&\n"
2150 " if (argc != 2) {\n"
2151 " fprintf(stderr, \"Usage: %s MOUNT\\[rs]n\", argv[0]);\n"
2152 " exit(EXIT_FAILURE);\n"
2153 " }\n"
2154 "\\&\n"
2155 " printf(\"Press enter key to terminate.\\[rs]n\");\n"
2156 "\\&\n"
2157 " /* Create the file descriptor for accessing the fanotify API. */\n"
2158 "\\&\n"
2159 " fd = fanotify_init(FAN_CLOEXEC | FAN_CLASS_CONTENT | FAN_NONBLOCK,\n"
2160 " O_RDONLY | O_LARGEFILE);\n"
2161 " if (fd == -1) {\n"
2162 " perror(\"fanotify_init\");\n"
2163 " exit(EXIT_FAILURE);\n"
2164 " }\n"
2165 "\\&\n"
2166 " /* Mark the mount for:\n"
2167 " - permission events before opening files\n"
2168 " - notification events after closing a write-enabled\n"
2169 " file descriptor. */\n"
2170 "\\&\n"
2171 " if (fanotify_mark(fd, FAN_MARK_ADD | FAN_MARK_MOUNT,\n"
2172 " FAN_OPEN_PERM | FAN_CLOSE_WRITE, AT_FDCWD,\n"
2173 " argv[1]) == -1) {\n"
2174 " perror(\"fanotify_mark\");\n"
2175 " exit(EXIT_FAILURE);\n"
2176 " }\n"
2177 "\\&\n"
2178 " /* Prepare for polling. */\n"
2179 "\\&\n"
2180 " nfds = 2;\n"
2181 "\\&\n"
2182 " fds[0].fd = STDIN_FILENO; /* Console input */\n"
2183 " fds[0].events = POLLIN;\n"
2184 "\\&\n"
2185 " fds[1].fd = fd; /* Fanotify input */\n"
2186 " fds[1].events = POLLIN;\n"
2187 "\\&\n"
2188 " /* This is the loop to wait for incoming events. */\n"
2189 "\\&\n"
2190 " printf(\"Listening for events.\\[rs]n\");\n"
2191 "\\&\n"
2192 " for (;;) {\n"
2193 " poll_num = poll(fds, nfds, -1);\n"
2194 " if (poll_num == -1) {\n"
2195 " if (errno == EINTR) /* Interrupted by a signal */\n"
2196 " continue; /* Restart poll() */\n"
2197 "\\&\n"
2198 " perror(\"poll\"); /* Unexpected error */\n"
2199 " exit(EXIT_FAILURE);\n"
2200 " }\n"
2201 "\\&\n"
2202 " if (poll_num E<gt> 0) {\n"
2203 " if (fds[0].revents & POLLIN) {\n"
2204 "\\&\n"
2205 " /* Console input is available: empty stdin and quit. */\n"
2206 "\\&\n"
2207 " while (read(STDIN_FILENO, &buf, 1) E<gt> 0 && buf != \\[aq]\\[rs]n\\[aq])\n"
2208 " continue;\n"
2209 " break;\n"
2210 " }\n"
2211 "\\&\n"
2212 " if (fds[1].revents & POLLIN) {\n"
2213 "\\&\n"
2214 " /* Fanotify events are available. */\n"
2215 "\\&\n"
2216 " handle_events(fd);\n"
2217 " }\n"
2218 " }\n"
2219 " }\n"
2220 "\\&\n"
2221 " printf(\"Listening for events stopped.\\[rs]n\");\n"
2222 " exit(EXIT_SUCCESS);\n"
2223 "}\n"
2224 msgstr ""
2225
2226 #. type: SS
2227 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2228 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2229 #, no-wrap
2230 msgid "Example program: fanotify_fid.c"
2231 msgstr ""
2232
2233 #. type: Plain text
2234 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2235 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2236 msgid ""
2237 "The second program is an example of fanotify being used with a group that "
2238 "identifies objects by file handles. The program marks the filesystem object "
2239 "that is passed as a command-line argument and waits until an event of type "
2240 "B<FAN_CREATE> has occurred. The event mask indicates which type of "
2241 "filesystem object\\[em]either a file or a directory\\[em]was created. Once "
2242 "all events have been read from the buffer and processed accordingly, the "
2243 "program simply terminates."
2244 msgstr ""
2245
2246 #. type: Plain text
2247 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2248 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2249 msgid ""
2250 "The following shell sessions show two different invocations of this program, "
2251 "with different actions performed on a watched object."
2252 msgstr ""
2253
2254 #. type: Plain text
2255 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2256 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2257 msgid ""
2258 "The first session shows a mark being placed on I</home/user>. This is "
2259 "followed by the creation of a regular file, I</home/user/testfile.txt>. "
2260 "This results in a B<FAN_CREATE> event being generated and reported against "
2261 "the file's parent watched directory object and with the created file name. "
2262 "Program execution ends once all events captured within the buffer have been "
2263 "processed."
2264 msgstr ""
2265
2266 #. type: Plain text
2267 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
2268 #: opensuse-tumbleweed
2269 #, no-wrap
2270 msgid ""
2271 "#B< ./fanotify_fid /home/user>;\n"
2272 "Listening for events.\n"
2273 "FAN_CREATE (file created):\n"
2274 " Directory /home/user has been modified.\n"
2275 " Entry \\[aq]testfile.txt\\[aq] is not a subdirectory.\n"
2276 "All events processed successfully. Program exiting.\n"
2277 "\\&\n"
2278 "$B< touch /home/user/testfile.txt>; # In another terminal\n"
2279 msgstr ""
2280
2281 #. type: Plain text
2282 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2283 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2284 msgid ""
2285 "The second session shows a mark being placed on I</home/user>. This is "
2286 "followed by the creation of a directory, I</home/user/testdir>. This "
2287 "specific action results in a B<FAN_CREATE> event being generated and is "
2288 "reported with the B<FAN_ONDIR> flag set and with the created directory name."
2289 msgstr ""
2290
2291 #. type: Plain text
2292 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
2293 #: opensuse-tumbleweed
2294 #, no-wrap
2295 msgid ""
2296 "#B< ./fanotify_fid /home/user>;\n"
2297 "Listening for events.\n"
2298 "FAN_CREATE | FAN_ONDIR (subdirectory created):\n"
2299 " Directory /home/user has been modified.\n"
2300 " Entry \\[aq]testdir\\[aq] is a subdirectory.\n"
2301 "All events processed successfully. Program exiting.\n"
2302 "\\&\n"
2303 "$B< mkdir -p /home/user/testdir>; # In another terminal\n"
2304 msgstr ""
2305
2306 #. type: SS
2307 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2308 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2309 #, no-wrap
2310 msgid "Program source: fanotify_fid.c"
2311 msgstr ""
2312
2313 #. type: Plain text
2314 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
2315 #: opensuse-tumbleweed
2316 #, no-wrap
2317 msgid ""
2318 "#define _GNU_SOURCE\n"
2319 "#include E<lt>errno.hE<gt>\n"
2320 "#include E<lt>fcntl.hE<gt>\n"
2321 "#include E<lt>limits.hE<gt>\n"
2322 "#include E<lt>stdio.hE<gt>\n"
2323 "#include E<lt>stdlib.hE<gt>\n"
2324 "#include E<lt>sys/types.hE<gt>\n"
2325 "#include E<lt>sys/stat.hE<gt>\n"
2326 "#include E<lt>sys/fanotify.hE<gt>\n"
2327 "#include E<lt>unistd.hE<gt>\n"
2328 "\\&\n"
2329 "#define BUF_SIZE 256\n"
2330 "\\&\n"
2331 "int\n"
2332 "main(int argc, char *argv[])\n"
2333 "{\n"
2334 " int fd, ret, event_fd, mount_fd;\n"
2335 " ssize_t size, path_len;\n"
2336 " char path[PATH_MAX];\n"
2337 " char procfd_path[PATH_MAX];\n"
2338 " char events_buf[BUF_SIZE];\n"
2339 " struct file_handle *file_handle;\n"
2340 " struct fanotify_event_metadata *metadata;\n"
2341 " struct fanotify_event_info_fid *fid;\n"
2342 " const char *file_name;\n"
2343 " struct stat sb;\n"
2344 "\\&\n"
2345 " if (argc != 2) {\n"
2346 " fprintf(stderr, \"Invalid number of command line arguments.\\[rs]n\");\n"
2347 " exit(EXIT_FAILURE);\n"
2348 " }\n"
2349 "\\&\n"
2350 " mount_fd = open(argv[1], O_DIRECTORY | O_RDONLY);\n"
2351 " if (mount_fd == -1) {\n"
2352 " perror(argv[1]);\n"
2353 " exit(EXIT_FAILURE);\n"
2354 " }\n"
2355 "\\&\n"
2356 " /* Create an fanotify file descriptor with FAN_REPORT_DFID_NAME as\n"
2357 " a flag so that program can receive fid events with directory\n"
2358 " entry name. */\n"
2359 "\\&\n"
2360 " fd = fanotify_init(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME, 0);\n"
2361 " if (fd == -1) {\n"
2362 " perror(\"fanotify_init\");\n"
2363 " exit(EXIT_FAILURE);\n"
2364 " }\n"
2365 "\\&\n"
2366 " /* Place a mark on the filesystem object supplied in argv[1]. */\n"
2367 "\\&\n"
2368 " ret = fanotify_mark(fd, FAN_MARK_ADD | FAN_MARK_ONLYDIR,\n"
2369 " FAN_CREATE | FAN_ONDIR,\n"
2370 " AT_FDCWD, argv[1]);\n"
2371 " if (ret == -1) {\n"
2372 " perror(\"fanotify_mark\");\n"
2373 " exit(EXIT_FAILURE);\n"
2374 " }\n"
2375 "\\&\n"
2376 " printf(\"Listening for events.\\[rs]n\");\n"
2377 "\\&\n"
2378 " /* Read events from the event queue into a buffer. */\n"
2379 "\\&\n"
2380 " size = read(fd, events_buf, sizeof(events_buf));\n"
2381 " if (size == -1 && errno != EAGAIN) {\n"
2382 " perror(\"read\");\n"
2383 " exit(EXIT_FAILURE);\n"
2384 " }\n"
2385 "\\&\n"
2386 " /* Process all events within the buffer. */\n"
2387 "\\&\n"
2388 " for (metadata = (struct fanotify_event_metadata *) events_buf;\n"
2389 " FAN_EVENT_OK(metadata, size);\n"
2390 " metadata = FAN_EVENT_NEXT(metadata, size)) {\n"
2391 " fid = (struct fanotify_event_info_fid *) (metadata + 1);\n"
2392 " file_handle = (struct file_handle *) fid-E<gt>handle;\n"
2393 "\\&\n"
2394 " /* Ensure that the event info is of the correct type. */\n"
2395 "\\&\n"
2396 " if (fid-E<gt>hdr.info_type == FAN_EVENT_INFO_TYPE_FID ||\n"
2397 " fid-E<gt>hdr.info_type == FAN_EVENT_INFO_TYPE_DFID) {\n"
2398 " file_name = NULL;\n"
2399 " } else if (fid-E<gt>hdr.info_type == FAN_EVENT_INFO_TYPE_DFID_NAME) {\n"
2400 " file_name = file_handle-E<gt>f_handle +\n"
2401 " file_handle-E<gt>handle_bytes;\n"
2402 " } else {\n"
2403 " fprintf(stderr, \"Received unexpected event info type.\\[rs]n\");\n"
2404 " exit(EXIT_FAILURE);\n"
2405 " }\n"
2406 "\\&\n"
2407 " if (metadata-E<gt>mask == FAN_CREATE)\n"
2408 " printf(\"FAN_CREATE (file created):\\[rs]n\");\n"
2409 "\\&\n"
2410 " if (metadata-E<gt>mask == (FAN_CREATE | FAN_ONDIR))\n"
2411 " printf(\"FAN_CREATE | FAN_ONDIR (subdirectory created):\\[rs]n\");\n"
2412 "\\&\n"
2413 "\t/* metadata-E<gt>fd is set to FAN_NOFD when the group identifies\n"
2414 "\t objects by file handles. To obtain a file descriptor for\n"
2415 "\t the file object corresponding to an event you can use the\n"
2416 "\t struct file_handle that\\[aq]s provided within the\n"
2417 "\t fanotify_event_info_fid in conjunction with the\n"
2418 "\t open_by_handle_at(2) system call. A check for ESTALE is\n"
2419 "\t done to accommodate for the situation where the file handle\n"
2420 "\t for the object was deleted prior to this system call. */\n"
2421 "\\&\n"
2422 " event_fd = open_by_handle_at(mount_fd, file_handle, O_RDONLY);\n"
2423 " if (event_fd == -1) {\n"
2424 " if (errno == ESTALE) {\n"
2425 " printf(\"File handle is no longer valid. \"\n"
2426 " \"File has been deleted\\[rs]n\");\n"
2427 " continue;\n"
2428 " } else {\n"
2429 " perror(\"open_by_handle_at\");\n"
2430 " exit(EXIT_FAILURE);\n"
2431 " }\n"
2432 " }\n"
2433 "\\&\n"
2434 " snprintf(procfd_path, sizeof(procfd_path), \"/proc/self/fd/%d\",\n"
2435 " event_fd);\n"
2436 "\\&\n"
2437 " /* Retrieve and print the path of the modified dentry. */\n"
2438 "\\&\n"
2439 " path_len = readlink(procfd_path, path, sizeof(path) - 1);\n"
2440 " if (path_len == -1) {\n"
2441 " perror(\"readlink\");\n"
2442 " exit(EXIT_FAILURE);\n"
2443 " }\n"
2444 "\\&\n"
2445 " path[path_len] = \\[aq]\\[rs]0\\[aq];\n"
2446 " printf(\"\\[rs]tDirectory \\[aq]%s\\[aq] has been modified.\\[rs]n\", path);\n"
2447 "\\&\n"
2448 " if (file_name) {\n"
2449 " ret = fstatat(event_fd, file_name, &sb, 0);\n"
2450 " if (ret == -1) {\n"
2451 " if (errno != ENOENT) {\n"
2452 " perror(\"fstatat\");\n"
2453 " exit(EXIT_FAILURE);\n"
2454 " }\n"
2455 " printf(\"\\[rs]tEntry \\[aq]%s\\[aq] does not exist.\\[rs]n\", file_name);\n"
2456 " } else if ((sb.st_mode & S_IFMT) == S_IFDIR) {\n"
2457 " printf(\"\\[rs]tEntry \\[aq]%s\\[aq] is a subdirectory.\\[rs]n\", file_name);\n"
2458 " } else {\n"
2459 " printf(\"\\[rs]tEntry \\[aq]%s\\[aq] is not a subdirectory.\\[rs]n\",\n"
2460 " file_name);\n"
2461 " }\n"
2462 " }\n"
2463 "\\&\n"
2464 " /* Close associated file descriptor for this event. */\n"
2465 "\\&\n"
2466 " close(event_fd);\n"
2467 " }\n"
2468 "\\&\n"
2469 " printf(\"All events processed successfully. Program exiting.\\[rs]n\");\n"
2470 " exit(EXIT_SUCCESS);\n"
2471 "}\n"
2472 msgstr ""
2473
2474 #. type: SH
2475 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2476 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2477 #, no-wrap
2478 msgid "SEE ALSO"
2479 msgstr "VÉASE TAMBIÉN"
2480
2481 #. type: Plain text
2482 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
2483 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
2484 msgid "B<fanotify_init>(2), B<fanotify_mark>(2), B<inotify>(7)"
2485 msgstr ""
2486
2487 #. type: TH
2488 #: debian-trixie
2489 #, no-wrap
2490 msgid "2024-06-15"
2491 msgstr "15 Junio 2024"
2492
2493 #. type: TH
2494 #: debian-trixie
2495 #, no-wrap
2496 msgid "Linux man-pages 6.9.1"
2497 msgstr "Páginas de Manual de Linux 6.9.1"
2498
2499 #. type: Plain text
2500 #: debian-trixie
2501 msgid ""
2502 "This is the length of the data for the current event and the offset to the "
2503 "next event in the buffer. Unless the group identifies filesystem objects by "
2504 "file handles, the value of I<event_len> is always "
2505 "B<FAN_EVENT_METADATA_LEN>. For a group that identifies filesystem objects "
2506 "by file handles, I<event_len> also includes the variable length file "
2507 "identifier records."
2508 msgstr ""
2509
2510 #. type: Plain text
2511 #: debian-trixie
2512 msgid ""
2513 "This is the length of the structure. The field was introduced to facilitate "
2514 "the implementation of optional headers per event type. No such optional "
2515 "headers exist in the current implementation."
2516 msgstr ""
2517
2518 #. type: Plain text
2519 #: debian-trixie fedora-44 fedora-rawhide
2520 msgid ""
2521 "A unique integer value representing the type of information record object "
2522 "received for an event. The value of this field can be set to one of the "
2523 "following: B<FAN_EVENT_INFO_TYPE_FID>, B<FAN_EVENT_INFO_TYPE_DFID>, "
2524 "B<FAN_EVENT_INFO_TYPE_DFID_NAME>, or B<FAN_EVENT_INFO_TYPE_PIDFD>. The "
2525 "value set for this field is dependent on the flags that have been supplied "
2526 "to B<fanotify_init>(2). Refer to the field details of each information "
2527 "record object type below to understand the different cases in which the "
2528 "I<info_type> values can be set."
2529 msgstr ""
2530
2531 #. type: Plain text
2532 #: debian-trixie
2533 msgid ""
2534 "This is a unique identifier of the filesystem containing the object "
2535 "associated with the event. It is a structure of type I<__kernel_fsid_t> and "
2536 "contains the same value as I<f_fsid> when calling B<statfs>(2)."
2537 msgstr ""
2538
2539 #. type: Plain text
2540 #: debian-trixie
2541 msgid ""
2542 "This field contains a variable-length structure of type I<struct "
2543 "file_handle>. It is an opaque handle that corresponds to a specified object "
2544 "on a filesystem as returned by B<name_to_handle_at>(2). It can be used to "
2545 "uniquely identify a file on a filesystem and can be passed as an argument to "
2546 "B<open_by_handle_at>(2). If the value of I<info_type> field is "
2547 "B<FAN_EVENT_INFO_TYPE_DFID_NAME>, the file handle is followed by a null "
2548 "terminated string that identifies the created/deleted/moved directory entry "
2549 "name. For other events such as B<FAN_OPEN>, B<FAN_ATTRIB>, "
2550 "B<FAN_DELETE_SELF>, and B<FAN_MOVE_SELF>, if the value of I<info_type> field "
2551 "is B<FAN_EVENT_INFO_TYPE_FID>, the I<handle> identifies the object "
2552 "correlated to the event. If the value of I<info_type> field is "
2553 "B<FAN_EVENT_INFO_TYPE_DFID>, the I<handle> identifies the directory object "
2554 "correlated to the event or the parent directory of a non-directory object "
2555 "correlated to the event. If the value of I<info_type> field is "
2556 "B<FAN_EVENT_INFO_TYPE_DFID_NAME>, the I<handle> identifies the same "
2557 "directory object that would be reported with B<FAN_EVENT_INFO_TYPE_DFID> and "
2558 "the file handle is followed by a null terminated string that identifies the "
2559 "name of a directory entry in that directory, or '.' to identify the "
2560 "directory object itself."
2561 msgstr ""
2562
2563 #. type: TP
2564 #: debian-trixie
2565 #, no-wrap
2566 msgid "B<FAN_EVENT_OK(meta, len)>"
2567 msgstr ""
2568
2569 #. type: Plain text
2570 #: debian-trixie
2571 msgid ""
2572 "This macro checks the remaining length I<len> of the buffer I<meta> against "
2573 "the length of the metadata structure and the I<event_len> field of the first "
2574 "metadata structure in the buffer."
2575 msgstr ""
2576
2577 #. type: TP
2578 #: debian-trixie
2579 #, no-wrap
2580 msgid "B<FAN_EVENT_NEXT(meta, len)>"
2581 msgstr ""
2582
2583 #. type: Plain text
2584 #: debian-trixie
2585 msgid ""
2586 "This macro uses the length indicated in the I<event_len> field of the "
2587 "metadata structure pointed to by I<meta> to calculate the address of the "
2588 "next metadata structure that follows I<meta>. I<len> is the number of bytes "
2589 "of metadata that currently remain in the buffer. The macro returns a "
2590 "pointer to the next metadata structure that follows I<meta>, and reduces "
2591 "I<len> by the number of bytes in the metadata structure that has been "
2592 "skipped over (i.e., it subtracts I<meta-E<gt>event_len> from I<len>)."
2593 msgstr ""
2594
2595 #. type: Plain text
2596 #: debian-trixie fedora-44 fedora-rawhide
2597 msgid ""
2598 "This field indicates whether or not the permission is to be granted. Its "
2599 "value must be either B<FAN_ALLOW> to allow the file operation or B<FAN_DENY> "
2600 "to deny the file operation."
2601 msgstr ""
2602
2603 #. type: Plain text
2604 #: debian-trixie fedora-44 fedora-rawhide
2605 msgid ""
2606 "If access is denied, the requesting application call will receive an "
2607 "B<EPERM> error. Additionally, if the notification group has been created "
2608 "with the B<FAN_ENABLE_AUDIT> flag, then the B<FAN_AUDIT> flag can be set in "
2609 "the I<response> field. In that case, the audit subsystem will log "
2610 "information about the access decision to the audit logs."
2611 msgstr ""
2612
2613 #. type: Plain text
2614 #: debian-trixie fedora-44 fedora-rawhide
2615 msgid ""
2616 "Errors not directly related to a file (i.e. super block corruption) are "
2617 "reported with an invalid I<handle>. For these errors, the I<handle> will "
2618 "have the field I<handle_type> set to B<FILEID_INVALID>, and the handle "
2619 "buffer size set to B<0>."
2620 msgstr ""
2621
2622 #. commit 5b8fea65d197f408bb00b251c70d842826d6b70b
2623 #. type: Plain text
2624 #: debian-trixie
2625 msgid ""
2626 "Since Linux 5.13, the following interfaces can be used to control the amount "
2627 "of kernel resources consumed by fanotify:"
2628 msgstr ""
2629
2630 #. type: Plain text
2631 #: debian-trixie
2632 msgid ""
2633 "If a call to B<read>(2) processes multiple events from the fanotify queue "
2634 "and an error occurs, the return value will be the total length of the events "
2635 "successfully copied to the user-space buffer before the error occurred. The "
2636 "return value will not be -1, and I<errno> will not be set. Thus, the "
2637 "reading application has no way to detect the error."
2638 msgstr ""
2639
2640 #. type: Plain text
2641 #: debian-trixie fedora-44 fedora-rawhide
2642 #, no-wrap
2643 msgid ""
2644 "# B<./fanotify_example /home>\n"
2645 "Press enter key to terminate.\n"
2646 "Listening for events.\n"
2647 "FAN_OPEN_PERM: File /home/user/temp/notes\n"
2648 "FAN_CLOSE_WRITE: File /home/user/temp/notes\n"
2649 "\\&\n"
2650 "Listening for events stopped.\n"
2651 msgstr ""
2652
2653 #. type: Plain text
2654 #: debian-trixie
2655 #, no-wrap
2656 msgid ""
2657 "#define _GNU_SOURCE /* Needed to get O_LARGEFILE definition */\n"
2658 "#include E<lt>errno.hE<gt>\n"
2659 "#include E<lt>fcntl.hE<gt>\n"
2660 "#include E<lt>limits.hE<gt>\n"
2661 "#include E<lt>poll.hE<gt>\n"
2662 "#include E<lt>stdio.hE<gt>\n"
2663 "#include E<lt>stdlib.hE<gt>\n"
2664 "#include E<lt>sys/fanotify.hE<gt>\n"
2665 "#include E<lt>unistd.hE<gt>\n"
2666 "\\&\n"
2667 "/* Read all available fanotify events from the file descriptor \\[aq]fd\\[aq]. */\n"
2668 "\\&\n"
2669 "static void\n"
2670 "handle_events(int fd)\n"
2671 "{\n"
2672 " const struct fanotify_event_metadata *metadata;\n"
2673 " struct fanotify_event_metadata buf[200];\n"
2674 " ssize_t len;\n"
2675 " char path[PATH_MAX];\n"
2676 " ssize_t path_len;\n"
2677 " char procfd_path[PATH_MAX];\n"
2678 " struct fanotify_response response;\n"
2679 "\\&\n"
2680 " /* Loop while events can be read from fanotify file descriptor. */\n"
2681 "\\&\n"
2682 " for (;;) {\n"
2683 "\\&\n"
2684 " /* Read some events. */\n"
2685 "\\&\n"
2686 " len = read(fd, buf, sizeof(buf));\n"
2687 " if (len == -1 && errno != EAGAIN) {\n"
2688 " perror(\"read\");\n"
2689 " exit(EXIT_FAILURE);\n"
2690 " }\n"
2691 "\\&\n"
2692 " /* Check if end of available data reached. */\n"
2693 "\\&\n"
2694 " if (len E<lt>= 0)\n"
2695 " break;\n"
2696 "\\&\n"
2697 " /* Point to the first event in the buffer. */\n"
2698 "\\&\n"
2699 " metadata = buf;\n"
2700 "\\&\n"
2701 " /* Loop over all events in the buffer. */\n"
2702 "\\&\n"
2703 " while (FAN_EVENT_OK(metadata, len)) {\n"
2704 "\\&\n"
2705 " /* Check that run-time and compile-time structures match. */\n"
2706 "\\&\n"
2707 " if (metadata-E<gt>vers != FANOTIFY_METADATA_VERSION) {\n"
2708 " fprintf(stderr,\n"
2709 " \"Mismatch of fanotify metadata version.\\[rs]n\");\n"
2710 " exit(EXIT_FAILURE);\n"
2711 " }\n"
2712 "\\&\n"
2713 " /* metadata-E<gt>fd contains either FAN_NOFD, indicating a\n"
2714 " queue overflow, or a file descriptor (a nonnegative\n"
2715 " integer). Here, we simply ignore queue overflow. */\n"
2716 "\\&\n"
2717 " if (metadata-E<gt>fd E<gt>= 0) {\n"
2718 "\\&\n"
2719 " /* Handle open permission event. */\n"
2720 "\\&\n"
2721 " if (metadata-E<gt>mask & FAN_OPEN_PERM) {\n"
2722 " printf(\"FAN_OPEN_PERM: \");\n"
2723 "\\&\n"
2724 " /* Allow file to be opened. */\n"
2725 "\\&\n"
2726 " response.fd = metadata-E<gt>fd;\n"
2727 " response.response = FAN_ALLOW;\n"
2728 " write(fd, &response, sizeof(response));\n"
2729 " }\n"
2730 "\\&\n"
2731 " /* Handle closing of writable file event. */\n"
2732 "\\&\n"
2733 " if (metadata-E<gt>mask & FAN_CLOSE_WRITE)\n"
2734 " printf(\"FAN_CLOSE_WRITE: \");\n"
2735 "\\&\n"
2736 " /* Retrieve and print pathname of the accessed file. */\n"
2737 "\\&\n"
2738 " snprintf(procfd_path, sizeof(procfd_path),\n"
2739 " \"/proc/self/fd/%d\", metadata-E<gt>fd);\n"
2740 " path_len = readlink(procfd_path, path,\n"
2741 " sizeof(path) - 1);\n"
2742 " if (path_len == -1) {\n"
2743 " perror(\"readlink\");\n"
2744 " exit(EXIT_FAILURE);\n"
2745 " }\n"
2746 "\\&\n"
2747 " path[path_len] = \\[aq]\\[rs]0\\[aq];\n"
2748 " printf(\"File %s\\[rs]n\", path);\n"
2749 "\\&\n"
2750 " /* Close the file descriptor of the event. */\n"
2751 "\\&\n"
2752 " close(metadata-E<gt>fd);\n"
2753 " }\n"
2754 "\\&\n"
2755 " /* Advance to next event. */\n"
2756 "\\&\n"
2757 " metadata = FAN_EVENT_NEXT(metadata, len);\n"
2758 " }\n"
2759 " }\n"
2760 "}\n"
2761 "\\&\n"
2762 "int\n"
2763 "main(int argc, char *argv[])\n"
2764 "{\n"
2765 " char buf;\n"
2766 " int fd, poll_num;\n"
2767 " nfds_t nfds;\n"
2768 " struct pollfd fds[2];\n"
2769 "\\&\n"
2770 " /* Check mount point is supplied. */\n"
2771 "\\&\n"
2772 " if (argc != 2) {\n"
2773 " fprintf(stderr, \"Usage: %s MOUNT\\[rs]n\", argv[0]);\n"
2774 " exit(EXIT_FAILURE);\n"
2775 " }\n"
2776 "\\&\n"
2777 " printf(\"Press enter key to terminate.\\[rs]n\");\n"
2778 "\\&\n"
2779 " /* Create the file descriptor for accessing the fanotify API. */\n"
2780 "\\&\n"
2781 " fd = fanotify_init(FAN_CLOEXEC | FAN_CLASS_CONTENT | FAN_NONBLOCK,\n"
2782 " O_RDONLY | O_LARGEFILE);\n"
2783 " if (fd == -1) {\n"
2784 " perror(\"fanotify_init\");\n"
2785 " exit(EXIT_FAILURE);\n"
2786 " }\n"
2787 "\\&\n"
2788 " /* Mark the mount for:\n"
2789 " - permission events before opening files\n"
2790 " - notification events after closing a write-enabled\n"
2791 " file descriptor. */\n"
2792 "\\&\n"
2793 " if (fanotify_mark(fd, FAN_MARK_ADD | FAN_MARK_MOUNT,\n"
2794 " FAN_OPEN_PERM | FAN_CLOSE_WRITE, AT_FDCWD,\n"
2795 " argv[1]) == -1) {\n"
2796 " perror(\"fanotify_mark\");\n"
2797 " exit(EXIT_FAILURE);\n"
2798 " }\n"
2799 "\\&\n"
2800 " /* Prepare for polling. */\n"
2801 "\\&\n"
2802 " nfds = 2;\n"
2803 "\\&\n"
2804 " fds[0].fd = STDIN_FILENO; /* Console input */\n"
2805 " fds[0].events = POLLIN;\n"
2806 "\\&\n"
2807 " fds[1].fd = fd; /* Fanotify input */\n"
2808 " fds[1].events = POLLIN;\n"
2809 "\\&\n"
2810 " /* This is the loop to wait for incoming events. */\n"
2811 "\\&\n"
2812 " printf(\"Listening for events.\\[rs]n\");\n"
2813 "\\&\n"
2814 " while (1) {\n"
2815 " poll_num = poll(fds, nfds, -1);\n"
2816 " if (poll_num == -1) {\n"
2817 " if (errno == EINTR) /* Interrupted by a signal */\n"
2818 " continue; /* Restart poll() */\n"
2819 "\\&\n"
2820 " perror(\"poll\"); /* Unexpected error */\n"
2821 " exit(EXIT_FAILURE);\n"
2822 " }\n"
2823 "\\&\n"
2824 " if (poll_num E<gt> 0) {\n"
2825 " if (fds[0].revents & POLLIN) {\n"
2826 "\\&\n"
2827 " /* Console input is available: empty stdin and quit. */\n"
2828 "\\&\n"
2829 " while (read(STDIN_FILENO, &buf, 1) E<gt> 0 && buf != \\[aq]\\[rs]n\\[aq])\n"
2830 " continue;\n"
2831 " break;\n"
2832 " }\n"
2833 "\\&\n"
2834 " if (fds[1].revents & POLLIN) {\n"
2835 "\\&\n"
2836 " /* Fanotify events are available. */\n"
2837 "\\&\n"
2838 " handle_events(fd);\n"
2839 " }\n"
2840 " }\n"
2841 " }\n"
2842 "\\&\n"
2843 " printf(\"Listening for events stopped.\\[rs]n\");\n"
2844 " exit(EXIT_SUCCESS);\n"
2845 "}\n"
2846 msgstr ""
2847
2848 #. type: Plain text
2849 #: debian-trixie fedora-44 fedora-rawhide
2850 #, no-wrap
2851 msgid ""
2852 "# B<./fanotify_fid /home/user>\n"
2853 "Listening for events.\n"
2854 "FAN_CREATE (file created):\n"
2855 " Directory /home/user has been modified.\n"
2856 " Entry \\[aq]testfile.txt\\[aq] is not a subdirectory.\n"
2857 "All events processed successfully. Program exiting.\n"
2858 "\\&\n"
2859 "$ B<touch /home/user/testfile.txt> # In another terminal\n"
2860 msgstr ""
2861
2862 #. type: Plain text
2863 #: debian-trixie fedora-44 fedora-rawhide
2864 #, no-wrap
2865 msgid ""
2866 "# B<./fanotify_fid /home/user>\n"
2867 "Listening for events.\n"
2868 "FAN_CREATE | FAN_ONDIR (subdirectory created):\n"
2869 " Directory /home/user has been modified.\n"
2870 " Entry \\[aq]testdir\\[aq] is a subdirectory.\n"
2871 "All events processed successfully. Program exiting.\n"
2872 "\\&\n"
2873 "$ B<mkdir -p /home/user/testdir> # In another terminal\n"
2874 msgstr ""
2875
2876 #. type: Plain text
2877 #: debian-trixie
2878 #, no-wrap
2879 msgid ""
2880 "#define _GNU_SOURCE\n"
2881 "#include E<lt>errno.hE<gt>\n"
2882 "#include E<lt>fcntl.hE<gt>\n"
2883 "#include E<lt>limits.hE<gt>\n"
2884 "#include E<lt>stdio.hE<gt>\n"
2885 "#include E<lt>stdlib.hE<gt>\n"
2886 "#include E<lt>sys/types.hE<gt>\n"
2887 "#include E<lt>sys/stat.hE<gt>\n"
2888 "#include E<lt>sys/fanotify.hE<gt>\n"
2889 "#include E<lt>unistd.hE<gt>\n"
2890 "\\&\n"
2891 "#define BUF_SIZE 256\n"
2892 "\\&\n"
2893 "int\n"
2894 "main(int argc, char *argv[])\n"
2895 "{\n"
2896 " int fd, ret, event_fd, mount_fd;\n"
2897 " ssize_t len, path_len;\n"
2898 " char path[PATH_MAX];\n"
2899 " char procfd_path[PATH_MAX];\n"
2900 " char events_buf[BUF_SIZE];\n"
2901 " struct file_handle *file_handle;\n"
2902 " struct fanotify_event_metadata *metadata;\n"
2903 " struct fanotify_event_info_fid *fid;\n"
2904 " const char *file_name;\n"
2905 " struct stat sb;\n"
2906 "\\&\n"
2907 " if (argc != 2) {\n"
2908 " fprintf(stderr, \"Invalid number of command line arguments.\\[rs]n\");\n"
2909 " exit(EXIT_FAILURE);\n"
2910 " }\n"
2911 "\\&\n"
2912 " mount_fd = open(argv[1], O_DIRECTORY | O_RDONLY);\n"
2913 " if (mount_fd == -1) {\n"
2914 " perror(argv[1]);\n"
2915 " exit(EXIT_FAILURE);\n"
2916 " }\n"
2917 "\\&\n"
2918 " /* Create an fanotify file descriptor with FAN_REPORT_DFID_NAME as\n"
2919 " a flag so that program can receive fid events with directory\n"
2920 " entry name. */\n"
2921 "\\&\n"
2922 " fd = fanotify_init(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME, 0);\n"
2923 " if (fd == -1) {\n"
2924 " perror(\"fanotify_init\");\n"
2925 " exit(EXIT_FAILURE);\n"
2926 " }\n"
2927 "\\&\n"
2928 " /* Place a mark on the filesystem object supplied in argv[1]. */\n"
2929 "\\&\n"
2930 " ret = fanotify_mark(fd, FAN_MARK_ADD | FAN_MARK_ONLYDIR,\n"
2931 " FAN_CREATE | FAN_ONDIR,\n"
2932 " AT_FDCWD, argv[1]);\n"
2933 " if (ret == -1) {\n"
2934 " perror(\"fanotify_mark\");\n"
2935 " exit(EXIT_FAILURE);\n"
2936 " }\n"
2937 "\\&\n"
2938 " printf(\"Listening for events.\\[rs]n\");\n"
2939 "\\&\n"
2940 " /* Read events from the event queue into a buffer. */\n"
2941 "\\&\n"
2942 " len = read(fd, events_buf, sizeof(events_buf));\n"
2943 " if (len == -1 && errno != EAGAIN) {\n"
2944 " perror(\"read\");\n"
2945 " exit(EXIT_FAILURE);\n"
2946 " }\n"
2947 "\\&\n"
2948 " /* Process all events within the buffer. */\n"
2949 "\\&\n"
2950 " for (metadata = (struct fanotify_event_metadata *) events_buf;\n"
2951 " FAN_EVENT_OK(metadata, len);\n"
2952 " metadata = FAN_EVENT_NEXT(metadata, len)) {\n"
2953 " fid = (struct fanotify_event_info_fid *) (metadata + 1);\n"
2954 " file_handle = (struct file_handle *) fid-E<gt>handle;\n"
2955 "\\&\n"
2956 " /* Ensure that the event info is of the correct type. */\n"
2957 "\\&\n"
2958 " if (fid-E<gt>hdr.info_type == FAN_EVENT_INFO_TYPE_FID ||\n"
2959 " fid-E<gt>hdr.info_type == FAN_EVENT_INFO_TYPE_DFID) {\n"
2960 " file_name = NULL;\n"
2961 " } else if (fid-E<gt>hdr.info_type == FAN_EVENT_INFO_TYPE_DFID_NAME) {\n"
2962 " file_name = file_handle-E<gt>f_handle +\n"
2963 " file_handle-E<gt>handle_bytes;\n"
2964 " } else {\n"
2965 " fprintf(stderr, \"Received unexpected event info type.\\[rs]n\");\n"
2966 " exit(EXIT_FAILURE);\n"
2967 " }\n"
2968 "\\&\n"
2969 " if (metadata-E<gt>mask == FAN_CREATE)\n"
2970 " printf(\"FAN_CREATE (file created):\\[rs]n\");\n"
2971 "\\&\n"
2972 " if (metadata-E<gt>mask == (FAN_CREATE | FAN_ONDIR))\n"
2973 " printf(\"FAN_CREATE | FAN_ONDIR (subdirectory created):\\[rs]n\");\n"
2974 "\\&\n"
2975 "\t/* metadata-E<gt>fd is set to FAN_NOFD when the group identifies\n"
2976 "\t objects by file handles. To obtain a file descriptor for\n"
2977 "\t the file object corresponding to an event you can use the\n"
2978 "\t struct file_handle that\\[aq]s provided within the\n"
2979 "\t fanotify_event_info_fid in conjunction with the\n"
2980 "\t open_by_handle_at(2) system call. A check for ESTALE is\n"
2981 "\t done to accommodate for the situation where the file handle\n"
2982 "\t for the object was deleted prior to this system call. */\n"
2983 "\\&\n"
2984 " event_fd = open_by_handle_at(mount_fd, file_handle, O_RDONLY);\n"
2985 " if (event_fd == -1) {\n"
2986 " if (errno == ESTALE) {\n"
2987 " printf(\"File handle is no longer valid. \"\n"
2988 " \"File has been deleted\\[rs]n\");\n"
2989 " continue;\n"
2990 " } else {\n"
2991 " perror(\"open_by_handle_at\");\n"
2992 " exit(EXIT_FAILURE);\n"
2993 " }\n"
2994 " }\n"
2995 "\\&\n"
2996 " snprintf(procfd_path, sizeof(procfd_path), \"/proc/self/fd/%d\",\n"
2997 " event_fd);\n"
2998 "\\&\n"
2999 " /* Retrieve and print the path of the modified dentry. */\n"
3000 "\\&\n"
3001 " path_len = readlink(procfd_path, path, sizeof(path) - 1);\n"
3002 " if (path_len == -1) {\n"
3003 " perror(\"readlink\");\n"
3004 " exit(EXIT_FAILURE);\n"
3005 " }\n"
3006 "\\&\n"
3007 " path[path_len] = \\[aq]\\[rs]0\\[aq];\n"
3008 " printf(\"\\[rs]tDirectory \\[aq]%s\\[aq] has been modified.\\[rs]n\", path);\n"
3009 "\\&\n"
3010 " if (file_name) {\n"
3011 " ret = fstatat(event_fd, file_name, &sb, 0);\n"
3012 " if (ret == -1) {\n"
3013 " if (errno != ENOENT) {\n"
3014 " perror(\"fstatat\");\n"
3015 " exit(EXIT_FAILURE);\n"
3016 " }\n"
3017 " printf(\"\\[rs]tEntry \\[aq]%s\\[aq] does not exist.\\[rs]n\", file_name);\n"
3018 " } else if ((sb.st_mode & S_IFMT) == S_IFDIR) {\n"
3019 " printf(\"\\[rs]tEntry \\[aq]%s\\[aq] is a subdirectory.\\[rs]n\", file_name);\n"
3020 " } else {\n"
3021 " printf(\"\\[rs]tEntry \\[aq]%s\\[aq] is not a subdirectory.\\[rs]n\",\n"
3022 " file_name);\n"
3023 " }\n"
3024 " }\n"
3025 "\\&\n"
3026 " /* Close associated file descriptor for this event. */\n"
3027 "\\&\n"
3028 " close(event_fd);\n"
3029 " }\n"
3030 "\\&\n"
3031 " printf(\"All events processed successfully. Program exiting.\\[rs]n\");\n"
3032 " exit(EXIT_SUCCESS);\n"
3033 "}\n"
3034 msgstr ""
3035
3036 #. type: TH
3037 #: fedora-44 fedora-rawhide
3038 #, no-wrap
3039 msgid "2024-11-17"
3040 msgstr "17 Noviembre 2024"
3041
3042 #. type: TH
3043 #: fedora-44 fedora-rawhide
3044 #, no-wrap
3045 msgid "Linux man-pages 6.13"
3046 msgstr "Páginas de Manual de Linux 6.13"
3047
3048 #. type: Plain text
3049 #: fedora-44 fedora-rawhide
3050 #, no-wrap
3051 msgid ""
3052 "#define _GNU_SOURCE /* Needed to get O_LARGEFILE definition */\n"
3053 "#include E<lt>errno.hE<gt>\n"
3054 "#include E<lt>fcntl.hE<gt>\n"
3055 "#include E<lt>limits.hE<gt>\n"
3056 "#include E<lt>poll.hE<gt>\n"
3057 "#include E<lt>stdio.hE<gt>\n"
3058 "#include E<lt>stdlib.hE<gt>\n"
3059 "#include E<lt>sys/fanotify.hE<gt>\n"
3060 "#include E<lt>unistd.hE<gt>\n"
3061 "\\&\n"
3062 "/* Read all available fanotify events from the file descriptor \\[aq]fd\\[aq]. */\n"
3063 "\\&\n"
3064 "static void\n"
3065 "handle_events(int fd)\n"
3066 "{\n"
3067 " const struct fanotify_event_metadata *metadata;\n"
3068 " struct fanotify_event_metadata buf[200];\n"
3069 " ssize_t size;\n"
3070 " char path[PATH_MAX];\n"
3071 " ssize_t path_len;\n"
3072 " char procfd_path[PATH_MAX];\n"
3073 " struct fanotify_response response;\n"
3074 "\\&\n"
3075 " /* Loop while events can be read from fanotify file descriptor. */\n"
3076 "\\&\n"
3077 " for (;;) {\n"
3078 "\\&\n"
3079 " /* Read some events. */\n"
3080 "\\&\n"
3081 " size = read(fd, buf, sizeof(buf));\n"
3082 " if (size == -1 && errno != EAGAIN) {\n"
3083 " perror(\"read\");\n"
3084 " exit(EXIT_FAILURE);\n"
3085 " }\n"
3086 "\\&\n"
3087 " /* Check if end of available data reached. */\n"
3088 "\\&\n"
3089 " if (size E<lt>= 0)\n"
3090 " break;\n"
3091 "\\&\n"
3092 " /* Point to the first event in the buffer. */\n"
3093 "\\&\n"
3094 " metadata = buf;\n"
3095 "\\&\n"
3096 " /* Loop over all events in the buffer. */\n"
3097 "\\&\n"
3098 " while (FAN_EVENT_OK(metadata, size)) {\n"
3099 "\\&\n"
3100 " /* Check that run-time and compile-time structures match. */\n"
3101 "\\&\n"
3102 " if (metadata-E<gt>vers != FANOTIFY_METADATA_VERSION) {\n"
3103 " fprintf(stderr,\n"
3104 " \"Mismatch of fanotify metadata version.\\[rs]n\");\n"
3105 " exit(EXIT_FAILURE);\n"
3106 " }\n"
3107 "\\&\n"
3108 " /* metadata-E<gt>fd contains either FAN_NOFD, indicating a\n"
3109 " queue overflow, or a file descriptor (a nonnegative\n"
3110 " integer). Here, we simply ignore queue overflow. */\n"
3111 "\\&\n"
3112 " if (metadata-E<gt>fd E<gt>= 0) {\n"
3113 "\\&\n"
3114 " /* Handle open permission event. */\n"
3115 "\\&\n"
3116 " if (metadata-E<gt>mask & FAN_OPEN_PERM) {\n"
3117 " printf(\"FAN_OPEN_PERM: \");\n"
3118 "\\&\n"
3119 " /* Allow file to be opened. */\n"
3120 "\\&\n"
3121 " response.fd = metadata-E<gt>fd;\n"
3122 " response.response = FAN_ALLOW;\n"
3123 " write(fd, &response, sizeof(response));\n"
3124 " }\n"
3125 "\\&\n"
3126 " /* Handle closing of writable file event. */\n"
3127 "\\&\n"
3128 " if (metadata-E<gt>mask & FAN_CLOSE_WRITE)\n"
3129 " printf(\"FAN_CLOSE_WRITE: \");\n"
3130 "\\&\n"
3131 " /* Retrieve and print pathname of the accessed file. */\n"
3132 "\\&\n"
3133 " snprintf(procfd_path, sizeof(procfd_path),\n"
3134 " \"/proc/self/fd/%d\", metadata-E<gt>fd);\n"
3135 " path_len = readlink(procfd_path, path,\n"
3136 " sizeof(path) - 1);\n"
3137 " if (path_len == -1) {\n"
3138 " perror(\"readlink\");\n"
3139 " exit(EXIT_FAILURE);\n"
3140 " }\n"
3141 "\\&\n"
3142 " path[path_len] = \\[aq]\\[rs]0\\[aq];\n"
3143 " printf(\"File %s\\[rs]n\", path);\n"
3144 "\\&\n"
3145 " /* Close the file descriptor of the event. */\n"
3146 "\\&\n"
3147 " close(metadata-E<gt>fd);\n"
3148 " }\n"
3149 "\\&\n"
3150 " /* Advance to next event. */\n"
3151 "\\&\n"
3152 " metadata = FAN_EVENT_NEXT(metadata, size);\n"
3153 " }\n"
3154 " }\n"
3155 "}\n"
3156 "\\&\n"
3157 "int\n"
3158 "main(int argc, char *argv[])\n"
3159 "{\n"
3160 " char buf;\n"
3161 " int fd, poll_num;\n"
3162 " nfds_t nfds;\n"
3163 " struct pollfd fds[2];\n"
3164 "\\&\n"
3165 " /* Check mount point is supplied. */\n"
3166 "\\&\n"
3167 " if (argc != 2) {\n"
3168 " fprintf(stderr, \"Usage: %s MOUNT\\[rs]n\", argv[0]);\n"
3169 " exit(EXIT_FAILURE);\n"
3170 " }\n"
3171 "\\&\n"
3172 " printf(\"Press enter key to terminate.\\[rs]n\");\n"
3173 "\\&\n"
3174 " /* Create the file descriptor for accessing the fanotify API. */\n"
3175 "\\&\n"
3176 " fd = fanotify_init(FAN_CLOEXEC | FAN_CLASS_CONTENT | FAN_NONBLOCK,\n"
3177 " O_RDONLY | O_LARGEFILE);\n"
3178 " if (fd == -1) {\n"
3179 " perror(\"fanotify_init\");\n"
3180 " exit(EXIT_FAILURE);\n"
3181 " }\n"
3182 "\\&\n"
3183 " /* Mark the mount for:\n"
3184 " - permission events before opening files\n"
3185 " - notification events after closing a write-enabled\n"
3186 " file descriptor. */\n"
3187 "\\&\n"
3188 " if (fanotify_mark(fd, FAN_MARK_ADD | FAN_MARK_MOUNT,\n"
3189 " FAN_OPEN_PERM | FAN_CLOSE_WRITE, AT_FDCWD,\n"
3190 " argv[1]) == -1) {\n"
3191 " perror(\"fanotify_mark\");\n"
3192 " exit(EXIT_FAILURE);\n"
3193 " }\n"
3194 "\\&\n"
3195 " /* Prepare for polling. */\n"
3196 "\\&\n"
3197 " nfds = 2;\n"
3198 "\\&\n"
3199 " fds[0].fd = STDIN_FILENO; /* Console input */\n"
3200 " fds[0].events = POLLIN;\n"
3201 "\\&\n"
3202 " fds[1].fd = fd; /* Fanotify input */\n"
3203 " fds[1].events = POLLIN;\n"
3204 "\\&\n"
3205 " /* This is the loop to wait for incoming events. */\n"
3206 "\\&\n"
3207 " printf(\"Listening for events.\\[rs]n\");\n"
3208 "\\&\n"
3209 " while (1) {\n"
3210 " poll_num = poll(fds, nfds, -1);\n"
3211 " if (poll_num == -1) {\n"
3212 " if (errno == EINTR) /* Interrupted by a signal */\n"
3213 " continue; /* Restart poll() */\n"
3214 "\\&\n"
3215 " perror(\"poll\"); /* Unexpected error */\n"
3216 " exit(EXIT_FAILURE);\n"
3217 " }\n"
3218 "\\&\n"
3219 " if (poll_num E<gt> 0) {\n"
3220 " if (fds[0].revents & POLLIN) {\n"
3221 "\\&\n"
3222 " /* Console input is available: empty stdin and quit. */\n"
3223 "\\&\n"
3224 " while (read(STDIN_FILENO, &buf, 1) E<gt> 0 && buf != \\[aq]\\[rs]n\\[aq])\n"
3225 " continue;\n"
3226 " break;\n"
3227 " }\n"
3228 "\\&\n"
3229 " if (fds[1].revents & POLLIN) {\n"
3230 "\\&\n"
3231 " /* Fanotify events are available. */\n"
3232 "\\&\n"
3233 " handle_events(fd);\n"
3234 " }\n"
3235 " }\n"
3236 " }\n"
3237 "\\&\n"
3238 " printf(\"Listening for events stopped.\\[rs]n\");\n"
3239 " exit(EXIT_SUCCESS);\n"
3240 "}\n"
3241 msgstr ""
3242
3243 #. type: Plain text
3244 #: fedora-44 fedora-rawhide
3245 #, no-wrap
3246 msgid ""
3247 "#define _GNU_SOURCE\n"
3248 "#include E<lt>errno.hE<gt>\n"
3249 "#include E<lt>fcntl.hE<gt>\n"
3250 "#include E<lt>limits.hE<gt>\n"
3251 "#include E<lt>stdio.hE<gt>\n"
3252 "#include E<lt>stdlib.hE<gt>\n"
3253 "#include E<lt>sys/types.hE<gt>\n"
3254 "#include E<lt>sys/stat.hE<gt>\n"
3255 "#include E<lt>sys/fanotify.hE<gt>\n"
3256 "#include E<lt>unistd.hE<gt>\n"
3257 "\\&\n"
3258 "#define BUF_SIZE 256\n"
3259 "\\&\n"
3260 "int\n"
3261 "main(int argc, char *argv[])\n"
3262 "{\n"
3263 " int fd, ret, event_fd, mount_fd;\n"
3264 " ssize_t size, path_len;\n"
3265 " char path[PATH_MAX];\n"
3266 " char procfd_path[PATH_MAX];\n"
3267 " char events_buf[BUF_SIZE];\n"
3268 " struct file_handle *file_handle;\n"
3269 " struct fanotify_event_metadata *metadata;\n"
3270 " struct fanotify_event_info_fid *fid;\n"
3271 " const char *file_name;\n"
3272 " struct stat sb;\n"
3273 "\\&\n"
3274 " if (argc != 2) {\n"
3275 " fprintf(stderr, \"Invalid number of command line arguments.\\[rs]n\");\n"
3276 " exit(EXIT_FAILURE);\n"
3277 " }\n"
3278 "\\&\n"
3279 " mount_fd = open(argv[1], O_DIRECTORY | O_RDONLY);\n"
3280 " if (mount_fd == -1) {\n"
3281 " perror(argv[1]);\n"
3282 " exit(EXIT_FAILURE);\n"
3283 " }\n"
3284 "\\&\n"
3285 " /* Create an fanotify file descriptor with FAN_REPORT_DFID_NAME as\n"
3286 " a flag so that program can receive fid events with directory\n"
3287 " entry name. */\n"
3288 "\\&\n"
3289 " fd = fanotify_init(FAN_CLASS_NOTIF | FAN_REPORT_DFID_NAME, 0);\n"
3290 " if (fd == -1) {\n"
3291 " perror(\"fanotify_init\");\n"
3292 " exit(EXIT_FAILURE);\n"
3293 " }\n"
3294 "\\&\n"
3295 " /* Place a mark on the filesystem object supplied in argv[1]. */\n"
3296 "\\&\n"
3297 " ret = fanotify_mark(fd, FAN_MARK_ADD | FAN_MARK_ONLYDIR,\n"
3298 " FAN_CREATE | FAN_ONDIR,\n"
3299 " AT_FDCWD, argv[1]);\n"
3300 " if (ret == -1) {\n"
3301 " perror(\"fanotify_mark\");\n"
3302 " exit(EXIT_FAILURE);\n"
3303 " }\n"
3304 "\\&\n"
3305 " printf(\"Listening for events.\\[rs]n\");\n"
3306 "\\&\n"
3307 " /* Read events from the event queue into a buffer. */\n"
3308 "\\&\n"
3309 " size = read(fd, events_buf, sizeof(events_buf));\n"
3310 " if (size == -1 && errno != EAGAIN) {\n"
3311 " perror(\"read\");\n"
3312 " exit(EXIT_FAILURE);\n"
3313 " }\n"
3314 "\\&\n"
3315 " /* Process all events within the buffer. */\n"
3316 "\\&\n"
3317 " for (metadata = (struct fanotify_event_metadata *) events_buf;\n"
3318 " FAN_EVENT_OK(metadata, size);\n"
3319 " metadata = FAN_EVENT_NEXT(metadata, size)) {\n"
3320 " fid = (struct fanotify_event_info_fid *) (metadata + 1);\n"
3321 " file_handle = (struct file_handle *) fid-E<gt>handle;\n"
3322 "\\&\n"
3323 " /* Ensure that the event info is of the correct type. */\n"
3324 "\\&\n"
3325 " if (fid-E<gt>hdr.info_type == FAN_EVENT_INFO_TYPE_FID ||\n"
3326 " fid-E<gt>hdr.info_type == FAN_EVENT_INFO_TYPE_DFID) {\n"
3327 " file_name = NULL;\n"
3328 " } else if (fid-E<gt>hdr.info_type == FAN_EVENT_INFO_TYPE_DFID_NAME) {\n"
3329 " file_name = file_handle-E<gt>f_handle +\n"
3330 " file_handle-E<gt>handle_bytes;\n"
3331 " } else {\n"
3332 " fprintf(stderr, \"Received unexpected event info type.\\[rs]n\");\n"
3333 " exit(EXIT_FAILURE);\n"
3334 " }\n"
3335 "\\&\n"
3336 " if (metadata-E<gt>mask == FAN_CREATE)\n"
3337 " printf(\"FAN_CREATE (file created):\\[rs]n\");\n"
3338 "\\&\n"
3339 " if (metadata-E<gt>mask == (FAN_CREATE | FAN_ONDIR))\n"
3340 " printf(\"FAN_CREATE | FAN_ONDIR (subdirectory created):\\[rs]n\");\n"
3341 "\\&\n"
3342 "\t/* metadata-E<gt>fd is set to FAN_NOFD when the group identifies\n"
3343 "\t objects by file handles. To obtain a file descriptor for\n"
3344 "\t the file object corresponding to an event you can use the\n"
3345 "\t struct file_handle that\\[aq]s provided within the\n"
3346 "\t fanotify_event_info_fid in conjunction with the\n"
3347 "\t open_by_handle_at(2) system call. A check for ESTALE is\n"
3348 "\t done to accommodate for the situation where the file handle\n"
3349 "\t for the object was deleted prior to this system call. */\n"
3350 "\\&\n"
3351 " event_fd = open_by_handle_at(mount_fd, file_handle, O_RDONLY);\n"
3352 " if (event_fd == -1) {\n"
3353 " if (errno == ESTALE) {\n"
3354 " printf(\"File handle is no longer valid. \"\n"
3355 " \"File has been deleted\\[rs]n\");\n"
3356 " continue;\n"
3357 " } else {\n"
3358 " perror(\"open_by_handle_at\");\n"
3359 " exit(EXIT_FAILURE);\n"
3360 " }\n"
3361 " }\n"
3362 "\\&\n"
3363 " snprintf(procfd_path, sizeof(procfd_path), \"/proc/self/fd/%d\",\n"
3364 " event_fd);\n"
3365 "\\&\n"
3366 " /* Retrieve and print the path of the modified dentry. */\n"
3367 "\\&\n"
3368 " path_len = readlink(procfd_path, path, sizeof(path) - 1);\n"
3369 " if (path_len == -1) {\n"
3370 " perror(\"readlink\");\n"
3371 " exit(EXIT_FAILURE);\n"
3372 " }\n"
3373 "\\&\n"
3374 " path[path_len] = \\[aq]\\[rs]0\\[aq];\n"
3375 " printf(\"\\[rs]tDirectory \\[aq]%s\\[aq] has been modified.\\[rs]n\", path);\n"
3376 "\\&\n"
3377 " if (file_name) {\n"
3378 " ret = fstatat(event_fd, file_name, &sb, 0);\n"
3379 " if (ret == -1) {\n"
3380 " if (errno != ENOENT) {\n"
3381 " perror(\"fstatat\");\n"
3382 " exit(EXIT_FAILURE);\n"
3383 " }\n"
3384 " printf(\"\\[rs]tEntry \\[aq]%s\\[aq] does not exist.\\[rs]n\", file_name);\n"
3385 " } else if ((sb.st_mode & S_IFMT) == S_IFDIR) {\n"
3386 " printf(\"\\[rs]tEntry \\[aq]%s\\[aq] is a subdirectory.\\[rs]n\", file_name);\n"
3387 " } else {\n"
3388 " printf(\"\\[rs]tEntry \\[aq]%s\\[aq] is not a subdirectory.\\[rs]n\",\n"
3389 " file_name);\n"
3390 " }\n"
3391 " }\n"
3392 "\\&\n"
3393 " /* Close associated file descriptor for this event. */\n"
3394 "\\&\n"
3395 " close(event_fd);\n"
3396 " }\n"
3397 "\\&\n"
3398 " printf(\"All events processed successfully. Program exiting.\\[rs]n\");\n"
3399 " exit(EXIT_SUCCESS);\n"
3400 "}\n"
3401 msgstr ""
3402
3403 #. type: TH
3404 #: mageia-cauldron
3405 #, no-wrap
3406 msgid "2026-02-08"
3407 msgstr "8 Febrero 2026"
3408
3409 #. type: TH
3410 #: mageia-cauldron
3411 #, no-wrap
3412 msgid "Linux man-pages 6.17"
3413 msgstr "Páginas de Manual de Linux 6.17"
3414
3415 #. type: Plain text
3416 #: mageia-cauldron
3417 #, no-wrap
3418 msgid ""
3419 "#define _GNU_SOURCE /* Needed to get O_LARGEFILE definition */\n"
3420 "#include E<lt>errno.hE<gt>\n"
3421 "#include E<lt>fcntl.hE<gt>\n"
3422 "#include E<lt>limits.hE<gt>\n"
3423 "#include E<lt>poll.hE<gt>\n"
3424 "#include E<lt>stdio.hE<gt>\n"
3425 "#include E<lt>stdlib.hE<gt>\n"
3426 "#include E<lt>sys/fanotify.hE<gt>\n"
3427 "#include E<lt>unistd.hE<gt>\n"
3428 "\\&\n"
3429 "/* Read all available fanotify events from the file descriptor \\[aq]fd\\[aq]. */\n"
3430 "\\&\n"
3431 "static void\n"
3432 "handle_events(int fd)\n"
3433 "{\n"
3434 " const struct fanotify_event_metadata *metadata;\n"
3435 " struct fanotify_event_metadata buf[200];\n"
3436 " ssize_t size;\n"
3437 " char path[PATH_MAX];\n"
3438 " ssize_t path_len;\n"
3439 " char procfd_path[PATH_MAX];\n"
3440 " struct fanotify_response response;\n"
3441 "\\&\n"
3442 " /* Loop while events can be read from fanotify file descriptor. */\n"
3443 "\\&\n"
3444 " for (;;) {\n"
3445 "\\&\n"
3446 " /* Read some events. */\n"
3447 "\\&\n"
3448 " size = read(fd, buf, sizeof(buf));\n"
3449 " if (size == -1 && errno != EAGAIN) {\n"
3450 " perror(\"read\");\n"
3451 " exit(EXIT_FAILURE);\n"
3452 " }\n"
3453 "\\&\n"
3454 " /* Check if end of available data reached. */\n"
3455 "\\&\n"
3456 " if (size E<lt>= 0)\n"
3457 " break;\n"
3458 "\\&\n"
3459 " /* Point to the first event in the buffer. */\n"
3460 "\\&\n"
3461 " metadata = buf;\n"
3462 "\\&\n"
3463 " /* Loop over all events in the buffer. */\n"
3464 "\\&\n"
3465 " while (FAN_EVENT_OK(metadata, size)) {\n"
3466 "\\&\n"
3467 " /* Check that run-time and compile-time structures match. */\n"
3468 "\\&\n"
3469 " if (metadata-E<gt>vers != FANOTIFY_METADATA_VERSION) {\n"
3470 " fprintf(stderr,\n"
3471 " \"Mismatch of fanotify metadata version.\\[rs]n\");\n"
3472 " exit(EXIT_FAILURE);\n"
3473 " }\n"
3474 "\\&\n"
3475 " /* metadata-E<gt>fd contains either FAN_NOFD, indicating a\n"
3476 " queue overflow, or a file descriptor (a nonnegative\n"
3477 " integer). Here, we simply ignore queue overflow. */\n"
3478 "\\&\n"
3479 " if (metadata-E<gt>fd E<gt>= 0) {\n"
3480 "\\&\n"
3481 " /* Handle open permission event. */\n"
3482 "\\&\n"
3483 " if (metadata-E<gt>mask & FAN_OPEN_PERM) {\n"
3484 " printf(\"FAN_OPEN_PERM: \");\n"
3485 "\\&\n"
3486 " /* Allow file to be opened. */\n"
3487 "\\&\n"
3488 " response.fd = metadata-E<gt>fd;\n"
3489 " response.response = FAN_ALLOW;\n"
3490 " write(fd, &response, sizeof(response));\n"
3491 " }\n"
3492 "\\&\n"
3493 " /* Handle closing of writable file event. */\n"
3494 "\\&\n"
3495 " if (metadata-E<gt>mask & FAN_CLOSE_WRITE)\n"
3496 " printf(\"FAN_CLOSE_WRITE: \");\n"
3497 "\\&\n"
3498 " /* Retrieve and print pathname of the accessed file. */\n"
3499 "\\&\n"
3500 " snprintf(procfd_path, sizeof(procfd_path),\n"
3501 " \"/proc/self/fd/%d\", metadata-E<gt>fd);\n"
3502 " path_len = readlink(procfd_path, path,\n"
3503 " sizeof(path) - 1);\n"
3504 " if (path_len == -1) {\n"
3505 " perror(\"readlink\");\n"
3506 " exit(EXIT_FAILURE);\n"
3507 " }\n"
3508 "\\&\n"
3509 " path[path_len] = \\[aq]\\[rs]0\\[aq];\n"
3510 " printf(\"File %s\\[rs]n\", path);\n"
3511 "\\&\n"
3512 " /* Close the file descriptor of the event. */\n"
3513 "\\&\n"
3514 " close(metadata-E<gt>fd);\n"
3515 " }\n"
3516 "\\&\n"
3517 " /* Advance to next event. */\n"
3518 "\\&\n"
3519 " metadata = FAN_EVENT_NEXT(metadata, size);\n"
3520 " }\n"
3521 " }\n"
3522 "}\n"
3523 "\\&\n"
3524 "int\n"
3525 "main(int argc, char *argv[])\n"
3526 "{\n"
3527 " char buf;\n"
3528 " int fd, poll_num;\n"
3529 " nfds_t nfds;\n"
3530 " struct pollfd fds[2];\n"
3531 "\\&\n"
3532 " /* Check mount point is supplied. */\n"
3533 "\\&\n"
3534 " if (argc != 2) {\n"
3535 " fprintf(stderr, \"Usage: %s MOUNT\\[rs]n\", argv[0]);\n"
3536 " exit(EXIT_FAILURE);\n"
3537 " }\n"
3538 "\\&\n"
3539 " printf(\"Press enter key to terminate.\\[rs]n\");\n"
3540 "\\&\n"
3541 " /* Create the file descriptor for accessing the fanotify API. */\n"
3542 "\\&\n"
3543 " fd = fanotify_init(FAN_CLOEXEC | FAN_CLASS_CONTENT | FAN_NONBLOCK,\n"
3544 " O_RDONLY | O_LARGEFILE);\n"
3545 " if (fd == -1) {\n"
3546 " perror(\"fanotify_init\");\n"
3547 " exit(EXIT_FAILURE);\n"
3548 " }\n"
3549 "\\&\n"
3550 " /* Mark the mount for:\n"
3551 " - permission events before opening files\n"
3552 " - notification events after closing a write-enabled\n"
3553 " file descriptor. */\n"
3554 "\\&\n"
3555 " if (fanotify_mark(fd, FAN_MARK_ADD | FAN_MARK_MOUNT,\n"
3556 " FAN_OPEN_PERM | FAN_CLOSE_WRITE, AT_FDCWD,\n"
3557 " argv[1]) == -1) {\n"
3558 " perror(\"fanotify_mark\");\n"
3559 " exit(EXIT_FAILURE);\n"
3560 " }\n"
3561 "\\&\n"
3562 " /* Prepare for polling. */\n"
3563 "\\&\n"
3564 " nfds = 2;\n"
3565 "\\&\n"
3566 " fds[0].fd = STDIN_FILENO; /* Console input */\n"
3567 " fds[0].events = POLLIN;\n"
3568 "\\&\n"
3569 " fds[1].fd = fd; /* Fanotify input */\n"
3570 " fds[1].events = POLLIN;\n"
3571 "\\&\n"
3572 " /* This is the loop to wait for incoming events. */\n"
3573 "\\&\n"
3574 " printf(\"Listening for events.\\[rs]n\");\n"
3575 "\\&\n"
3576 " while (1) {\n"
3577 " poll_num = poll(fds, nfds, -1);\n"
3578 " if (poll_num == -1) {\n"
3579 " if (errno == EINTR) /* Interrupted by a signal */\n"
3580 " continue; /* Restart poll() */\n"
3581 "\\&\n"
3582 " perror(\"poll\"); /* Unexpected error */\n"
3583 " exit(EXIT_FAILURE);\n"
3584 " }\n"
3585 "\\&\n"
3586 " if (poll_num E<gt> 0) {\n"
3587 " if (fds[0].revents & POLLIN) {\n"
3588 "\\&\n"
3589 " /* Console input is available: empty stdin and quit. */\n"
3590 "\\&\n"
3591 " while (read(STDIN_FILENO, &buf, 1) E<gt> 0 && buf != \\[aq]\\[rs]n\\[aq])\n"
3592 " continue;\n"
3593 " break;\n"
3594 " }\n"
3595 "\\&\n"
3596 " if (fds[1].revents & POLLIN) {\n"
3597 "\\&\n"
3598 " /* Fanotify events are available. */\n"
3599 "\\&\n"
3600 " handle_events(fd);\n"
3601 " }\n"
3602 " }\n"
3603 " }\n"
3604 "\\&\n"
3605 " printf(\"Listening for events stopped.\\[rs]n\");\n"
3606 " exit(EXIT_SUCCESS);\n"
3607 "}\n"
3608 msgstr ""
3609
3610 #. type: TH
3611 #: opensuse-leap-16-1 opensuse-tumbleweed
3612 #, no-wrap
3613 msgid "Linux man-pages (unreleased)"
3614 msgstr "Páginas de Manual de Linux (no publicadas)"