chiark / gitweb /
journald: use "persistent", not "permanent" as storage option
[elogind.git] / src / journal / journald.c
index 08597ae3eb9630dc22b43151d7163336465a0ead..da9f52813dbf2a030634d6143e81a64771291f6c 100644 (file)
@@ -114,7 +114,7 @@ struct StdoutStream {
 static const char* const storage_table[] = {
         [STORAGE_AUTO] = "auto",
         [STORAGE_VOLATILE] = "volatile",
-        [STORAGE_PERMANENT] = "permanent",
+        [STORAGE_PERSISTENT] = "persistent",
         [STORAGE_NONE] = "none"
 };
 
@@ -1963,16 +1963,16 @@ static int system_journal_open(Server *s) {
         sd_id128_to_string(machine, ids);
 
         if (!s->system_journal &&
-            (s->storage == STORAGE_PERMANENT ||
+            (s->storage == STORAGE_PERSISTENT ||
              s->storage == STORAGE_AUTO)) {
 
                 /* If in auto mode: first try to create the machine
                  * path, but not the prefix.
                  *
-                 * If in permanent mode: create /var/log/journal and
+                 * If in persistent mode: create /var/log/journal and
                  * the machine path */
 
-                if (s->storage & STORAGE_PERMANENT)
+                if (s->storage & STORAGE_PERSISTENT)
                         (void) mkdir("/var/log/journal/", 0755);
 
                 fn = strappend("/var/log/journal/", ids);
@@ -2058,7 +2058,6 @@ static int system_journal_open(Server *s) {
 }
 
 static int server_flush_to_var(Server *s) {
-        char path[] = "/run/log/journal/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
         Object *o = NULL;
         int r;
         sd_id128_t machine;
@@ -2068,7 +2067,7 @@ static int server_flush_to_var(Server *s) {
         assert(s);
 
         if (s->storage != STORAGE_AUTO &&
-            s->storage != STORAGE_PERMANENT)
+            s->storage != STORAGE_PERSISTENT)
                 return 0;
 
         if (!s->runtime_journal)
@@ -2135,6 +2134,7 @@ finish:
         s->runtime_journal = NULL;
 
         if (r >= 0) {
+                char path[] = "/run/log/journal/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
                 sd_id128_to_string(machine, path + 17);
                 rm_rf(path, false, true, false);
         }
@@ -2148,6 +2148,10 @@ static int server_read_proc_kmsg(Server *s) {
         assert(s->proc_kmsg_fd >= 0);
 
         l = read(s->proc_kmsg_fd, s->proc_kmsg_buffer + s->proc_kmsg_length, sizeof(s->proc_kmsg_buffer) - 1 - s->proc_kmsg_length);
+        if (l == 0) /* the kernel is stupid and in some race
+                     * conditions returns 0 in the middle of the
+                     * stream. */
+                return 0;
         if (l < 0) {
 
                 if (errno == EAGAIN || errno == EINTR)
@@ -2723,7 +2727,6 @@ static int server_init(Server *s) {
         s->rate_limit_burst = DEFAULT_RATE_LIMIT_BURST;
 
         s->forward_to_syslog = true;
-        s->import_proc_kmsg = true;
 
         s->max_level_store = LOG_DEBUG;
         s->max_level_syslog = LOG_DEBUG;