]> git.ipfire.org Git - thirdparty/man-pages.git/blob - 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
1 .\" Copyright (C) 2005 Robert Love
2 .\" and Copyright, 2006 Michael Kerrisk
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
20 .\" License along with this manual; if not, see
21 .\" <http://www.gnu.org/licenses/>.
22 .\"
23 .\" 2005-07-19 Robert Love <rlove@rlove.org> - initial version
24 .\" 2006-02-07 mtk, various changes
25 .\"
26 .TH INOTIFY_ADD_WATCH 2 2010-10-20 "Linux" "Linux Programmer's Manual"
27 .SH NAME
28 inotify_add_watch \- add a watch to an initialized inotify instance
29 .SH SYNOPSIS
30 .B #include <sys/inotify.h>
31 .sp
32 .BI "int inotify_add_watch(int " fd ", const char *" pathname ", uint32_t " mask );
33 .SH DESCRIPTION
34 .BR inotify_add_watch ()
35 adds a new watch, or modifies an existing watch,
36 for the file whose location is specified in
37 .IR pathname ;
38 the caller must have read permission for this file.
39 The
40 .I fd
41 argument is a file descriptor referring to the
42 inotify instance whose watch list is to be modified.
43 The events to be monitored for
44 .I pathname
45 are specified in the
46 .I mask
47 bit-mask argument.
48 See
49 .BR inotify (7)
50 for a description of the bits that can be set in
51 .IR mask .
52
53 A successful call to
54 .BR inotify_add_watch ()
55 returns the unique watch descriptor associated with
56 .I pathname
57 for this inotify instance.
58 If
59 .I pathname
60 was not previously being watched by this inotify instance,
61 then the watch descriptor is newly allocated.
62 If
63 .I pathname
64 was already being watched, then the descriptor
65 for the existing watch is returned.
66
67 The watch descriptor is returned by later
68 .BR read (2)s
69 from the inotify file descriptor.
70 These reads fetch
71 .I inotify_event
72 structures (see
73 .BR inotify (7))
74 indicating file system events;
75 the watch descriptor inside this structure identifies
76 the object for which the event occurred.
77 .SH RETURN VALUE
78 On success,
79 .BR inotify_add_watch ()
80 returns a nonnegative watch descriptor.
81 On error \-1 is returned and
82 .I errno
83 is set appropriately.
84 .SH ERRORS
85 .TP
86 .B EACCES
87 Read access to the given file is not permitted.
88 .TP
89 .B EBADF
90 The given file descriptor is not valid.
91 .TP
92 .B EFAULT
93 .I pathname
94 points outside of the process's accessible address space.
95 .TP
96 .B EINVAL
97 The given event mask contains no valid events; or
98 .I fd
99 is not an inotify file descriptor.
100 .TP
101 .B ENOENT
102 A directory component in
103 .I pathname
104 does not exist or is a dangling symbolic link.
105 .TP
106 .B ENOMEM
107 Insufficient kernel memory was available.
108 .TP
109 .B ENOSPC
110 The user limit on the total number of inotify watches was reached or the
111 kernel failed to allocate a needed resource.
112 .SH VERSIONS
113 Inotify was merged into the 2.6.13 Linux kernel.
114 .SH CONFORMING TO
115 This system call is Linux-specific.
116 .SH SEE ALSO
117 .BR inotify_init (2),
118 .BR inotify_rm_watch (2),
119 .BR inotify (7)