summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
authorJan Synacek <jsynacek@redhat.com>2016-02-01 09:23:58 +0100
committerJan Synacek <jsynacek@redhat.com>2016-02-01 11:59:27 +0100
commit39fd5b08a73f144a20202a665bd25cad51d8a90b (patch)
treec52246c727f6cda7aad57b5e5035e82c08c74e87 /src/journal
parentc25bf528a1ad0ef19d70882ddfd4d4eccba05bc7 (diff)
sd-journal: introduce has_runtime_files and has_persistent_files
Also introduce sd_journal_has_runtime_files() and sd_journal_has_persistent_files() to the public API. These functions can be used to easily find out if the open journal files are runtime and/or persistent.
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/journal-internal.h2
-rw-r--r--src/journal/sd-journal.c18
2 files changed, 20 insertions, 0 deletions
diff --git a/src/journal/journal-internal.h b/src/journal/journal-internal.h
index 9ff4fea7fb..fa5ca11636 100644
--- a/src/journal/journal-internal.h
+++ b/src/journal/journal-internal.h
@@ -115,6 +115,8 @@ struct sd_journal {
removed, and there were no more
files, so sd_j_enumerate_unique
will return a value equal to 0. */
+ bool has_runtime_files:1;
+ bool has_persistent_files:1;
size_t data_threshold;
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index cd5160154a..74a5e262f8 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -1292,6 +1292,12 @@ static int add_file(sd_journal *j, const char *prefix, const char *filename) {
return 0;
path = strjoina(prefix, "/", filename);
+
+ if (!j->has_runtime_files && path_startswith(path, "/run/log/journal"))
+ j->has_runtime_files = true;
+ else if (!j->has_persistent_files && path_startswith(path, "/var/log/journal"))
+ j->has_persistent_files = true;
+
return add_any_file(j, path);
}
@@ -2630,3 +2636,15 @@ _public_ int sd_journal_get_data_threshold(sd_journal *j, size_t *sz) {
*sz = j->data_threshold;
return 0;
}
+
+_public_ int sd_journal_has_runtime_files(sd_journal *j) {
+ assert_return(j, -EINVAL);
+
+ return j->has_runtime_files;
+}
+
+_public_ int sd_journal_has_persistent_files(sd_journal *j) {
+ assert_return(j, -EINVAL);
+
+ return j->has_persistent_files;
+}