]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/inotify_add_watch.2
getent.1, _syscall.2, acct.2, adjtimex.2, bdflush.2, brk.2, cacheflush.2, getsid...
[thirdparty/man-pages.git] / man2 / inotify_add_watch.2
CommitLineData
efa25b17
MK
1.\" Copyright (C) 2005 Robert Love
2.\" and Copyright, 2006 Michael Kerrisk
4d2b74dd
MK
3.\"
4.\" This is free documentation; you can redistribute it and/or
5.\" modify it under the terms of the GNU General Public License as
6.\" published by the Free Software Foundation; either version 2 of
7.\" the License, or (at your option) any later version.
8.\"
9.\" The GNU General Public License's references to "object code"
10.\" and "executables" are to be interpreted as the output of any
11.\" document formatting or typesetting system, including
12.\" intermediate and printed output.
13.\"
14.\" This manual is distributed in the hope that it will be useful,
15.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
16.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17.\" GNU General Public License for more details.
18.\"
19.\" You should have received a copy of the GNU General Public
c715f741
MK
20.\" License along with this manual; if not, see
21.\" <http://www.gnu.org/licenses/>.
4d2b74dd
MK
22.\"
23.\" 2005-07-19 Robert Love <rlove@rlove.org> - initial version
24.\" 2006-02-07 mtk, various changes
25.\"
6a03b9dd 26.TH INOTIFY_ADD_WATCH 2 2010-10-20 "Linux" "Linux Programmer's Manual"
4d2b74dd
MK
27.SH NAME
28inotify_add_watch \- add a watch to an initialized inotify instance
29.SH SYNOPSIS
6e969f22 30.B #include <sys/inotify.h>
4d2b74dd 31.sp
93440c02 32.BI "int inotify_add_watch(int " fd ", const char *" pathname ", uint32_t " mask );
4d2b74dd
MK
33.SH DESCRIPTION
34.BR inotify_add_watch ()
c13182ef 35adds a new watch, or modifies an existing watch,
dd28cb72
MK
36for the file whose location is specified in
37.IR pathname ;
38the caller must have read permission for this file.
c13182ef 39The
4d2b74dd 40.I fd
dd28cb72
MK
41argument is a file descriptor referring to the
42inotify instance whose watch list is to be modified.
43The events to be monitored for
44.I pathname
45are specified in the
46.I mask
47bit-mask argument.
4d2b74dd
MK
48See
49.BR inotify (7)
50for a description of the bits that can be set in
51.IR mask .
52
53A successful call to
54.BR inotify_add_watch ()
c13182ef 55returns the unique watch descriptor associated with
93440c02 56.I pathname
4d2b74dd 57for this inotify instance.
c13182ef 58If
93440c02 59.I pathname
4d2b74dd 60was not previously being watched by this inotify instance,
c13182ef 61then the watch descriptor is newly allocated.
4d2b74dd 62If
93440c02 63.I pathname
4d2b74dd
MK
64was already being watched, then the descriptor
65for the existing watch is returned.
66
67The watch descriptor is returned by later
68.BR read (2)s
c13182ef 69from the inotify file descriptor.
4d2b74dd
MK
70These reads fetch
71.I inotify_event
325f18da
MK
72structures (see
73.BR inotify (7))
74indicating file system events;
75the watch descriptor inside this structure identifies
4d2b74dd 76the object for which the event occurred.
47297adb 77.SH RETURN VALUE
4d2b74dd
MK
78On success,
79.BR inotify_add_watch ()
2fda57bd 80returns a nonnegative watch descriptor.
4d2b74dd
MK
81On error \-1 is returned and
82.I errno
83is set appropriately.
84.SH ERRORS
85.TP
1b3fc756 86.B EACCES
4d2b74dd
MK
87Read access to the given file is not permitted.
88.TP
89.B EBADF
90The given file descriptor is not valid.
91.TP
92.B EFAULT
93440c02 93.I pathname
4d2b74dd
MK
94points outside of the process's accessible address space.
95.TP
96.B EINVAL
e935e108 97The given event mask contains no valid events; or
9f5774a9
MK
98.I fd
99is not an inotify file descriptor.
4d2b74dd 100.TP
6a03b9dd
MK
101.B ENOENT
102A directory component in
103.I pathname
104does not exist or is a dangling symbolic link.
105.TP
4d2b74dd
MK
106.B ENOMEM
107Insufficient kernel memory was available.
108.TP
109.B ENOSPC
110The user limit on the total number of inotify watches was reached or the
111kernel failed to allocate a needed resource.
ff457ccb 112.SH VERSIONS
4d2b74dd 113Inotify was merged into the 2.6.13 Linux kernel.
47297adb 114.SH CONFORMING TO
8382f16d 115This system call is Linux-specific.
47297adb 116.SH SEE ALSO
4d2b74dd 117.BR inotify_init (2),
c13182ef 118.BR inotify_rm_watch (2),
ccd2b351 119.BR inotify (7)