chiark / gitweb /
util: rename join() to strjoin()
[elogind.git] / src / journal / journald.c
index d2e2fcacac25b6480d8dc6bd6cc06037108c6425..fd292f019e2237b89fdd70d105d0be45717cc6c9 100644 (file)
@@ -69,8 +69,6 @@
 
 #define RECHECK_AVAILABLE_SPACE_USEC (30*USEC_PER_SEC)
 
-#define RECHECK_VAR_AVAILABLE_USEC (30*USEC_PER_SEC)
-
 #define N_IOVEC_META_FIELDS 17
 
 #define ENTRY_SIZE_MAX (1024*1024*32)
@@ -114,15 +112,13 @@ struct StdoutStream {
 static const char* const storage_table[] = {
         [STORAGE_AUTO] = "auto",
         [STORAGE_VOLATILE] = "volatile",
-        [STORAGE_PERMANENT] = "permanent",
+        [STORAGE_PERSISTENT] = "persistent",
         [STORAGE_NONE] = "none"
 };
 
 DEFINE_STRING_TABLE_LOOKUP(storage, Storage);
 DEFINE_CONFIG_PARSE_ENUM(config_parse_storage, storage, Storage, "Failed to parse storage setting");
 
-static int server_flush_to_var(Server *s);
-
 static uint64_t available_space(Server *s) {
         char ids[33], *p;
         const char *f;
@@ -630,8 +626,6 @@ static void dispatch_message_real(
 
         assert(n <= m);
 
-        server_flush_to_var(s);
-
 retry:
         f = find_journal(s, realuid == 0 ? 0 : loginuid);
         if (f) {
@@ -1963,16 +1957,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_AUTO)) {
+            (s->storage == STORAGE_PERSISTENT || s->storage == STORAGE_AUTO) &&
+            access("/run/systemd/journal/flushed", F_OK) >= 0) {
 
                 /* 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);
@@ -1982,8 +1976,7 @@ static int system_journal_open(Server *s) {
                 (void) mkdir(fn, 0755);
                 free(fn);
 
-                /* The create the system journal file */
-                fn = join("/var/log/journal/", ids, "/system.journal", NULL);
+                fn = strjoin("/var/log/journal/", ids, "/system.journal", NULL);
                 if (!fn)
                         return -ENOMEM;
 
@@ -2009,7 +2002,7 @@ static int system_journal_open(Server *s) {
         if (!s->runtime_journal &&
             (s->storage != STORAGE_NONE)) {
 
-                fn = join("/run/log/journal/", ids, "/system.journal", NULL);
+                fn = strjoin("/run/log/journal/", ids, "/system.journal", NULL);
                 if (!fn)
                         return -ENOMEM;
 
@@ -2034,7 +2027,7 @@ static int system_journal_open(Server *s) {
                         /* OK, we really need the runtime journal, so create
                          * it if necessary. */
 
-                        (void) mkdir_parents_label(fn, 0755);
+                        (void) mkdir_parents(fn, 0755);
                         r = journal_file_open_reliably(fn, O_RDWR|O_CREAT, 0640, NULL, &s->runtime_journal);
                         free(fn);
 
@@ -2058,28 +2051,20 @@ 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;
         sd_journal *j;
-        usec_t ts;
 
         assert(s);
 
         if (s->storage != STORAGE_AUTO &&
-            s->storage != STORAGE_PERMANENT)
+            s->storage != STORAGE_PERSISTENT)
                 return 0;
 
         if (!s->runtime_journal)
                 return 0;
 
-        ts = now(CLOCK_MONOTONIC);
-        if (s->var_available_timestamp + RECHECK_VAR_AVAILABLE_USEC > ts)
-                return 0;
-
-        s->var_available_timestamp = ts;
-
         system_journal_open(s);
 
         if (!s->system_journal)
@@ -2135,6 +2120,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);
         }
@@ -2215,6 +2201,7 @@ static int process_event(Server *s, struct epoll_event *ev) {
                 }
 
                 if (sfsi.ssi_signo == SIGUSR1) {
+                        touch("/run/systemd/journal/flushed");
                         server_flush_to_var(s);
                         return 1;
                 }
@@ -2727,7 +2714,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;