[systemd-commits] 6 commits - src/core src/journal

Lennart Poettering lennart at kemper.freedesktop.org
Wed Jul 18 18:24:40 PDT 2012


 src/core/killall.c             |    4 ++--
 src/core/manager.c             |    2 +-
 src/journal/journal-file.c     |    6 ++++--
 src/journal/journal-internal.h |    2 ++
 src/journal/sd-journal.c       |   28 +++++++++++++++++++++-------
 5 files changed, 30 insertions(+), 12 deletions(-)

New commits:
commit 4a842cadb8d6b30fa9fdc8ff183633c14e02cf96
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jul 19 03:22:07 2012 +0200

    journal: allow watching symlinked journal dirs

diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index 672896d..fd0fb57 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -1233,7 +1233,7 @@ static int add_directory(sd_journal *j, const char *prefix, const char *dirname)
                 m->wd = inotify_add_watch(j->inotify_fd, m->path,
                                           IN_CREATE|IN_MOVED_TO|IN_MODIFY|IN_ATTRIB|IN_DELETE|
                                           IN_DELETE_SELF|IN_MOVE_SELF|IN_UNMOUNT|
-                                          IN_DONT_FOLLOW|IN_ONLYDIR);
+                                          IN_ONLYDIR);
 
                 if (m->wd > 0 && hashmap_put(j->directories_by_wd, INT_TO_PTR(m->wd), m) < 0)
                         inotify_rm_watch(j->inotify_fd, m->wd);
@@ -1310,7 +1310,7 @@ static int add_root_directory(sd_journal *j, const char *p) {
 
                 m->wd = inotify_add_watch(j->inotify_fd, m->path,
                                           IN_CREATE|IN_MOVED_TO|IN_MODIFY|IN_ATTRIB|IN_DELETE|
-                                          IN_DONT_FOLLOW|IN_ONLYDIR);
+                                          IN_ONLYDIR);
 
                 if (m->wd > 0 && hashmap_put(j->directories_by_wd, INT_TO_PTR(m->wd), m) < 0)
                         inotify_rm_watch(j->inotify_fd, m->wd);

commit 7827b1a10f4dfe2c6771b515f28f7ae22e0ae039
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jul 19 03:21:49 2012 +0200

    journal: when watching directories actually watch the directories asked for

