[systemd-commits] 6 commits - TODO catalog/Makefile src/journal src/systemd

Lennart Poettering lennart at kemper.freedesktop.org
Tue Nov 20 12:40:29 PST 2012


 TODO                               |    4 ++
 catalog/Makefile                   |    1 
 src/journal/journal-send.c         |   55 ++++++++++++++++++++++---------------
 src/journal/libsystemd-journal.sym |    1 
 src/journal/sd-journal.c           |    7 ++++
 src/systemd/sd-journal.h           |    1 
 6 files changed, 47 insertions(+), 22 deletions(-)

New commits:
commit 8f1e860f8a55e2baa336a5abb7e53abb3f77a9ad
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Nov 20 21:38:59 2012 +0100

    journal: add sd_journal_get_catalog_for_message_id() as API to get catalog entry for any message ID without requiring an open journal file

diff --git a/src/journal/libsystemd-journal.sym b/src/journal/libsystemd-journal.sym
index d4b0c32..17b5bf8 100644
--- a/src/journal/libsystemd-journal.sym
+++ b/src/journal/libsystemd-journal.sym
@@ -85,4 +85,5 @@ LIBSYSTEMD_JOURNAL_196 {
 global:
         sd_journal_fd_reliable;
         sd_journal_get_catalog;
+        sd_journal_get_catalog_for_message_id;
 } LIBSYSTEMD_JOURNAL_195;
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index 41f0c4d..fe0478f 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -2449,3 +2449,10 @@ _public_ int sd_journal_get_catalog(sd_journal *j, char **ret) {
         *ret = t;
         return 0;
 }
+
+_public_ int sd_journal_get_catalog_for_message_id(sd_id128_t id, char **ret) {
+        if (!ret)
+                return -EINVAL;
+
+        return catalog_get(id, ret);
+}
diff --git a/src/systemd/sd-journal.h b/src/systemd/sd-journal.h
index f9919b2..fd9c0f5 100644
--- a/src/systemd/sd-journal.h
+++ b/src/systemd/sd-journal.h
@@ -129,6 +129,7 @@ int sd_journal_process(sd_journal *j);
 int sd_journal_wait(sd_journal *j, uint64_t timeout_usec);
 
 int sd_journal_get_catalog(sd_journal *j, char **text);
+int sd_journal_get_catalog_for_message_id(sd_id128_t id, char **ret);
 
 #define SD_JOURNAL_FOREACH(j)                                           \
         if (sd_journal_seek_head(j) >= 0)                               \

commit e41814846c19a48f4490169d82e359e005c4db45
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Nov 20 21:33:49 2012 +0100

    update TODO

diff --git a/TODO b/TODO
index 2b1ab07..53ae9ab 100644
--- a/TODO
+++ b/TODO
@@ -19,6 +19,8 @@ F18:
 
 Features:
 
+* journald: also get thread ID from client, plus thread name
+
 * check if we can make journalctl by default use --follow mode inside of less if called without args?
 
 * Addd a verbose mode to "systemctl start" and friends that explains what is being done or not done

commit ee55db41442ad8055f5a84a339b1e0e22bc037c4
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Nov 20 21:25:26 2012 +0100

    journal-send: always send SYSLOG_IDENTIFIER, if we have it
    
    https://bugzilla.redhat.com/show_bug.cgi?id=872193

