From 3b0d7556897bd0fb296081ae5b4d4866409e7d2f Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Sun, 20 Aug 2006 18:03:37 +0200 Subject: Cleanup --- inotail.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/inotail.c b/inotail.c index afcc1f7..c7c20c8 100644 --- a/inotail.c +++ b/inotail.c @@ -37,9 +37,9 @@ #include "inotail.h" -#define PROGRAM_NAME "inotail" +#define PROGRAM_NAME "inotail" #ifndef VERSION -#define VERSION "undef" +# define VERSION "undef" #endif #define BUFFER_SIZE 4096 @@ -213,20 +213,21 @@ static int watch_files(struct file_struct *f, int n_files) offset = fil->st_size; - dprintf(" File '%s' modified.\n", fil->name); - dprintf(" offset: %lu.\n", offset); + dprintf(" File '%s' modified, offset: %lu.\n", fil->name, offset); fil->fd = open(fil->name, O_RDONLY); if (fil->fd < 0) { fil->ignore = 1; n_ignored++; fprintf(stderr, "Error: Could not open file '%s' (%s)\n", f->name, strerror(errno)); + continue; } if (fstat(fil->fd, &finfo) < 0) { fil->ignore = 1; n_ignored++; fprintf(stderr, "Error: Could not stat file '%s' (%s)\n", f->name, strerror(errno)); + continue; } fil->st_size = finfo.st_size; @@ -252,20 +253,16 @@ static int watch_files(struct file_struct *f, int n_files) } close(fil->fd); - } - - if (inev->mask & IN_DELETE_SELF) { + } else if (inev->mask & IN_DELETE_SELF) { fil->ignore = 1; n_ignored++; fprintf(stderr, "File '%s' deleted.\n", fil->name); - } - if (inev->mask & IN_MOVE_SELF) { + } else if (inev->mask & IN_MOVE_SELF) { fil->ignore = 1; n_ignored++; fprintf(stderr, "File '%s' moved.\n", fil->name); /* TODO: Try to follow file/fd */ - } - if (inev->mask & IN_UNMOUNT) { + } else if (inev->mask & IN_UNMOUNT) { fil->ignore = 1; n_ignored++; fprintf(stderr, "Device containing file '%s' unmounted.\n", fil->name); -- cgit v1.2.3-54-g00ecf