wendy

inotify based node watcher
git clone git://git.2f30.org/wendy
Log | Files | Refs | README | LICENSE

commit 12e2d648b0f26ae584f1ed4d6277f13e94be3301
parent 4d64b76fa2f60a37c5a2edc70b9d5e27c338a2c2
Author: Willy Goiffon <dev@z3bra.org>
Date:   Wed,  4 Mar 2020 14:13:06 +0100

Treat IN_IGNORED as any other event

Diffstat:
Mwendy.c | 17+++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/wendy.c b/wendy.c @@ -109,7 +109,6 @@ main (int argc, char **argv) uint8_t buf[EVSZ]; uint32_t mask = MASK; ssize_t len, off = 0; - char path[PATH_MAX]; char **cmd, *argv0 = NULL; struct watcher *tmp, *w; struct inotify_event *e; @@ -176,28 +175,26 @@ main (int argc, char **argv) wait(NULL); } - switch(e->mask & IN_ALL_EVENTS) { + switch(e->mask & IN_ALL_EVENTS|IN_IGNORED) { case IN_CREATE: /* Watch subdirectories upon creation */ - if (rflag) { - snprintf(path, PATH_MAX, "%s/%s", w->path, e->name); - watch(fd, path, mask); - } + if (rflag) + watch(fd, wdpath(e, w), mask); break; - } /* * IN_IGNORED is triggered when a file watched * doesn't exists anymore. In this case we first try to - * add the watcher back, and if it fails, remove the - * watcher completely. + * watch it again (in case it was recreated), and if it + * fails, remove the watcher completely. */ - if (e->mask & IN_IGNORED) { + case IN_IGNORED: inotify_rm_watch(fd, e->wd); if ((w->wd = inotify_add_watch(fd, w->path, mask)) < 0) { SLIST_REMOVE(&head, w, watcher, entries); free(w); } + break; } skip: