summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-02-01 12:02:53 +0100
committerLennart Poettering <lennart@poettering.net>2016-02-01 12:02:53 +0100
commitf3ade27e68e76e068a7d81ed52d6893318e1d1ec (patch)
treee8e8fd8e16faa64cbb6bd7f46d4797501989d110 /src/journal
parentc248c80dfdfacadb9460a8831ffff45ed382e48a (diff)
parentc34e939909710bf124e7741c3648592a30418ffd (diff)
Merge pull request #2497 from jsynacek/bootoffset-runtime-v4
Expose additional booleans in sd_journal and improve error messages in journalctl
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/journal-internal.h2
-rw-r--r--src/journal/journalctl.c14
-rw-r--r--src/journal/sd-journal.c18
3 files changed, 31 insertions, 3 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/journalctl.c b/src/journal/journalctl.c
index db11421e7a..1686f38c4e 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -1136,10 +1136,11 @@ static int add_boot(sd_journal *j) {
const char *reason = (r == 0) ? "No such boot ID in journal" : strerror(-r);
if (sd_id128_is_null(arg_boot_id))
- log_error("Failed to look up boot %+i: %s", arg_boot_offset, reason);
+ log_error("Data from the specified boot (%+i) is not available: %s",
+ arg_boot_offset, reason);
else
- log_error("Failed to look up boot ID "SD_ID128_FORMAT_STR"%+i: %s",
- SD_ID128_FORMAT_VAL(arg_boot_id), arg_boot_offset, reason);
+ log_error("Data from the specified boot ("SD_ID128_FORMAT_STR") is not available: %s",
+ SD_ID128_FORMAT_VAL(arg_boot_id), reason);
return r == 0 ? -ENODATA : r;
}
@@ -2091,6 +2092,13 @@ int main(int argc, char *argv[]) {
assert_not_reached("Unknown action");
}
+ if (arg_boot_offset != 0 &&
+ sd_journal_has_runtime_files(j) > 0 &&
+ sd_journal_has_persistent_files(j) == 0) {
+ log_info("Specifying boot ID has no effect, no persistent journal was found");
+ r = 0;
+ goto finish;
+ }
/* add_boot() must be called first!
* It may need to seek the journal to find parent boot IDs. */
r = add_boot(j);
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;
+}