[systemd-commits] Branch 'journal' - 3 commits - .gitignore Makefile.am libsystemd-id128.pc.in libsystemd-journal.pc.in src/journal src/libsystemd-id128.sym src/libsystemd-journal.sym src/remount-api-vfs.c units/.gitignore units/systemd-journald.service.in units/systemd-journald.socket

Lennart Poettering lennart at kemper.freedesktop.org
Fri Dec 30 08:50:59 PST 2011


 .gitignore                        |    2 
 Makefile.am                       |  108 +++++++++++++++++++++++++++++++++++---
 libsystemd-id128.pc.in            |   18 ++++++
 libsystemd-journal.pc.in          |   19 ++++++
 src/journal/journal-internal.h    |   83 +++++++++++++++++++++++++++++
 src/libsystemd-id128.sym          |   22 +++++++
 src/libsystemd-journal.sym        |   45 +++++++++++++++
 src/remount-api-vfs.c             |   23 +++++---
 units/.gitignore                  |    1 
 units/systemd-journald.service.in |   24 ++++++++
 units/systemd-journald.socket     |   24 ++++++++
 11 files changed, 355 insertions(+), 14 deletions(-)

New commits:
commit 4b2d99d9f4258a29f0bf8b1a78d17836e75bc378
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Dec 30 17:50:37 2011 +0100

    journal: add unit files and shared library glue

diff --git a/.gitignore b/.gitignore
index 265801f..28b40de 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
+/libsystemd-journal.pc
+/libsystemd-id128.pc
 systemd-journalctl
 systemd-journald
 test-id128
diff --git a/Makefile.am b/Makefile.am
index 5fe67fd..fa0a217 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -27,6 +27,14 @@ LIBSYSTEMD_DAEMON_CURRENT=0
 LIBSYSTEMD_DAEMON_REVISION=0
 LIBSYSTEMD_DAEMON_AGE=0
 
+LIBSYSTEMD_ID128_CURRENT=0
+LIBSYSTEMD_ID128_REVISION=0
+LIBSYSTEMD_ID128_AGE=0
+
+LIBSYSTEMD_JOURNAL_CURRENT=0
+LIBSYSTEMD_JOURNAL_REVISION=0
+LIBSYSTEMD_JOURNAL_AGE=0
+
 # Dirs of external packages
 dbuspolicydir=@dbuspolicydir@
 dbussessionservicedir=@dbussessionservicedir@
@@ -217,11 +225,15 @@ endif
 
 lib_LTLIBRARIES = \
 	libsystemd-daemon.la \
-	libsystemd-login.la
+	libsystemd-login.la \
+        libsystemd-id128.la \
+        libsystemd-journal.la
 
 pkginclude_HEADERS = \
 	src/sd-daemon.h \
-	src/sd-login.h
+	src/sd-login.h \
+        src/sd-id128.h \
+        src/journal/sd-journal.h
 
 noinst_PROGRAMS = \
 	test-engine \
@@ -389,7 +401,8 @@ dist_systemunit_DATA = \
 	units/quotaon.service \
 	units/systemd-ask-password-wall.path \
 	units/systemd-ask-password-console.path \
-	units/syslog.target
+	units/syslog.target \
+        units/systemd-journald.socket
 
 if HAVE_SYSV_COMPAT
 dist_systemunit_DATA += \
@@ -410,6 +423,7 @@ nodist_systemunit_DATA = \
 	units/systemd-stdout-syslog-bridge.service \
 	units/systemd-shutdownd.service \
 	units/systemd-logind.service \
+        units/systemd-journald.service \
 	units/systemd-kmsg-syslogd.service \
 	units/systemd-modules-load.service \
 	units/systemd-vconsole-setup.service \
@@ -473,7 +487,8 @@ EXTRA_DIST = \
 	units/systemd-stdout-syslog-bridge.service.in \
 	units/systemd-shutdownd.service.in \
 	units/systemd-logind.service.in \
-	units/systemd-kmsg-syslogd.service.in \
+        units/systemd-journald.service.in \
+        units/systemd-kmsg-syslogd.service.in \
 	units/systemd-modules-load.service.in \
 	units/systemd-vconsole-setup.service.in \
 	units/systemd-remount-api-vfs.service.in \