diff --git a/src/journal/journal-internal.h b/src/journal/journal-internal.h
index b767901..04f7754 100644
--- a/src/journal/journal-internal.h
+++ b/src/journal/journal-internal.h
@@ -90,6 +90,8 @@ struct Directory {
 struct sd_journal {
         int flags;
 
+        char *path;
+
         Hashmap *files;
 
         Location current_location;
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index 4c19fc0..672896d 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -1402,7 +1402,7 @@ static int allocate_inotify(sd_journal *j) {
         return 0;
 }
 
-static sd_journal *journal_new(int flags) {
+static sd_journal *journal_new(int flags, const char *path) {
         sd_journal *j;
 
         j = new0(sd_journal, 1);
@@ -1412,8 +1412,17 @@ static sd_journal *journal_new(int flags) {
         j->inotify_fd = -1;
         j->flags = flags;
 
+        if (path) {
+                j->path = strdup(path);
+                if (!j->path) {
+                        free(j);
+                        return NULL;
+                }
+        }
+
         j->files = hashmap_new(string_hash_func, string_compare_func);
         if (!j->files) {
+                free(j->path);
                 free(j);
                 return NULL;
         }
@@ -1421,6 +1430,7 @@ static sd_journal *journal_new(int flags) {
         j->directories_by_path = hashmap_new(string_hash_func, string_compare_func);
         if (!j->directories_by_path) {
                 hashmap_free(j->files);
+                free(j->path);
                 free(j);
                 return NULL;
         }
@@ -1440,7 +1450,7 @@ _public_ int sd_journal_open(sd_journal **ret, int flags) {
                       SD_JOURNAL_SYSTEM_ONLY))
                 return -EINVAL;
 
-        j = journal_new(flags);
+        j = journal_new(flags, NULL);
         if (!j)
                 return -ENOMEM;
 
@@ -1470,7 +1480,7 @@ _public_ int sd_journal_open_directory(sd_journal **ret, const char *path, int f
         if (flags != 0)
                 return -EINVAL;
 
-        j = journal_new(flags);
+        j = journal_new(flags, path);
         if (!j)
                 return -ENOMEM;
 
@@ -1513,6 +1523,7 @@ _public_ void sd_journal_close(sd_journal *j) {
 
         sd_journal_flush_matches(j);
 
+        free(j->path);
         free(j);
 }
 
@@ -1790,7 +1801,10 @@ _public_ int sd_journal_get_fd(sd_journal *j) {
 
         /* Iterate through all dirs again, to add them to the
          * inotify */
-        r = add_search_paths(j);
+        if (j->path)
+                r = add_root_directory(j, j->path);
+        else
+                r = add_search_paths(j);
         if (r < 0)
                 return r;
 

commit a1a1898f7190a25a579556826379f7486f87459b
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jul 19 03:21:04 2012 +0200

    journal: rotate busy files away when we try to write to them

diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 9efa82c..b840124 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -2142,7 +2142,9 @@ int journal_file_open_reliably(
         if (r != -EBADMSG && /* corrupted */
             r != -ENODATA && /* truncated */
             r != -EHOSTDOWN && /* other machine */
-            r != -EPROTONOSUPPORT) /* incompatible feature */
+            r != -EPROTONOSUPPORT && /* incompatible feature */
+            r != -EBUSY && /* unclean shutdown */
+            r != -ESHUTDOWN /* already archived */)
                 return r;
 
         if ((flags & O_ACCMODE) == O_RDONLY)
@@ -2165,7 +2167,7 @@ int journal_file_open_reliably(
         if (r < 0)
                 return -errno;
 
-        log_warning("File %s corrupted, renaming and replacing.", fname);
+        log_warning("File %s corrupted or uncleanly shut down, renaming and replacing.", fname);
 
         return journal_file_open(fname, flags, mode, metrics, template, ret);
 }

commit 6f5878a286c34739d8d6759de5f5a77e56daeb61
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jul 19 02:35:17 2012 +0200

    journal: follow symlinks when enumerating journals

diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index c3f19ca..4c19fc0 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -1329,7 +1329,7 @@ static int add_root_directory(sd_journal *j, const char *p) {
                         if (r < 0)
                                 log_debug("Failed to add file %s/%s: %s", m->path, de->d_name, strerror(-r));
 
-                } else if ((de->d_type == DT_DIR || de->d_type == DT_UNKNOWN) &&
+                } else if ((de->d_type == DT_DIR || de->d_type == DT_LNK || de->d_type == DT_UNKNOWN) &&
                            sd_id128_from_string(de->d_name, &id) >= 0) {
 
                         r = add_directory(j, m->path, de->d_name);

commit 31f92a7df427593532d221dd715e2e0a5b6f3a96
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jul 19 02:17:50 2012 +0200

    manager: use a private notify sockets in containers to avoid problems with shared abstract socket namespaces

diff --git a/src/core/manager.c b/src/core/manager.c
index 27dc9f3..48305e3 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -96,7 +96,7 @@ static int manager_setup_notify(Manager *m) {
         zero(sa);
         sa.sa.sa_family = AF_UNIX;
 
-        if (getpid() != 1)
+        if (getpid() != 1 || detect_container(NULL) > 0)
                 snprintf(sa.un.sun_path, sizeof(sa.un.sun_path), NOTIFY_SOCKET "/%llu", random_ull());
         else
                 strncpy(sa.un.sun_path, NOTIFY_SOCKET, sizeof(sa.un.sun_path));

commit 3d141780b8d509e4a6c3083de207cd84cbce187b
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jul 19 02:17:11 2012 +0200

    killall: avoid gcc warning about wait name clash

diff --git a/src/core/killall.c b/src/core/killall.c
index 6fcaf84..55200ff 100644
--- a/src/core/killall.c
+++ b/src/core/killall.c
@@ -150,7 +150,7 @@ static int killall(int sig) {
         return n_processes;
 }
 
-void broadcast_signal(int sig, bool wait) {
+void broadcast_signal(int sig, bool wait_for_exit) {
         sigset_t mask, oldmask;
         int n_processes;
 
@@ -169,7 +169,7 @@ void broadcast_signal(int sig, bool wait) {
         if (n_processes <= 0)
                 goto finish;
 
-        if (wait)
+        if (wait_for_exit)
                 wait_for_children(n_processes, &mask);
 
 finish:



More information about the systemd-commits mailing list