summaryrefslogtreecommitdiff
path: root/src/journal/journal-vacuum.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-10-02 22:39:24 +0200
committerLennart Poettering <lennart@poettering.net>2015-10-02 22:39:24 +0200
commit7b5195e2740799a5e94cfafdcf8f6d6699c1b8af (patch)
treeb1de57ec481d6d71017181948b066df6d44210d3 /src/journal/journal-vacuum.c
parent84267e4043cf88bf540b5bf9cd65e194670a4ffa (diff)
journal: don't affect atime of journal files when vacuuming
Let's try to use O_NOATIME if we can when vacuuming old journal files, if we have the permissions for it, so that vacuuming doesn't count as proper journal read access.
Diffstat (limited to 'src/journal/journal-vacuum.c')
-rw-r--r--src/journal/journal-vacuum.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/journal/journal-vacuum.c b/src/journal/journal-vacuum.c
index 8c642d16e4..394f7be46b 100644
--- a/src/journal/journal-vacuum.c
+++ b/src/journal/journal-vacuum.c
@@ -112,9 +112,13 @@ static int journal_file_empty(int dir_fd, const char *name) {
le64_t n_entries;
ssize_t n;
- fd = openat(dir_fd, name, O_RDONLY|O_CLOEXEC|O_NOFOLLOW|O_NONBLOCK);
- if (fd < 0)
- return -errno;
+ fd = openat(dir_fd, name, O_RDONLY|O_CLOEXEC|O_NOFOLLOW|O_NONBLOCK|O_NOATIME);
+ if (fd < 0) {
+ /* Maybe failed due to O_NOATIME and lack of privileges? */
+ fd = openat(dir_fd, name, O_RDONLY|O_CLOEXEC|O_NOFOLLOW|O_NONBLOCK);
+ if (fd < 0)
+ return -errno;
+ }
if (fstat(fd, &st) < 0)
return -errno;