@@ -502,8 +517,12 @@ EXTRA_DIST = \
 	systemd.pc.in \
 	libsystemd-daemon.pc.in \
 	libsystemd-login.pc.in \
+        libsystemd-id128.pc.in \
+        libsystemd-journal.pc.in \
 	src/libsystemd-daemon.sym \
 	src/libsystemd-login.sym \
+	src/libsystemd-id128.sym \
+	src/libsystemd-journal.sym \
 	introspect.awk \
 	src/73-seat-late.rules.in \
         src/99-systemd.rules.in \
@@ -594,7 +613,9 @@ pkgconfigdata_DATA = \
 
 pkgconfiglib_DATA = \
         libsystemd-daemon.pc \
-        libsystemd-login.pc
+        libsystemd-login.pc \
+        libsystemd-id128.pc \
+        libsystemd-journal.pc
 
 # Passed through intltool only
 polkitpolicy_in_files = \
@@ -770,7 +791,14 @@ EXTRA_DIST += \
         src/logind-user.h \
         src/logind-acl.h \
         src/dbus-loop.h \
-        src/spawn-agent.h
+        src/spawn-agent.h \
+        src/journal/journal-def.h \
+        src/journal/journal-internal.h \
+        src/journal/journal-file.h \
+        src/journal/lookup3.h \
+        src/journal/compress.h \
+        src/journal/journal-rate-limit.h \
+        src/acl-util.h
 
 MANPAGES = \
 	man/systemd.1 \
@@ -1703,6 +1731,69 @@ libsystemd-login-install-hook:
 libsystemd-login-uninstall-hook:
 	rm -f $(DESTDIR)$(rootlibdir)/libsystemd-login.so*
 