diff --git a/src/journal/journal-send.c b/src/journal/journal-send.c
index 7a91569..bd8f887 100644
--- a/src/journal/journal-send.c
+++ b/src/journal/journal-send.c
@@ -219,6 +219,7 @@ _public_ int sd_journal_sendv(const struct iovec *iov, int n) {
          * be a tmpfs, and one that is available from early boot on
          * and where unprivileged users can create files. */
         char path[] = "/dev/shm/journal.XXXXXX";
+        bool have_syslog_identifier = false;
 
         if (_unlikely_(!iov))
                 return -EINVAL;
@@ -228,7 +229,7 @@ _public_ int sd_journal_sendv(const struct iovec *iov, int n) {
 
         saved_errno = errno;
 
-        w = alloca(sizeof(struct iovec) * n * 5);
+        w = alloca(sizeof(struct iovec) * n * 5 + 3);
         l = alloca(sizeof(uint64_t) * n);
 
         for (i = 0; i < n; i++) {
@@ -245,6 +246,9 @@ _public_ int sd_journal_sendv(const struct iovec *iov, int n) {
                         goto finish;
                 }
 
+                have_syslog_identifier =
+                        have_syslog_identifier || (c == iov[i].iov_base + 17 && memcmp(iov[i].iov_base, "SYSLOG_IDENTIFIER", 17) == 0);
+
                 nl = memchr(iov[i].iov_base, '\n', iov[i].iov_len);
                 if (nl) {
                         if (_unlikely_(nl < c)) {
@@ -280,6 +284,20 @@ _public_ int sd_journal_sendv(const struct iovec *iov, int n) {
                 IOVEC_SET_STRING(w[j++], "\n");
         }
 
+        if (!have_syslog_identifier &&
+            string_is_safe(program_invocation_short_name)) {
+
+                /* Implicitly add program_invocation_short_name, if it
+                 * is not set explicitly. We only do this for
+                 * program_invocation_short_name, and nothing else
+                 * since everything else is much nicer to retrieve
+                 * from the outside. */
+
+                IOVEC_SET_STRING(w[j++], "SYSLOG_IDENTIFIER=");
+                IOVEC_SET_STRING(w[j++], program_invocation_short_name);
+                IOVEC_SET_STRING(w[j++], "\n");
+        }
+
         fd = journal_fd();
         if (_unlikely_(fd < 0)) {
                 r = fd;

commit 3ed08c446cfaaae2b234fdfeb0c34ab6b4748c3e
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Nov 20 21:22:18 2012 +0100

    journal-send: unify a bit of code

diff --git a/src/journal/journal-send.c b/src/journal/journal-send.c
index 8589d94..7a91569 100644
--- a/src/journal/journal-send.c
+++ b/src/journal/journal-send.c
@@ -35,6 +35,17 @@
 
 #define SNDBUF_SIZE (8*1024*1024)
 
+#define ALLOCA_CODE_FUNC(f, func)                 \
+        do {                                      \
+                size_t _fl;                       \
+                const char *_func = (func);       \
+                char **_f = &(f);                 \
+                _fl = strlen(_func) + 1;          \
+                *_f = alloca(_fl + 10);           \
+                memcpy(*_f, "CODE_FUNC=", 10);    \
+                memcpy(*_f + 10, _func, _fl);     \
+        } while(false)
+
 /* We open a single fd, and we'll share it with the current process,
  * all its threads, and all its subprocesses. This means we need to
  * initialize it atomically, and need to operate on it atomically
@@ -487,7 +498,6 @@ _public_ int sd_journal_printv_with_location(int priority, const char *file, con
         char buffer[8 + LINE_MAX], p[11];
         struct iovec iov[5];
         char *f;
-        size_t fl;
 
         if (priority < 0 || priority > 7)
                 return -EINVAL;
@@ -505,10 +515,7 @@ _public_ int sd_journal_printv_with_location(int priority, const char *file, con
         /* func is initialized from __func__ which is not a macro, but
          * a static const char[], hence cannot easily be prefixed with
          * CODE_FUNC=, hence let's do it manually here. */
-        fl = strlen(func) + 1;
-        f = alloca(fl + 10);
-        memcpy(f, "CODE_FUNC=", 10);
-        memcpy(f + 10, func, fl);
+        ALLOCA_CODE_FUNC(f, func);
 
         zero(iov);
         IOVEC_SET_STRING(iov[0], buffer);
@@ -525,7 +532,6 @@ _public_ int sd_journal_send_with_location(const char *file, const char *line, c
         va_list ap;
         struct iovec *iov = NULL;
         char *f;
-        size_t fl;
 
         va_start(ap, format);
         i = fill_iovec_sprintf(format, ap, 3, &iov);
@@ -536,10 +542,7 @@ _public_ int sd_journal_send_with_location(const char *file, const char *line, c
                 goto finish;
         }
 
-        fl = strlen(func) + 1;
-        f = alloca(fl + 10);
-        memcpy(f, "CODE_FUNC=", 10);
-        memcpy(f + 10, func, fl);
+        ALLOCA_CODE_FUNC(f, func);
 
         IOVEC_SET_STRING(iov[0], file);
         IOVEC_SET_STRING(iov[1], line);
@@ -563,7 +566,6 @@ _public_ int sd_journal_sendv_with_location(
 
         struct iovec *niov;
         char *f;
-        size_t fl;
 
         if (_unlikely_(!iov))
                 return -EINVAL;
@@ -574,10 +576,7 @@ _public_ int sd_journal_sendv_with_location(
         niov = alloca(sizeof(struct iovec) * (n + 3));
         memcpy(niov, iov, sizeof(struct iovec) * n);
 
-        fl = strlen(func) + 1;
-        f = alloca(fl + 10);
-        memcpy(f, "CODE_FUNC=", 10);
-        memcpy(f + 10, func, fl);
+        ALLOCA_CODE_FUNC(f, func);
 
         IOVEC_SET_STRING(niov[n++], file);
         IOVEC_SET_STRING(niov[n++], line);
@@ -592,13 +591,9 @@ _public_ int sd_journal_perror_with_location(
                 const char *message) {
 
         struct iovec iov[6];
-        size_t fl;
         char *f;
 
-        fl = strlen(func) + 1;
-        f = alloca(fl + 10);
-        memcpy(f, "CODE_FUNC=", 10);
-        memcpy(f + 10, func, fl);
+        ALLOCA_CODE_FUNC(f, func);
 
         IOVEC_SET_STRING(iov[0], file);
         IOVEC_SET_STRING(iov[1], line);

commit c7db8aa9d3da1704cd0d4b867627cf14badf6ef7
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Nov 20 20:31:01 2012 +0100

    build-sys: add symlink Makefile to catalog/ too

diff --git a/catalog/Makefile b/catalog/Makefile
new file mode 120000
index 0000000..bd10475
--- /dev/null
+++ b/catalog/Makefile
@@ -0,0 +1 @@
+../src/Makefile
\ No newline at end of file

commit 54728c372afe83ad7650201ce7b61d0fa110657c
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Nov 20 20:30:30 2012 +0100

    update TODO

diff --git a/TODO b/TODO
index f8062f2..2b1ab07 100644
--- a/TODO
+++ b/TODO
@@ -99,7 +99,7 @@ Features:
 
 * journal: add a setgid "adm" utility to invoke from libsystemd-journal, which passes fds via STDOUT and does PK access
 
-* link up selected blog stories from man pages?
+* link up selected blog stories from man pages and unit files Documentation= fields?
 
 * journactl: support negative filtering, i.e. FOOBAR!="waldo",
   and !FOOBAR for events without FOOBAR.



More information about the systemd-commits mailing list