1 .\" man2/inotify_add_watch.2 - inotify_add_watch man page
3 .\" Copyright (C) 2005 Robert Love
4 .\" and Copyright, 2006 Michael Kerrisk
6 .\" This is free documentation; you can redistribute it and/or
7 .\" modify it under the terms of the GNU General Public License as
8 .\" published by the Free Software Foundation; either version 2 of
9 .\" the License, or (at your option) any later version.
11 .\" The GNU General Public License's references to "object code"
12 .\" and "executables" are to be interpreted as the output of any
13 .\" document formatting or typesetting system, including
14 .\" intermediate and printed output.
16 .\" This manual is distributed in the hope that it will be useful,
17 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
18 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 .\" GNU General Public License for more details.
21 .\" You should have received a copy of the GNU General Public
22 .\" License along with this manual; if not, write to the Free
23 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
26 .\" 2005-07-19 Robert Love <rlove@rlove.org> - initial version
27 .\" 2006-02-07 mtk, various changes
29 .TH INOTIFY_ADD_WATCH 2 2006-02-07 "Linux" "Linux Programmer's Manual"
31 inotify_add_watch \- add a watch to an initialized inotify instance
33 .B #include <sys/inotify.h>
35 .BI "int inotify_add_watch(int " fd ", const char *" pathname ", uint32_t " mask );
37 .BR inotify_add_watch ()
38 adds a new watch, or modifies an existing watch,
39 for the file whose location is specified in
41 the caller must have read permission for this file.
44 argument is a file descriptor referring to the
45 inotify instance whose watch list is to be modified.
46 The events to be monitored for
53 for a description of the bits that can be set in
57 .BR inotify_add_watch ()
58 returns the unique watch descriptor associated with
60 for this inotify instance.
63 was not previously being watched by this inotify instance,
64 then the watch descriptor is newly allocated.
67 was already being watched, then the descriptor
68 for the existing watch is returned.
70 The watch descriptor is returned by later
72 from the inotify file descriptor.
77 indicating file system events;
78 the watch descriptor inside this structure identifies
79 the object for which the event occurred.
82 .BR inotify_add_watch ()
83 returns a nonnegative watch descriptor.
84 On error \-1 is returned and
90 Read access to the given file is not permitted.
93 The given file descriptor is not valid.
97 points outside of the process's accessible address space.
100 The given event mask contains no valid events; or
102 is not an inotify file descriptor.
105 Insufficient kernel memory was available.
108 The user limit on the total number of inotify watches was reached or the
109 kernel failed to allocate a needed resource.
111 Inotify was merged into the 2.6.13 Linux kernel.
113 This system call is Linux-specific.
115 .BR inotify_init (2),
116 .BR inotify_rm_watch (2),