+libsystemd_id128_la_SOURCES = \
+        src/sd-id128.c
+
+libsystemd_id128_la_CFLAGS = \
+        $(AM_CFLAGS) \
+	-fvisibility=hidden
+
+libsystemd_id128_la_LDFLAGS = \
+        -shared \
+        -version-info $(LIBSYSTEMD_ID128_CURRENT):$(LIBSYSTEMD_ID128_REVISION):$(LIBSYSTEMD_ID128_AGE) \
+        -Wl,--version-script=$(top_srcdir)/src/libsystemd-id128.sym
+
+libsystemd_id128_la_LIBADD = \
+	libsystemd-basic.la
+
+# move lib from $(libdir) to $(rootlibdir) and update devel link, if needed
+libsystemd-id128-install-hook:
+	if test "$(libdir)" != "$(rootlibdir)"; then \
+		mkdir -p $(DESTDIR)$(rootlibdir) && \
+		so_img_name=$$(readlink $(DESTDIR)$(libdir)/libsystemd-id128.so) && \
+		so_img_rel_target_prefix=$$(echo $(libdir) | sed 's,\(^/\|\)[^/][^/]*,..,g') && \
+		ln -sf $$so_img_rel_target_prefix$(rootlibdir)/$$so_img_name $(DESTDIR)$(libdir)/libsystemd-id128.so && \
+		mv $(DESTDIR)$(libdir)/libsystemd-id128.so.* $(DESTDIR)$(rootlibdir); \
+	fi
+
+libsystemd-id128-uninstall-hook:
+	rm -f $(DESTDIR)$(rootlibdir)/libsystemd-id128.so*
+
+libsystemd_journal_la_SOURCES = \
+        src/journal/sd-journal.c \
+        src/journal/journal-file.c \
+        src/journal/compress.c \
+        src/journal/lookup3.c \
+        src/journal/journal-send.c
+
+libsystemd_journal_la_CFLAGS = \
+        $(AM_CFLAGS) \
+        $(XZ_CFLAGS) \
+	-fvisibility=hidden
+
+libsystemd_journal_la_LDFLAGS = \
+        -shared \
+        -version-info $(LIBSYSTEMD_JOURNAL_CURRENT):$(LIBSYSTEMD_JOURNAL_REVISION):$(LIBSYSTEMD_JOURNAL_AGE) \
+        -Wl,--version-script=$(top_srcdir)/src/libsystemd-journal.sym
+
+libsystemd_journal_la_LIBADD = \
+	libsystemd-basic.la \
+        libsystemd-id128.la \
+        $(XZ_LIBS)
+
+# move lib from $(libdir) to $(rootlibdir) and update devel link, if needed
+libsystemd-journal-install-hook:
+	if test "$(libdir)" != "$(rootlibdir)"; then \
+		mkdir -p $(DESTDIR)$(rootlibdir) && \
+		so_img_name=$$(readlink $(DESTDIR)$(libdir)/libsystemd-journal.so) && \
+		so_img_rel_target_prefix=$$(echo $(libdir) | sed 's,\(^/\|\)[^/][^/]*,..,g') && \
+		ln -sf $$so_img_rel_target_prefix$(rootlibdir)/$$so_img_name $(DESTDIR)$(libdir)/libsystemd-journal.so && \
+		mv $(DESTDIR)$(libdir)/libsystemd-journal.so.* $(DESTDIR)$(rootlibdir); \
+	fi
+
+libsystemd-journal-uninstall-hook:
+	rm -f $(DESTDIR)$(rootlibdir)/libsystemd-journal.so*
+
 SED_PROCESS = \
 	$(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
 	$(SED)  -e 's, at rootlibexecdir\@,$(rootlibexecdir),g' \
@@ -1919,11 +2010,12 @@ endif
 		rm -f user && \
 		$(LN_S) $(pkgsysconfdir)/user user )
 	( cd $(DESTDIR)$(systemunitdir)/sockets.target.wants && \
-		rm -f systemd-initctl.socket systemd-stdout-syslog-bridge.socket systemd-shutdownd.socket syslog.socket && \
+		rm -f systemd-initctl.socket systemd-stdout-syslog-bridge.socket systemd-shutdownd.socket syslog.socket systemd-journald.socket && \
 		$(LN_S) ../systemd-stdout-syslog-bridge.socket systemd-stdout-syslog-bridge.socket && \
 		$(LN_S) ../systemd-initctl.socket systemd-initctl.socket && \
 		$(LN_S) ../systemd-shutdownd.socket systemd-shutdownd.socket && \
-		$(LN_S) ../syslog.socket syslog.socket )
+		$(LN_S) ../syslog.socket syslog.socket && \
+                $(LN_S) ../systemd-journald.socket )
 	( cd $(DESTDIR)$(systemunitdir)/runlevel1.target.wants && \
 		rm -f systemd-update-utmp-runlevel.service && \
 		$(LN_S) ../systemd-update-utmp-runlevel.service systemd-update-utmp-runlevel.service )
