[systemd-devel] [RFC PATCH 2/3] journal: allow opening without any files

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Mon Mar 18 18:29:10 PDT 2013


Explicit flag is required, since this is supposed to be used
mostly for debugging and it is better to catch the mistake
of not specyfing any files.
---
 src/journal/sd-journal.c | 11 +++++++----
 src/systemd/sd-journal.h |  3 ++-
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index 46f9fb8..e1b3fe0 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -1542,16 +1542,19 @@ _public_ int sd_journal_open(sd_journal **ret, int flags) {
 
         if (flags & ~(SD_JOURNAL_LOCAL_ONLY|
                       SD_JOURNAL_RUNTIME_ONLY|
-                      SD_JOURNAL_SYSTEM_ONLY))
+                      SD_JOURNAL_SYSTEM_ONLY|
+                      SD_JOURNAL_WITHOUT_FILES))
                 return -EINVAL;
 
         j = journal_new(flags, NULL);
         if (!j)
                 return -ENOMEM;
 
-        r = add_search_paths(j);
-        if (r < 0)
-                goto fail;
+        if (!(flags & SD_JOURNAL_WITHOUT_FILES)) {
+                r = add_search_paths(j);
+                if (r < 0)
+                        goto fail;
+        }
 
         *ret = j;
         return 0;
diff --git a/src/systemd/sd-journal.h b/src/systemd/sd-journal.h
index 30b7c75..13dc06a 100644
--- a/src/systemd/sd-journal.h
+++ b/src/systemd/sd-journal.h
@@ -74,7 +74,8 @@ typedef struct sd_journal sd_journal;
 enum {
         SD_JOURNAL_LOCAL_ONLY = 1,
         SD_JOURNAL_RUNTIME_ONLY = 2,
-        SD_JOURNAL_SYSTEM_ONLY = 4
+        SD_JOURNAL_SYSTEM_ONLY = 4,
+        SD_JOURNAL_WITHOUT_FILES = 8,
 };
 
 /* Wakeup event types */
-- 
1.8.1.4



More information about the systemd-devel mailing list