inotify_add_watch(2) System Calls Manual inotify_add_watch(2) inotify_add_watch - inotify C (libc, -lc) #include int inotify_add_watch(int fd, const char *path, uint32_t mask); inotify_add_watch() adds a new watch, or modifies an existing watch, for the file whose location is specified in path; the caller must have read permission for this file. The fd argument is a file descriptor referring to the inotify instance whose watch list is to be modified. The events to be monitored for path are specified in the mask bit-mask argument. See inotify(7) for a description of the bits that can be set in mask. A successful call to inotify_add_watch() returns a unique watch descriptor for this inotify instance, for the filesystem object (inode) that corresponds to path. If the filesystem object was not previously being watched by this inotify instance, then the watch descriptor is newly allocated. If the filesystem object was already being watched (perhaps via a different link to the same object), then the descriptor for the existing watch is returned. read(2) inotify. inotify_event (. inotify(7)), ; , . inotify_add_watch() ( ). -1, errno . EACCES . EBADF . EEXIST mask contains IN_MASK_CREATE and path refers to a file already being watched by the same fd. EFAULT path points outside of the process's accessible address space. EINVAL ; mask IN_MASK_ADD IN_MASK_CREATE ; fd inotify. ENAMETOOLONG path . ENOENT A directory component in path does not exist or is a dangling symbolic link. ENOMEM . ENOSPC inotify . ENOTDIR mask contains IN_ONLYDIR and path is not a directory. Linux. Linux 2.6.13. inotify(7). inotify_init(2), inotify_rm_watch(2), inotify(7) () Azamat Hackimov , Dmitriy S. Seregin , Yuri Kozlov ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () . Linux man-pages 6.18 8 2026 . inotify_add_watch(2)