diff --git a/libsystemd-id128.pc.in b/libsystemd-id128.pc.in
new file mode 100644
index 0000000..4d984fd
--- /dev/null
+++ b/libsystemd-id128.pc.in
@@ -0,0 +1,18 @@
+#  This file is part of systemd.
+#
+#  systemd is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: systemd
+Description: systemd 128 Bit ID Utility Library
+URL: @PACKAGE_URL@
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -lsystemd-id128
+Cflags: -I${includedir}
diff --git a/libsystemd-journal.pc.in b/libsystemd-journal.pc.in
new file mode 100644
index 0000000..13cc820
--- /dev/null
+++ b/libsystemd-journal.pc.in
@@ -0,0 +1,19 @@
+#  This file is part of systemd.
+#
+#  systemd is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: systemd
+Description: systemd Journal Utility Library
+URL: @PACKAGE_URL@
+Version: @PACKAGE_VERSION@
+Requires: libsystemd-id128 = @PACKAGE_VERSION@
+Libs: -L${libdir} -lsystemd-journal
+Cflags: -I${includedir}
diff --git a/src/libsystemd-id128.sym b/src/libsystemd-id128.sym
new file mode 100644
index 0000000..c4d1cf5
--- /dev/null
+++ b/src/libsystemd-id128.sym
@@ -0,0 +1,22 @@
+/***
+  This file is part of systemd.
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+***/
+
+/* Original symbols from systemd v38 */
+
+LIBSYSTEMD_ID128_38 {
+global:
+        sd_id128_to_string;
+        sd_id128_from_string;
+        sd_id128_randomize;
+        sd_id128_make_v4_uuid;
+        sd_id128_get_machine;
+        sd_id128_get_boot;
+local:
+        *;
+};
diff --git a/src/libsystemd-journal.sym b/src/libsystemd-journal.sym
new file mode 100644
index 0000000..7653880
--- /dev/null
+++ b/src/libsystemd-journal.sym
@@ -0,0 +1,45 @@
+/***
+  This file is part of systemd.
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+***/
+
+/* Original symbols from systemd v38 */
+
+LIBSYSTEMD_JOURNAL_38 {
+global:
+        sd_journal_print;
+        sd_journal_printv;
+        sd_journal_send;
+        sd_journal_sendv;
+        sd_journal_stream_fd;
+        sd_journal_open;
+        sd_journal_close;
+        sd_journal_previous;
+        sd_journal_next;
+        sd_journal_previous_skip;
+        sd_journal_next_skip;
+        sd_journal_get_realtime_usec;
+        sd_journal_get_monotonic_usec;
+        sd_journal_get_data;
+        sd_journal_enumerate_data;
+        sd_journal_restart_data;
+        sd_journal_add_match;
+        sd_journal_flush_matches;
+        sd_journal_seek_head;
+        sd_journal_seek_tail;
+        sd_journal_seek_monotonic_usec;
+        sd_journal_seek_realtime_usec;
+        sd_journal_seek_cursor;
+        sd_journal_get_cursor;
+        sd_journal_query_unique;
+        sd_journal_enumerate_unique;
+        sd_journal_restart_unique;
+        sd_journal_get_fd;
+        sd_journal_process;
+local:
+        *;
+};
diff --git a/units/.gitignore b/units/.gitignore
index cc92c73..94412d5 100644
--- a/units/.gitignore
+++ b/units/.gitignore
@@ -1,3 +1,4 @@
+/systemd-journald.service
 user at .service
 systemd-logind.service
 systemd-localed.service
diff --git a/units/systemd-journald.service.in b/units/systemd-journald.service.in
new file mode 100644
index 0000000..2cfc684
--- /dev/null
+++ b/units/systemd-journald.service.in
@@ -0,0 +1,24 @@
+#  This file is part of systemd.
+#
+#  systemd is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+
+# See systemd.special(7) for details
+
+[Unit]
+Description=Journal Service
+DefaultDependencies=no
+Requires=systemd-journald.socket
+After=systemd-journald.socket
+
+[Service]
+ExecStart=@rootlibexecdir@/systemd-journald
+NotifyAccess=all
+StandardOutput=null
+#CapabilityBoundingSet=CAP_SYS_ADMIN CAP_SETUID CAP_SETGID
+
+# Increase the default a bit in order to allow many simultaneous
+# services being run since we keep one fd open per service.
+LimitNOFILE=16384
diff --git a/units/systemd-journald.socket b/units/systemd-journald.socket
new file mode 100644
index 0000000..b439bc1
--- /dev/null
+++ b/units/systemd-journald.socket
@@ -0,0 +1,24 @@
+#  This file is part of systemd.
+#
+#  systemd is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+
+# See systemd.special(7) for details
+
+[Unit]
+Description=Journal Socket
+DefaultDependencies=no
+Before=sockets.target syslog.target
+
+# Mount and swap units need this. If this socket unit is removed by an
+# isolate request the mount and and swap units would be removed too,
+# hence let's exclude this from isolate requests.
+IgnoreOnIsolate=yes
+
+[Socket]
+ListenStream=/run/systemd/stdout
+ListenDatagram=/run/systemd/native
+ListenDatagram=/dev/log
+SocketMode=0666

commit f39e126e990869e33a002763ec02aa0aeb06214a
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Dec 30 16:01:33 2011 +0100

    journald: add missing header

