summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-01-04 02:16:38 +0100
committerLennart Poettering <lennart@poettering.net>2012-01-04 02:16:38 +0100
commit4bbdcdb301f8ef6f8b9e943210ab61250003c517 (patch)
tree9402cde1e2dbf4167ede14f252b5feb6187eaf55 /src/journal
parentb788cc23aa50682fe80c1b78cc5e42aaf7d76bc5 (diff)
journal: apply seek check before resizing window, and refresh stat data if necessary
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/journal-file.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 15a752d507..977cfa1010 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -296,6 +296,15 @@ static int journal_file_move_to(JournalFile *f, int wt, uint64_t offset, uint64_
assert(wt >= 0);
assert(wt < _WINDOW_MAX);
+ if (offset + size > (uint64_t) f->last_stat.st_size) {
+ /* Hmm, out of range? Let's refresh the fstat() data
+ * first, before we trust that check. */
+
+ if (fstat(f->fd, &f->last_stat) < 0 ||
+ offset + size > (uint64_t) f->last_stat.st_size)
+ return -EADDRNOTAVAIL;
+ }
+
w = f->windows + wt;
if (_likely_(w->ptr &&
@@ -331,9 +340,6 @@ static int journal_file_move_to(JournalFile *f, int wt, uint64_t offset, uint64_
} else
delta = 0;
- if (offset > (uint64_t) f->last_stat.st_size)
- return -EADDRNOTAVAIL;
-
if (offset + size > (uint64_t) f->last_stat.st_size)
size = PAGE_ALIGN((uint64_t) f->last_stat.st_size - offset);