[systemd-commits] 2 commits - man/systemd.unit.xml src/journal

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Mon Jan 28 23:31:22 PST 2013


 man/systemd.unit.xml     |    7 +++----
 src/journal/journalctl.c |   25 ++++++++++++++++---------
 2 files changed, 19 insertions(+), 13 deletions(-)

New commits:
commit e65c85abcf17c9ab92f6a2eb45704a17b466fd64
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Mon Jan 28 22:10:50 2013 -0500

    man: grammar fix

diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml
index dcdfc1e..c09b8aa 100644
--- a/man/systemd.unit.xml
+++ b/man/systemd.unit.xml
@@ -159,11 +159,10 @@
 
                 <para>Note that while systemd offers a flexible
                 dependency system between units it is recommended to
-                use this functionality only sparsely and instead rely
+                use this functionality only sparingly and instead rely
                 on techniques such as bus-based or socket-based
-                activation which makes dependencies implicit, which
-                both results in a simpler and more flexible
-                system.</para>
+                activation which make dependencies implicit, resulting
+                in a both simpler and more flexible system.</para>
 
                 <para>Some unit names reflect paths existing in the
                 file system name space. Example: a device unit

commit 67e04a486b92fcb656049cb4d6b66148c7d2e61b
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Sun Jan 27 23:53:52 2013 -0500

    journalctl: allow --lines=0 i.e. only new
    
    Makes it easier to watch just for new entries. Once scenario
    is where the user starts 'journalctl -qfn0' to watch for changes
    during some operation.

diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 45543a5..0ec2f33 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -60,7 +60,7 @@ static bool arg_follow = false;
 static bool arg_full = false;
 static bool arg_all = false;
 static bool arg_no_pager = false;
-static unsigned arg_lines = 0;
+static int arg_lines = -1;
 static bool arg_no_tail = false;
 static bool arg_quiet = false;
 static bool arg_merge = false;
@@ -239,8 +239,8 @@ static int parse_argv(int argc, char *argv[]) {
 
                 case 'n':
                         if (optarg) {
-                                r = safe_atou(optarg, &arg_lines);
-                                if (r < 0 || arg_lines <= 0) {
+                                r = safe_atoi(optarg, &arg_lines);
+                                if (r < 0 || arg_lines < 0) {
                                         log_error("Failed to parse lines '%s'", optarg);
                                         return -EINVAL;
                                 }
@@ -413,7 +413,7 @@ static int parse_argv(int argc, char *argv[]) {
                 }
         }
 
-        if (arg_follow && !arg_no_tail && arg_lines <= 0)
+        if (arg_follow && !arg_no_tail && arg_lines < 0)
                 arg_lines = 10;
 
         if (arg_since_set && arg_until_set && arg_since_set > arg_until_set) {
@@ -849,8 +849,8 @@ int main(int argc, char *argv[]) {
         sd_journal *j = NULL;
         bool need_seek = false;
         sd_id128_t previous_boot_id;
-        bool previous_boot_id_valid = false;
-        unsigned n_shown = 0;
+        bool previous_boot_id_valid = false, first_line = true;
+        int n_shown = 0;
 
         setlocale(LC_ALL, "");
         log_parse_environment();
@@ -937,6 +937,11 @@ int main(int argc, char *argv[]) {
         if (r < 0)
                 goto finish;
 
+        /* Opening the fd now means the first sd_journal_wait() will actually wait */
+        r = sd_journal_get_fd(j);
+        if (r < 0)
+                goto finish;
+
         if (arg_field) {
                 const void *data;
                 size_t size;
@@ -950,7 +955,7 @@ int main(int argc, char *argv[]) {
                 SD_JOURNAL_FOREACH_UNIQUE(j, data, size) {
                         const void *eq;
 
-                        if (arg_lines > 0 && n_shown >= arg_lines)
+                        if (arg_lines >= 0 && n_shown >= arg_lines)
                                 break;
 
                         eq = memchr(data, '=', size);
@@ -983,7 +988,7 @@ int main(int argc, char *argv[]) {
                 }
                 r = sd_journal_next(j);
 
-        } else if (arg_lines > 0) {
+        } else if (arg_lines >= 0) {
                 r = sd_journal_seek_tail(j);
                 if (r < 0) {
                         log_error("Failed to seek to tail: %s", strerror(-r));
@@ -1032,7 +1037,7 @@ int main(int argc, char *argv[]) {
         }
 
         for (;;) {
-                while (arg_lines == 0 || arg_follow || n_shown < arg_lines) {
+                while (arg_lines < 0 || n_shown < arg_lines || (arg_follow && !first_line)) {
                         int flags;
 
                         if (need_seek) {
@@ -1092,6 +1097,8 @@ int main(int argc, char *argv[]) {
                         log_error("Couldn't wait for journal event: %s", strerror(-r));
                         goto finish;
                 }
+
+                first_line = false;
         }
 
 finish:



More information about the systemd-commits mailing list