From 13ceb77f59f5d001ba3e71dff75340278d8a73a8 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Sun, 3 Mar 2019 17:40:32 +0100 Subject: rwc: add -c to detect all file creations --- rwc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'rwc.c') diff --git a/rwc.c b/rwc.c index 4ff2b1a..c828644 100644 --- a/rwc.c +++ b/rwc.c @@ -1,6 +1,7 @@ /* - * rwc [-0dep] [PATH...] - report when changed + * rwc [-0cdep] [PATH...] - report when changed * -0 use NUL instead of newline for input/output separator + * -c detect all creations (open/O_CREAT, mkdir, link, symlink, bind) * -d detect deletions too (prefixed with "- ") * -e exit after the first reported change * -p pipe mode, don't generate new events if stdout pipe is not empty @@ -27,6 +28,7 @@ char *argv0; char ibuf[8192]; int ifd; +int cflag; int dflag; int eflag; int pflag; @@ -75,7 +77,8 @@ add(char *file) if (lstat(file, &st) < 0 || !S_ISDIR(st.st_mode)) dir = dirname(file); - wd = inotify_add_watch(ifd, dir, IN_MOVED_TO | IN_CLOSE_WRITE | dflag); + wd = inotify_add_watch(ifd, dir, + IN_MOVED_TO | IN_CLOSE_WRITE | cflag | dflag); if (wd < 0) { fprintf(stderr, "%s: inotify_add_watch: %s: %s\n", argv0, dir, strerror(errno)); @@ -95,14 +98,15 @@ main(int argc, char *argv[]) argv0 = argv[0]; - while ((c = getopt(argc, argv, "0dep")) != -1) + while ((c = getopt(argc, argv, "0cdep")) != -1) switch (c) { case '0': input_delim = 0; break; + case 'c': cflag = IN_CREATE; break; case 'd': dflag = IN_DELETE|IN_DELETE_SELF|IN_MOVED_FROM; break; case 'e': eflag++; break; case 'p': pflag++; break; default: - fprintf(stderr, "Usage: %s [-0dep] [PATH...]\n", argv0); + fprintf(stderr, "Usage: %s [-0cdep] [PATH...]\n", argv0); exit(2); } -- cgit 1.4.1