diff options
-rw-r--r-- | inotify-watch.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/inotify-watch.c b/inotify-watch.c index 7ccf9c4..ccedf2f 100644 --- a/inotify-watch.c +++ b/inotify-watch.c @@ -4,7 +4,8 @@ * Watch a file or directory for changes using inotify * * Copyright (c) Tobias Klauser <tklauser@distanz.ch> - * All rights reserved + * + * All rights reserved. */ #include <stdio.h> @@ -12,10 +13,8 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> -#include <sys/syscall.h> -#include "inotify.h" -#include "inotify-syscalls.h" +#include <sys/inotify.h> struct mask2string { uint32_t mask; @@ -53,7 +52,8 @@ static void inotify_print_event(struct inotify_event *inev) /* stat? */ printf("(%s) wd=%04x, cookie=%04x, len=%04x, name=\"%s\" :", - inev->mask & IN_ISDIR ? "dir" : "file", inev->wd, inev->cookie, inev->len, inev->name); + inev->mask & IN_ISDIR ? "dir" : "file", + inev->wd, inev->cookie, inev->len, inev->name); for (i = 0; events[i].desc; i++) if (inev->mask & events[i].mask) @@ -82,7 +82,7 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - watches = malloc(argc * sizeof(int)); + watches = malloc((argc - 1) * sizeof(int)); if (!watches) { perror("malloc"); exit(EXIT_FAILURE); @@ -105,7 +105,8 @@ int main(int argc, char *argv[]) inotify_print_event(inev); len -= sizeof(struct inotify_event) + inev->len; - inev = (struct inotify_event *) ((char *) inev + sizeof(struct inotify_event) + inev->len); + inev = (struct inotify_event *) ((char *) inev + + sizeof(struct inotify_event) + inev->len); } } |