1 .\" Copyright (C) 2005 Robert Love
2 .\" and Copyright, 2006 Michael Kerrisk
4 .\" %%%LICENSE_START(GPLv2+_DOC_FULL)
5 .\" This is free documentation; you can redistribute it and/or
6 .\" modify it under the terms of the GNU General Public License as
7 .\" published by the Free Software Foundation; either version 2 of
8 .\" the License, or (at your option) any later version.
10 .\" The GNU General Public License's references to "object code"
11 .\" and "executables" are to be interpreted as the output of any
12 .\" document formatting or typesetting system, including
13 .\" intermediate and printed output.
15 .\" This manual is distributed in the hope that it will be useful,
16 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
17 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 .\" GNU General Public License for more details.
20 .\" You should have received a copy of the GNU General Public
21 .\" License along with this manual; if not, see
22 .\" <http://www.gnu.org/licenses/>.
25 .\" 2005-07-19 Robert Love <rlove@rlove.org> - initial version
26 .\" 2006-02-07 mtk, various changes
28 .TH INOTIFY_ADD_WATCH 2 2017-09-15 "Linux" "Linux Programmer's Manual"
30 inotify_add_watch \- add a watch to an initialized inotify instance
32 .B #include <sys/inotify.h>
34 .BI "int inotify_add_watch(int " fd ", const char *" pathname ", uint32_t " mask );
36 .BR inotify_add_watch ()
37 adds a new watch, or modifies an existing watch,
38 for the file whose location is specified in
40 the caller must have read permission for this file.
43 argument is a file descriptor referring to the
44 inotify instance whose watch list is to be modified.
45 The events to be monitored for
52 for a description of the bits that can be set in
56 .BR inotify_add_watch ()
57 returns a unique watch descriptor for this inotify instance,
58 for the filesystem object (inode) that corresponds to
60 If the filesystem object
61 was not previously being watched by this inotify instance,
62 then the watch descriptor is newly allocated.
63 If the filesystem object was already being watched
64 (perhaps via a different link to the same object), then the descriptor
65 for the existing watch is returned.
67 The watch descriptor is returned by later
69 from the inotify file descriptor.
74 indicating filesystem events;
75 the watch descriptor inside this structure identifies
76 the object for which the event occurred.
79 .BR inotify_add_watch ()
80 returns a nonnegative watch descriptor.
81 On error, \-1 is returned and
87 Read access to the given file is not permitted.
90 The given file descriptor is not valid.
94 points outside of the process's accessible address space.
97 The given event mask contains no valid events; or
99 is not an inotify file descriptor.
106 A directory component in
108 does not exist or is a dangling symbolic link.
111 Insufficient kernel memory was available.
114 The user limit on the total number of inotify watches was reached or the
115 kernel failed to allocate a needed resource.
125 Inotify was merged into the 2.6.13 Linux kernel.
127 This system call is Linux-specific.
129 .BR inotify_init (2),
130 .BR inotify_rm_watch (2),