summaryrefslogtreecommitdiff
path: root/src/journal/journal-file.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-12-19 22:35:46 +0100
committerLennart Poettering <lennart@poettering.net>2011-12-19 22:35:46 +0100
commit50f20cfdb0f127e415ab38c024d9ca7a3602f74b (patch)
treeb8d2296305986c6aac11bad146d591a5638b642c /src/journal/journal-file.c
parent76318284fc970b30e9dc4c079960807345331dad (diff)
journal: implement inotify-based live logging logic
Diffstat (limited to 'src/journal/journal-file.c')
-rw-r--r--src/journal/journal-file.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 427631d30a..7626743248 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -879,6 +879,18 @@ static int journal_file_append_entry_internal(
return 0;
}
+static void journal_file_post_change(JournalFile *f) {
+ assert(f);
+
+ /* inotify() does not receive IN_MODIFY events from file
+ * accesses done via mmap(). After each access we hence
+ * trigger IN_MODIFY by truncating the journal file to its
+ * current size which triggers IN_MODIFY. */
+
+ if (ftruncate(f->fd, f->last_stat.st_size) < 0)
+ log_error("Failed to to truncate file to its own size: %m");
+}
+
int journal_file_append_entry(JournalFile *f, const dual_timestamp *ts, const struct iovec iovec[], unsigned n_iovec, uint64_t *seqnum, Object **ret, uint64_t *offset) {
unsigned i;
EntryItem *items;
@@ -923,6 +935,8 @@ int journal_file_append_entry(JournalFile *f, const dual_timestamp *ts, const st
r = journal_file_append_entry_internal(f, ts, xor_hash, items, n_iovec, seqnum, ret, offset);
+ journal_file_post_change(f);
+
finish:
free(items);