Blame man2/fanotify_mark.2

Packit 7cfc04
.\" Copyright (C) 2013,  Heinrich Schuchardt <xypron.glpk@gmx.de>
Packit 7cfc04
.\"
Packit 7cfc04
.\" %%%LICENSE_START(VERBATIM)
Packit 7cfc04
.\" Permission is granted to make and distribute verbatim copies of this
Packit 7cfc04
.\" manual provided the copyright notice and this permission notice are
Packit 7cfc04
.\" preserved on all copies.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Permission is granted to copy and distribute modified versions of
Packit 7cfc04
.\" this manual under the conditions for verbatim copying, provided that
Packit 7cfc04
.\" the entire resulting derived work is distributed under the terms of
Packit 7cfc04
.\" a permission notice identical to this one.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Since the Linux kernel and libraries are constantly changing, this
Packit 7cfc04
.\" manual page may be incorrect or out-of-date.  The author(s) assume.
Packit 7cfc04
.\" no responsibility for errors or omissions, or for damages resulting.
Packit 7cfc04
.\" from the use of the information contained herein.  The author(s) may.
Packit 7cfc04
.\" not have taken the same level of care in the production of this.
Packit 7cfc04
.\" manual, which is licensed free of charge, as they might when working.
Packit 7cfc04
.\" professionally.
Packit 7cfc04
.\"
Packit 7cfc04
.\" Formatted or processed versions of this manual, if unaccompanied by
Packit 7cfc04
.\" the source, must acknowledge the copyright and authors of this work.
Packit 7cfc04
.\" %%%LICENSE_END
Packit 7cfc04
.TH FANOTIFY_MARK 2 2016-10-08 "Linux" "Linux Programmer's Manual"
Packit 7cfc04
.SH NAME
Packit 7cfc04
fanotify_mark \- add, remove, or modify an fanotify mark on a filesystem
Packit 7cfc04
object
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.nf
Packit 7cfc04
.B #include <sys/fanotify.h>
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int fanotify_mark(int " fanotify_fd ", unsigned int " flags ,
Packit 7cfc04
.BI "                  uint64_t " mask ", int " dirfd \
Packit 7cfc04
", const char *" pathname );
Packit 7cfc04
.fi
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
For an overview of the fanotify API, see
Packit 7cfc04
.BR fanotify (7).
Packit 7cfc04
.PP
Packit 7cfc04
.BR fanotify_mark ()
Packit 7cfc04
adds, removes, or modifies an fanotify mark on a filesystem object.
Packit 7cfc04
The caller must have read permission on the filesystem object that
Packit 7cfc04
is to be marked.
Packit 7cfc04
.PP
Packit 7cfc04
The
Packit 7cfc04
.I fanotify_fd
Packit 7cfc04
argument is a file descriptor returned by
Packit 7cfc04
.BR fanotify_init (2).
Packit 7cfc04
.PP
Packit 7cfc04
.I flags
Packit 7cfc04
is a bit mask describing the modification to perform.
Packit 7cfc04
It must include exactly one of the following values:
Packit 7cfc04
.TP
Packit 7cfc04
.B FAN_MARK_ADD
Packit 7cfc04
The events in
Packit 7cfc04
.I mask
Packit 7cfc04
will be added to the mark mask (or to the ignore mask).
Packit 7cfc04
.I mask
Packit 7cfc04
must be nonempty or the error
Packit 7cfc04
.B EINVAL
Packit 7cfc04
will occur.
Packit 7cfc04
.TP
Packit 7cfc04
.B FAN_MARK_REMOVE
Packit 7cfc04
The events in argument
Packit 7cfc04
.I mask
Packit 7cfc04
will be removed from the mark mask (or from the ignore mask).
Packit 7cfc04
.I mask
Packit 7cfc04
must be nonempty or the error
Packit 7cfc04
.B EINVAL
Packit 7cfc04
will occur.
Packit 7cfc04
.TP
Packit 7cfc04
.B FAN_MARK_FLUSH
Packit 7cfc04
Remove either all mount or all non-mount marks from the fanotify group.
Packit 7cfc04
If
Packit 7cfc04
.I flags
Packit 7cfc04
contains
Packit 7cfc04
.BR FAN_MARK_MOUNT ,
Packit 7cfc04
all marks for mounts are removed from the group.
Packit 7cfc04
Otherwise, all marks for directories and files are removed.
Packit 7cfc04
No flag other than
Packit 7cfc04
.B FAN_MARK_MOUNT
Packit 7cfc04
can be used in conjunction with
Packit 7cfc04
.BR FAN_MARK_FLUSH .
Packit 7cfc04
.I mask
Packit 7cfc04
is ignored.
Packit 7cfc04
.PP
Packit 7cfc04
If none of the values above is specified, or more than one is specified,
Packit 7cfc04
the call fails with the error
Packit 7cfc04
.BR EINVAL .
Packit 7cfc04
.PP
Packit 7cfc04
In addition,
Packit 7cfc04
zero or more of the following values may be ORed into
Packit 7cfc04
.IR flags :
Packit 7cfc04
.TP
Packit 7cfc04
.B FAN_MARK_DONT_FOLLOW
Packit 7cfc04
If
Packit 7cfc04
.I pathname
Packit 7cfc04
is a symbolic link, mark the link itself, rather than the file to which it
Packit 7cfc04
refers.
Packit 7cfc04
(By default,
Packit 7cfc04
.BR fanotify_mark ()
Packit 7cfc04
dereferences
Packit 7cfc04
.I pathname
Packit 7cfc04
if it is a symbolic link.)
Packit 7cfc04
.TP
Packit 7cfc04
.B FAN_MARK_ONLYDIR
Packit 7cfc04
If the filesystem object to be marked is not a directory, the error
Packit 7cfc04
.B ENOTDIR
Packit 7cfc04
shall be raised.
Packit 7cfc04
.TP
Packit 7cfc04
.B FAN_MARK_MOUNT
Packit 7cfc04
Mark the mount point specified by
Packit 7cfc04
.IR pathname .
Packit 7cfc04
If
Packit 7cfc04
.I pathname
Packit 7cfc04
is not itself a mount point, the mount point containing
Packit 7cfc04
.I pathname
Packit 7cfc04
will be marked.
Packit 7cfc04
All directories, subdirectories, and the contained files of the mount point
Packit 7cfc04
will be monitored.
Packit 7cfc04
.TP
Packit 7cfc04
.B FAN_MARK_IGNORED_MASK
Packit 7cfc04
The events in
Packit 7cfc04
.I mask
Packit 7cfc04
shall be added to or removed from the ignore mask.
Packit 7cfc04
.TP
Packit 7cfc04
.B FAN_MARK_IGNORED_SURV_MODIFY
Packit 7cfc04
The ignore mask shall survive modify events.
Packit 7cfc04
If this flag is not set,
Packit 7cfc04
the ignore mask is cleared when a modify event occurs
Packit 7cfc04
for the ignored file or directory.
Packit 7cfc04
.PP
Packit 7cfc04
.I mask
Packit 7cfc04
defines which events shall be listened for (or which shall be ignored).
Packit 7cfc04
It is a bit mask composed of the following values:
Packit 7cfc04
.TP
Packit 7cfc04
.B FAN_ACCESS
Packit 7cfc04
Create an event when a file or directory (but see BUGS) is accessed (read).
Packit 7cfc04
.TP
Packit 7cfc04
.B FAN_MODIFY
Packit 7cfc04
Create an event when a file is modified (write).
Packit 7cfc04
.TP
Packit 7cfc04
.B FAN_CLOSE_WRITE
Packit 7cfc04
Create an event when a writable file is closed.
Packit 7cfc04
.TP
Packit 7cfc04
.B FAN_CLOSE_NOWRITE
Packit 7cfc04
Create an event when a read-only file or directory is closed.
Packit 7cfc04
.TP
Packit 7cfc04
.B FAN_OPEN
Packit 7cfc04
Create an event when a file or directory is opened.
Packit 7cfc04
.TP
Packit 7cfc04
.B FAN_Q_OVERFLOW
Packit 7cfc04
Create an event when an overflow of the event queue occurs.
Packit 7cfc04
The size of the event queue is limited to 16384 entries if
Packit 7cfc04
.B FAN_UNLIMITED_QUEUE
Packit 7cfc04
is not set in
Packit 7cfc04
.BR fanotify_init (2).
Packit 7cfc04
.TP
Packit 7cfc04
.B FAN_OPEN_PERM
Packit 7cfc04
Create an event when a permission to open a file or directory is requested.
Packit 7cfc04
An fanotify file descriptor created with
Packit 7cfc04
.B FAN_CLASS_PRE_CONTENT
Packit 7cfc04
or
Packit 7cfc04
.B FAN_CLASS_CONTENT
Packit 7cfc04
is required.
Packit 7cfc04
.TP
Packit 7cfc04
.B FAN_ACCESS_PERM
Packit 7cfc04
Create an event when a permission to read a file or directory is requested.
Packit 7cfc04
An fanotify file descriptor created with
Packit 7cfc04
.B FAN_CLASS_PRE_CONTENT
Packit 7cfc04
or
Packit 7cfc04
.B FAN_CLASS_CONTENT
Packit 7cfc04
is required.
Packit 7cfc04
.TP
Packit 7cfc04
.B FAN_ONDIR
Packit 7cfc04
Create events for directories\(emfor example, when
Packit 7cfc04
.BR opendir (3),
Packit 7cfc04
.BR readdir (3)
Packit 7cfc04
(but see BUGS), and
Packit 7cfc04
.BR closedir (3)
Packit 7cfc04
are called.
Packit 7cfc04
Without this flag, only events for files are created.
Packit 7cfc04
.TP
Packit 7cfc04
.B FAN_EVENT_ON_CHILD
Packit 7cfc04
Events for the immediate children of marked directories shall be created.
Packit 7cfc04
The flag has no effect when marking mounts.
Packit 7cfc04
Note that events are not generated for children of the subdirectories
Packit 7cfc04
of marked directories.
Packit 7cfc04
To monitor complete directory trees it is necessary to mark the relevant
Packit 7cfc04
mount.
Packit 7cfc04
.PP
Packit 7cfc04
The following composed value is defined:
Packit 7cfc04
.TP
Packit 7cfc04
.B FAN_CLOSE
Packit 7cfc04
A file is closed
Packit 7cfc04
.RB ( FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE ).
Packit 7cfc04
.PP
Packit 7cfc04
The filesystem object to be marked is determined by the file descriptor
Packit 7cfc04
.I dirfd
Packit 7cfc04
and the pathname specified in
Packit 7cfc04
.IR pathname :
Packit 7cfc04
.IP * 3
Packit 7cfc04
If
Packit 7cfc04
.I pathname
Packit 7cfc04
is NULL,
Packit 7cfc04
.I dirfd
Packit 7cfc04
defines the filesystem object to be marked.
Packit 7cfc04
.IP *
Packit 7cfc04
If
Packit 7cfc04
.I pathname
Packit 7cfc04
is NULL, and
Packit 7cfc04
.I dirfd
Packit 7cfc04
takes the special value
Packit 7cfc04
.BR AT_FDCWD ,
Packit 7cfc04
the current working directory is to be marked.
Packit 7cfc04
.IP *
Packit 7cfc04
If
Packit 7cfc04
.I pathname
Packit 7cfc04
is absolute, it defines the filesystem object to be marked, and
Packit 7cfc04
.I dirfd
Packit 7cfc04
is ignored.
Packit 7cfc04
.IP *
Packit 7cfc04
If
Packit 7cfc04
.I pathname
Packit 7cfc04
is relative, and
Packit 7cfc04
.I dirfd
Packit 7cfc04
does not have the value
Packit 7cfc04
.BR AT_FDCWD ,
Packit 7cfc04
then the filesystem object to be marked is determined by interpreting
Packit 7cfc04
.I pathname
Packit 7cfc04
relative the directory referred to by
Packit 7cfc04
.IR dirfd .
Packit 7cfc04
.IP *
Packit 7cfc04
If
Packit 7cfc04
.I pathname
Packit 7cfc04
is relative, and
Packit 7cfc04
.I dirfd
Packit 7cfc04
has the value
Packit 7cfc04
.BR AT_FDCWD ,
Packit 7cfc04
then the filesystem object to be marked is determined by interpreting
Packit 7cfc04
.I pathname
Packit 7cfc04
relative the current working directory.
Packit 7cfc04
.SH RETURN VALUE
Packit 7cfc04
On success,
Packit 7cfc04
.BR fanotify_mark ()
Packit 7cfc04
returns 0.
Packit 7cfc04
On error, \-1 is returned, and
Packit 7cfc04
.I errno
Packit 7cfc04
is set to indicate the error.
Packit 7cfc04
.SH ERRORS
Packit 7cfc04
.TP
Packit 7cfc04
.B EBADF
Packit 7cfc04
An invalid file descriptor was passed in
Packit 7cfc04
.IR fanotify_fd .
Packit 7cfc04
.TP
Packit 7cfc04
.B EINVAL
Packit 7cfc04
An invalid value was passed in
Packit 7cfc04
.IR flags
Packit 7cfc04
or
Packit 7cfc04
.IR mask ,
Packit 7cfc04
or
Packit 7cfc04
.I fanotify_fd
Packit 7cfc04
was not an fanotify file descriptor.
Packit 7cfc04
.TP
Packit 7cfc04
.B EINVAL
Packit 7cfc04
The fanotify file descriptor was opened with
Packit 7cfc04
.B FAN_CLASS_NOTIF
Packit 7cfc04
and mask contains a flag for permission events
Packit 7cfc04
.RB ( FAN_OPEN_PERM
Packit 7cfc04
or
Packit 7cfc04
.BR FAN_ACCESS_PERM ).
Packit 7cfc04
.TP
Packit 7cfc04
.B ENOENT
Packit 7cfc04
The filesystem object indicated by
Packit 7cfc04
.IR dirfd
Packit 7cfc04
and
Packit 7cfc04
.IR pathname
Packit 7cfc04
does not exist.
Packit 7cfc04
This error also occurs when trying to remove a mark from an object
Packit 7cfc04
which is not marked.
Packit 7cfc04
.TP
Packit 7cfc04
.B ENOMEM
Packit 7cfc04
The necessary memory could not be allocated.
Packit 7cfc04
.TP
Packit 7cfc04
.B ENOSPC
Packit 7cfc04
The number of marks exceeds the limit of 8192 and the
Packit 7cfc04
.B FAN_UNLIMITED_MARKS
Packit 7cfc04
flag was not specified when the fanotify file descriptor was created with
Packit 7cfc04
.BR fanotify_init (2).
Packit 7cfc04
.TP
Packit 7cfc04
.B ENOSYS
Packit 7cfc04
This kernel does not implement
Packit 7cfc04
.BR fanotify_mark ().
Packit 7cfc04
The fanotify API is available only if the kernel was configured with
Packit 7cfc04
.BR CONFIG_FANOTIFY .
Packit 7cfc04
.TP
Packit 7cfc04
.B ENOTDIR
Packit 7cfc04
.I flags
Packit 7cfc04
contains
Packit 7cfc04
.BR FAN_MARK_ONLYDIR ,
Packit 7cfc04
and
Packit 7cfc04
.I dirfd
Packit 7cfc04
and
Packit 7cfc04
.I pathname
Packit 7cfc04
do not specify a directory.
Packit 7cfc04
.SH VERSIONS
Packit 7cfc04
.BR fanotify_mark ()
Packit 7cfc04
was introduced in version 2.6.36 of the Linux kernel and enabled in version
Packit 7cfc04
2.6.37.
Packit 7cfc04
.SH CONFORMING TO
Packit 7cfc04
This system call is Linux-specific.
Packit 7cfc04
.SH BUGS
Packit 7cfc04
The following bugs were present in Linux kernels before version 3.16:
Packit 7cfc04
.IP * 3
Packit 7cfc04
.\" Fixed by commit 0a8dd2db579f7a0ac7033d6b857c3d5dbaa77563
Packit 7cfc04
If
Packit 7cfc04
.I flags
Packit 7cfc04
contains
Packit 7cfc04
.BR FAN_MARK_FLUSH ,
Packit 7cfc04
.I dirfd
Packit 7cfc04
and
Packit 7cfc04
.I pathname
Packit 7cfc04
must specify a valid filesystem object, even though this object is not used.
Packit 7cfc04
.IP *
Packit 7cfc04
.\" Fixed by commit d4c7cf6cffb1bc711a833b5e304ba5bcfe76398b
Packit 7cfc04
.BR readdir (2)
Packit 7cfc04
does not generate a
Packit 7cfc04
.B FAN_ACCESS
Packit 7cfc04
event.
Packit 7cfc04
.IP *
Packit 7cfc04
.\" Fixed by commit cc299a98eb13a9853675a9cbb90b30b4011e1406
Packit 7cfc04
If
Packit 7cfc04
.BR fanotify_mark ()
Packit 7cfc04
is called with
Packit 7cfc04
.BR FAN_MARK_FLUSH ,
Packit 7cfc04
.I flags
Packit 7cfc04
is not checked for invalid values.
Packit 7cfc04
.SH SEE ALSO
Packit 7cfc04
.BR fanotify_init (2),
Packit 7cfc04
.BR fanotify (7)
Packit 7cfc04
.SH COLOPHON
Packit 7cfc04
This page is part of release 4.15 of the Linux
Packit 7cfc04
.I man-pages
Packit 7cfc04
project.
Packit 7cfc04
A description of the project,
Packit 7cfc04
information about reporting bugs,
Packit 7cfc04
and the latest version of this page,
Packit 7cfc04
can be found at
Packit 7cfc04
\%https://www.kernel.org/doc/man\-pages/.