]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/fanotify_mark.2
fanotify_mark.2: wfix
[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
24.TH FANOTIFY_MARK 2 2014-04-24 "Linux" "Linux Programmer's Manual"
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 ,
33.BI " uint64_t " mask ", int " dirfd ,
34.BI " const char *" pathname );
35.fi
36.SH DESCRIPTION
37For an overview of the fanotify API, see
38.BR fanotify (7).
39.PP
40.BR fanotify_mark (2)
b6551738 41adds, removes, or modifies an fanotify mark on a filesystem object.
c200b422
HS
42The caller must have read permission on the filesystem object that is to be
43marked.
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
73Remove either all mount or non-mount marks from the fanotify group.
74If
75.I flag
76contains
77.BR FAN_MARK_MOUNT ,
78all marks for mounts are removed from the group.
79Otherwise, all marks for directories and files are removed.
80No other flag but
81.B FAN_MARK_MOUNT
82can be used in conjunction with
83.BR FAN_MARK_FLUSH .
84.I mask
85is ignored.
86.PP
87If none of the values above is specified, or more than one is specified, the
88call fails with the error
89.BR EINVAL .
90.PP
91In addition,
92.I flags
93may contain zero or more of the following:
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
112The
113.I pathname
114indicates a mount point to be marked.
115If the path is not itself a mount point, the mount point containing the path
116will be marked.
117All directories, subdirectories, and the contained files of the mount point
118will be monitored.
119.TP
120.B FAN_MARK_IGNORED_MASK
121The events in
122.I mask
123shall be added to or removed from the ignore mask.
124.TP
125.B FAN_MARK_IGNORED_SURV_MODIFY
126The ignore mask shall survive modify events.
127If this flag is not set, the ignore mask is cleared when a modify event occurs
128for the ignored file or directory.
129.PP
130.I mask
131defines which events shall be listened to (or which shall be ignored).
132It is a bit mask composed of the following values:
133.TP
134.B FAN_ACCESS
135Create an event when a file or directory (but see BUGS) is accessed (read).
136.TP
137.B FAN_MODIFY
138Create an event when a file is modified (write).
139.TP
140.B FAN_CLOSE_WRITE
141Create an event when a writable file is closed.
142.TP
143.B FAN_CLOSE_NOWRITE
144Create an event when a read-only file or directory is closed.
145.TP
146.B FAN_OPEN
147Create an event when a file or directory is opened.
148.TP
149.B FAN_OPEN_PERM
150Create an event when a permission to open a file or directory is requested.
151An fanotify file descriptor created with
152.B FAN_CLASS_PRE_CONTENT
153or
154.B FAN_CLASS_CONTENT
155is required.
156.TP
157.B FAN_ACCESS_PERM
158Create an event when a permission to read a file or directory is requested.
159An fanotify file descriptor created with
160.B FAN_CLASS_PRE_CONTENT
161or
162.B FAN_CLASS_CONTENT
163is required.
164.TP
165.B FAN_ONDIR
166Events for directories shall be created, for example when
167.BR opendir (2),
168.BR readdir (2)
169(but see BUGS), and
170.BR closedir (2)
171are called.
172Without this flag only events for files are created.
173.TP
174.B FAN_EVENT_ON_CHILD
175Events for the immediate children of marked directories shall be created.
176The flag has no effect when marking mounts.
177Note that events are not generated for children of the subdirectories
178of marked directories.
179To monitor complete directory trees it is necessary to mark the relevant
180mount.
181.PP
182The following composed value is defined:
183.TP
184.B FAN_CLOSE
185A file is closed
186.RB ( FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE ).
187.PP
188The filesystem object to be marked is determined by the file descriptor
189.I dirfd
190and the pathname specified in
191.IR pathname :
192.IP * 3
193If
194.I pathname
195is NULL,
196.I dirfd
197defines the filesystem object to be marked.
198.IP *
199If
200.I pathname
201is NULL, and
202.I dirfd
203takes the special value
204.BR AT_FDCWD ,
205the current working directory is to be marked.
206.IP *
207If
208.I pathname
209is absolute, it defines the filesystem object to be marked, and
210.I dirfd
211is ignored.
212.IP *
213If
214.I pathname
215is relative, and
216.I dirfd
217does not have the value
218.BR AT_FDCWD ,
219then the filesystem object to be marked is determined by interpreting
220.I pathname
221relative the directory referred to by
222.IR dirfd .
223.IP *
224If
225.I pathname
226is relative, and
227.I dirfd
228has the value
229.BR AT_FDCWD,
230then the filesystem object to be marked is determined by interpreting
231.I pathname
232relative the current working directory.
233.SH RETURN VALUE
234On success,
235.BR fanotify_mark ()
236returns 0.
237In case of an error, \-1 is returned, and
238.I errno
239is set to indicate the error.
240.SH ERRORS
241.TP
242.B EBADF
243An invalid file descriptor was passed in
244.IR fanotify_fd .
245.TP
246.B EINVAL
247An invalid value was passed in
248.IR flags
249or
250.IR mask ,
251or
252.I fanotify_fd
253was not an fanotify file descriptor.
254.TP
255.B EINVAL
256The fanotify file descriptor was opened with
257.B FAN_CLASS_NOTIF
258and mask contains a flag for permission events
259.RB ( FAN_OPEN_PERM
260or
261.BR FAN_ACCESS_PERM ).
262.TP
263.B ENOENT
264The filesystem object indicated by
265.IR dirfd
266and
267.IR pathname
268does not exist.
269This error also occurs when trying to remove a mark from an object which is not
270marked.
271.TP
272.B ENOMEM
273The necessary memory could not be allocated.
274.TP
275.B ENOSPC
276The number of marks exceeds the limit of 8192 and
277.B FAN_UNLIMITED_MARKS
278was not specified in the call to
279.BR fanotify_init (2).
280.TP
281.B ENOTDIR
282.I flags
283contains
284.BR FAN_MARK_ONLYDIR ,
285and
286.I dirfd
287and
288.I pathname
289do not specify a directory.
290.SH VERSIONS
291.BR fanotify_mark ()
292was introduced in version 2.6.36 of the Linux kernel and enabled in version
2932.6.37.
294.SH CONFORMING TO
295This system call is Linux-specific.
296.SH BUGS
297As of Linux 3.15,
298the following bugs exist:
299.IP * 3
300.\" FIXME: Patch is in next-20140424.
301If
302.I flags
303contains
304.BR FAN_MARK_FLUSH ,
305.I dfd
306and
307.I pathname
308must indicate a valid path.
309This path is not used.
310.IP *
311.\" FIXME: Patch is in next-20140424.
312.BR readdir (2)
313does not result in a
314.B FAN_ACCESS
315event.
316.IP *
317.\" FIXME: Patch proposed.
318If
319.BR fanotify_mark (2)
320is called with
321.B FAN_MARK_FLUSH,
322.I flags
323is not checked for invalid values.
324.SH SEE ALSO
325.BR fanotify_init (2),
326.BR fanotify (7)