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