1INOTIFY_ADD_WATCH(2)       Linux Programmer's Manual      INOTIFY_ADD_WATCH(2)
2
3
4

NAME

6       inotify_add_watch - add a watch to an initialized inotify instance
7

SYNOPSIS

9       #include <sys/inotify.h>
10
11       int inotify_add_watch(int fd, const char *pathname, uint32_t mask);
12

DESCRIPTION

14       inotify_add_watch()  adds  a  new watch, or modifies an existing watch,
15       for the file whose location is specified in pathname; the  caller  must
16       have read permission for this file.  The fd argument is a file descrip‐
17       tor referring to the inotify instance whose watch list is to  be  modi‐
18       fied.   The  events  to  be monitored for pathname are specified in the
19       mask bit-mask argument.  See inotify(7) for a description of  the  bits
20       that can be set in mask.
21
22       A  successful  call  to  inotify_add_watch()  returns  the unique watch
23       descriptor associated with pathname  for  this  inotify  instance.   If
24       pathname  was  not  previously  being watched by this inotify instance,
25       then the watch descriptor is newly allocated.  If pathname was  already
26       being watched, then the descriptor for the existing watch is returned.
27
28       The  watch  descriptor  is  returned by later read(2)s from the inotify
29       file descriptor.  These reads fetch inotify_event structures (see  ino‐
30       tify(7))  indicating  file  system  events; the watch descriptor inside
31       this structure identifies the object for which the event occurred.
32

RETURN VALUE

34       On success, inotify_add_watch() returns a nonnegative watch descriptor.
35       On error -1 is returned and errno is set appropriately.
36

ERRORS

38       EACCES Read access to the given file is not permitted.
39
40       EBADF  The given file descriptor is not valid.
41
42       EFAULT pathname  points  outside  of  the  process's accessible address
43              space.
44
45       EINVAL The given event mask contains no valid events; or fd is  not  an
46              inotify file descriptor.
47
48       ENOMEM Insufficient kernel memory was available.
49
50       ENOSPC The  user  limit  on  the  total  number  of inotify watches was
51              reached or the kernel failed to allocate a needed resource.
52

VERSIONS

54       Inotify was merged into the 2.6.13 Linux kernel.
55

CONFORMING TO

57       This system call is Linux-specific.
58

SEE ALSO

60       inotify_init(2), inotify_rm_watch(2), inotify(7)
61

COLOPHON

63       This page is part of release 3.25 of the Linux  man-pages  project.   A
64       description  of  the project, and information about reporting bugs, can
65       be found at http://www.kernel.org/doc/man-pages/.
66
67
68
69Linux                             2006-02-07              INOTIFY_ADD_WATCH(2)
Impressum