1 .\" Copyright (C) 2005 Robert Love
2 .\" and Copyright, 2006 Michael Kerrisk
4 .\" SPDX-License-Identifier: GPL-2.0-or-later
6 .\" 2005-07-19 Robert Love <rlove@rlove.org> - initial version
7 .\" 2006-02-07 mtk, various changes
9 .TH INOTIFY_ADD_WATCH 2 (date) "Linux man-pages (unreleased)"
11 inotify_add_watch \- add a watch to an initialized inotify instance
14 .RI ( libc ", " \-lc )
17 .B #include <sys/inotify.h>
19 .BI "int inotify_add_watch(int " fd ", const char *" pathname ", uint32_t " mask );
22 .BR inotify_add_watch ()
23 adds a new watch, or modifies an existing watch,
24 for the file whose location is specified in
26 the caller must have read permission for this file.
29 argument is a file descriptor referring to the
30 inotify instance whose watch list is to be modified.
31 The events to be monitored for
38 for a description of the bits that can be set in
42 .BR inotify_add_watch ()
43 returns a unique watch descriptor for this inotify instance,
44 for the filesystem object (inode) that corresponds to
46 If the filesystem object
47 was not previously being watched by this inotify instance,
48 then the watch descriptor is newly allocated.
49 If the filesystem object was already being watched
50 (perhaps via a different link to the same object), then the descriptor
51 for the existing watch is returned.
53 The watch descriptor is returned by later
55 from the inotify file descriptor.
60 indicating filesystem events;
61 the watch descriptor inside this structure identifies
62 the object for which the event occurred.
65 .BR inotify_add_watch ()
66 returns a watch descriptor (a nonnegative integer).
67 On error, \-1 is returned and
69 is set to indicate the error.
73 Read access to the given file is not permitted.
76 The given file descriptor is not valid.
84 refers to a file already being watched by the same
89 points outside of the process's accessible address space.
92 The given event mask contains no valid events; or
100 is not an inotify file descriptor.
107 A directory component in
109 does not exist or is a dangling symbolic link.
112 Insufficient kernel memory was available.
115 The user limit on the total number of inotify watches was reached or the
116 kernel failed to allocate a needed resource.
126 Inotify was merged into the 2.6.13 Linux kernel.
128 This system call is Linux-specific.
133 .BR inotify_init (2),
134 .BR inotify_rm_watch (2),