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