On success, inotify_init() returns a new file descriptor, or -1 if an error occurred (in which case, errno is set appropriately).
struct inotify_event {
int wd; /* Watch descriptor */
uint32_t mask; /* Mask of events */
uint32_t cookie; /* Unique cookie associating related
events (for rename(2)) */
uint32_t len; /* Size of 'name' field */
char name[]; /* Optional null-terminated name */
};
inotify_add_watch()
int inotify_add_watch(int fd, const char *pathname, uint32_t mask);
adds a new watch, or modifies an existing watch,
for the file whose location is specified in pathname; the caller must
have read permission for this file. The fd argument is a file descrip-
tor referring to the inotify instance whose watch list is to be modi-
fied. The events to be monitored for pathname are specified in the
mask bit-mask argument.
A successful call to inotify_add_watch() returns the unique watch
descriptor associated with pathname for this inotify instance. If
pathname was not previously being watched by this inotify instance,
then the watch descriptor is newly allocated. If pathname was already
being watched, then the descriptor for the existing watch is returned.
pathname: watch pathname
fd : fd = inotify_init()
mask: IN_MODIFY, IN_CREATE, IN_DELETE ....
On success, inotify_add_watch() returns a non-negative watch descriptor. On error -1 is returned and errno is set appropriately.