summaryrefslogtreecommitdiff
path: root/inotail.h
diff options
context:
space:
mode:
authorDominguez Bonini, David <dominguez.d@ikusi.es>2009-10-30 15:24:20 +0100
committerTobias Klauser <klto@zhaw.ch>2009-10-30 15:27:31 +0100
commit727e55497fa03e9312c1e73bea005233aa03c8d6 (patch)
tree166b6b9ec123b859bf4b9e3593afec2fff06ca96 /inotail.h
parent3a7017f169c598356d406f5c941cb463536f5e11 (diff)
inotail: Support reopening rotated files
We changed the behaviour of the "follow" option so that it detects that file has been moved or deleted it keeps monitoring for the file instead of ignoring it. This is useful when tailing syslog circular logs, where syslog periodically moves the log to another filename and recreates the log file. Without the patch inotail would issue a "file has been moved" or a "file has been deleted message" and stop tracking the file. Now it will close the file and refresh the inotify +descriptor. When a notification arrives with a CREATE or MODIFY event, it will reopen the file and set the size to zero. We are using the patched program in an embedded ARM system with satisfactory results.
Diffstat (limited to 'inotail.h')
-rw-r--r--inotail.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/inotail.h b/inotail.h
index 5b0ef0c..3320c3d 100644
--- a/inotail.h
+++ b/inotail.h
@@ -10,10 +10,13 @@
#include <sys/types.h>
#include <sys/inotify.h>
-#define DEFAULT_N_LINES 10 /* Number of items to tail. */
-
+/* Number of items to tail. */
+#define DEFAULT_N_LINES 10
/* inotify event buffer length for one file */
-#define INOTIFY_BUFLEN (4 * sizeof(struct inotify_event))
+#define INOTIFY_BUFLEN (4 * sizeof(struct inotify_event))
+/* inotify events to watch for on tailed files */
+#define INOTAIL_WATCH_MASK \
+ (IN_MODIFY|IN_DELETE_SELF|IN_MOVE_SELF|IN_UNMOUNT|IN_CREATE)
/* tail modes */
enum tail_mode { M_LINES, M_BYTES };