.\" the source, must acknowledge the copyright and authors of this work.
.\" %%%LICENSE_END
.\"
-.TH INOTIFY 7 2017-09-15 "Linux" "Linux Programmer's Manual"
+.TH INOTIFY 7 2019-03-06 "Linux" "Linux Programmer's Manual"
.SH NAME
inotify \- monitoring filesystem events
.SH DESCRIPTION
for a file inside a watched directory;
it identifies the filename within to the watched directory.
This filename is null-terminated,
-and may include further null bytes (\(aq\\0\(aq) to align subsequent reads to a
+and may include further null bytes (\(aq\e0\(aq) to align subsequent reads to a
suitable address boundary.
.PP
The
.IR pathname ,
add (OR) the events in
.I mask
-to the watch mask (instead of replacing the mask).
+to the watch mask (instead of replacing the mask);
+the error
+.B EINVAL
+results if
+.B IN_MASK_CREATE
+is also specified.
.TP
.B IN_ONESHOT
Monitor the filesystem object corresponding to
is not a directory.
Using this flag provides an application with a race-free way of
ensuring that the monitored object is a directory.
+.TP
+.BR IN_MASK_CREATE " (since Linux 4.18)"
+Watch
+.I pathname
+only if it does not already have a watch associated with it;
+the error
+.B EEXIST
+results if
+.I pathname
+is already being watched.
+.IP
+Using this flag provides an application with a way of ensuring
+that new watches do not modify existing ones.
+This is useful because multiple paths may refer to the same inode,
+and multiple calls to
+.BR inotify_add_watch (2)
+without this flag may clobber existing watch masks.
.RE
.PP
The following bits may be set in the
/* Print type of filesystem object */
if (event\->mask & IN_ISDIR)
- printf(" [directory]\\n");
+ printf(" [directory]\en");
else
- printf(" [file]\\n");
+ printf(" [file]\en");
}
}
}
struct pollfd fds[2];
if (argc < 2) {
- printf("Usage: %s PATH [PATH ...]\\n", argv[0]);
+ printf("Usage: %s PATH [PATH ...]\en", argv[0]);
exit(EXIT_FAILURE);
}
- printf("Press ENTER key to terminate.\\n");
+ printf("Press ENTER key to terminate.\en");
/* Create the file descriptor for accessing the inotify API */
wd[i] = inotify_add_watch(fd, argv[i],
IN_OPEN | IN_CLOSE);
if (wd[i] == \-1) {
- fprintf(stderr, "Cannot watch '%s'\\n", argv[i]);
+ fprintf(stderr, "Cannot watch '%s'\en", argv[i]);
perror("inotify_add_watch");
exit(EXIT_FAILURE);
}
/* Wait for events and/or terminal input */
- printf("Listening for events.\\n");
+ printf("Listening for events.\en");
while (1) {
poll_num = poll(fds, nfds, \-1);
if (poll_num == \-1) {
/* Console input is available. Empty stdin and quit */
- while (read(STDIN_FILENO, &buf, 1) > 0 && buf != '\\n')
+ while (read(STDIN_FILENO, &buf, 1) > 0 && buf != '\en')
continue;
break;
}
}
}
- printf("Listening for events stopped.\\n");
+ printf("Listening for events stopped.\en");
/* Close inotify file descriptor */