diff --git a/src/journal/journal-internal.h b/src/journal/journal-internal.h
new file mode 100644
index 0000000..1b64666
--- /dev/null
+++ b/src/journal/journal-internal.h
@@ -0,0 +1,83 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+#ifndef foojournalinternalhfoo
+#define foojournalinternalhfoo
+
+/***
+  This file is part of systemd.
+
+  Copyright 2011 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <sys/types.h>
+#include <inttypes.h>
+#include <stdbool.h>
+
+#include "list.h"
+#include "sd-id128.h"
+
+typedef struct Match Match;
+
+struct Match {
+        char *data;
+        size_t size;
+        uint64_t le_hash;
+
+        LIST_FIELDS(Match, matches);
+};
+
+typedef enum location_type {
+        LOCATION_HEAD,
+        LOCATION_TAIL,
+        LOCATION_DISCRETE
+} location_type_t;
+
+typedef struct Location {
+        location_type_t type;
+
+        uint64_t seqnum;
+        sd_id128_t seqnum_id;
+        bool seqnum_set;
+
+        uint64_t realtime;
+        bool realtime_set;
+
+        uint64_t monotonic;
+        sd_id128_t boot_id;
+        bool monotonic_set;
+
+        uint64_t xor_hash;
+        bool xor_hash_set;
+} Location;
+
+struct sd_journal {
+        int flags;
+
+        Hashmap *files;
+
+        Location current_location;
+        JournalFile *current_file;
+        uint64_t current_field;
+
+        int inotify_fd;
+        Hashmap *inotify_wd_dirs;
+        Hashmap *inotify_wd_roots;
+
+        LIST_HEAD(Match, matches);
+        unsigned n_matches;
+};
+
+#endif

commit adb2ce5f694cb528f9294219941b1e37dc6a9530
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Dec 30 15:34:21 2011 +0100

    remount-api-vfs: handle another OOM condition

diff --git a/src/remount-api-vfs.c b/src/remount-api-vfs.c
index 8bbc021..7b14655 100644
--- a/src/remount-api-vfs.c
+++ b/src/remount-api-vfs.c
@@ -54,12 +54,14 @@ int main(int argc, char *argv[]) {
 
         umask(0022);
 
-        if (!(f = setmntent("/etc/fstab", "r"))) {
+        f = setmntent("/etc/fstab", "r");
+        if (!f) {
                 log_error("Failed to open /etc/fstab: %m");
                 goto finish;
         }
 
-        if (!(pids = hashmap_new(trivial_hash_func, trivial_compare_func))) {
+        pids = hashmap_new(trivial_hash_func, trivial_compare_func);
+        if (!pids) {
                 log_error("Failed to allocate set");
                 goto finish;
         }
@@ -76,9 +78,10 @@ int main(int argc, char *argv[]) {
 
                 log_debug("Remounting %s", me->mnt_dir);
 
-                if ((pid = fork()) < 0) {
+                pid = fork();
+                if (pid < 0) {
                         log_error("Failed to fork: %m");
-                        ret = 1;
+                        ret = EXIT_FAILURE;
                         continue;
                 }
 
@@ -101,8 +104,15 @@ int main(int argc, char *argv[]) {
                 /* Parent */
 
                 s = strdup(me->mnt_dir);
+                if (!s) {
+                        log_error("Out of memory.");
+                        ret = EXIT_FAILURE;
+                        continue;
+                }
+
 
-                if ((k = hashmap_put(pids, UINT_TO_PTR(pid), s)) < 0) {
+                k = hashmap_put(pids, UINT_TO_PTR(pid), s);
+                if (k < 0) {
                         log_error("Failed to add PID to set: %s", strerror(-k));
                         ret = EXIT_FAILURE;
                         continue;
@@ -124,7 +134,8 @@ int main(int argc, char *argv[]) {
                         break;
                 }
 
-                if ((s = hashmap_remove(pids, UINT_TO_PTR(si.si_pid)))) {
+                s = hashmap_remove(pids, UINT_TO_PTR(si.si_pid));
+                if (s) {
                         if (!is_clean_exit(si.si_code, si.si_status)) {
                                 if (si.si_code == CLD_EXITED)
                                         log_error("/bin/mount for %s exited with exit status %i.", s, si.si_status);



More information about the systemd-commits mailing list