[systemd-commits] 3 commits - src/journal

Lennart Poettering lennart at kemper.freedesktop.org
Tue Oct 9 16:37:50 PDT 2012


 src/journal/journal-internal.h |   10 +++++++++-
 src/journal/journalctl.c       |    2 +-
 src/journal/sd-journal.c       |   20 +++++++++++---------
 3 files changed, 21 insertions(+), 11 deletions(-)

New commits:
commit a3eb665e0c12df35e807611582e7332ebed325b1
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 10 01:37:38 2012 +0200

    journal: update comments a bit

diff --git a/src/journal/journal-internal.h b/src/journal/journal-internal.h
index 7cedcac..edd4f23 100644
--- a/src/journal/journal-internal.h
+++ b/src/journal/journal-internal.h
@@ -57,9 +57,16 @@ struct Match {
 };
 
 typedef enum LocationType {
+        /* The first and last entries, resp. */
         LOCATION_HEAD,
         LOCATION_TAIL,
+
+        /* We already read the entry we currently point to, and the
+         * next one to read should probably not be this one again. */
         LOCATION_DISCRETE,
+
+        /* We should seek to the precise location specified, and
+         * return it, as we haven't read it yet. */
         LOCATION_SEEK
 } LocationType;
 

commit ad9eafab9fb182388777bab4bc7d32fd84702198
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 10 01:35:24 2012 +0200

    journalctl: properly parse --cursor= long getopt in addition to short -c

diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index b6f9b2f..ec05c16 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -150,7 +150,7 @@ static int parse_argv(int argc, char *argv[]) {
                 { "verify",       no_argument,       NULL, ARG_VERIFY       },
                 { "verify-key",   required_argument, NULL, ARG_VERIFY_KEY   },
                 { "disk-usage",   no_argument,       NULL, ARG_DISK_USAGE   },
-                { "cursor",       no_argument,       NULL, 'c'              },
+                { "cursor",       required_argument, NULL, 'c'              },
                 { NULL,           0,                 NULL, 0                }
         };
 

commit a87247dd5dc3892f858e920d09b16cc2a8b9b3c4
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 10 01:34:27 2012 +0200

    journal: make sure sd_journal_seek_cursor() seeks to the specified entry if it exists, not one after it

diff --git a/src/journal/journal-internal.h b/src/journal/journal-internal.h
index 86519be..7cedcac 100644
--- a/src/journal/journal-internal.h
+++ b/src/journal/journal-internal.h
@@ -59,7 +59,8 @@ struct Match {
 typedef enum LocationType {
         LOCATION_HEAD,
         LOCATION_TAIL,
-        LOCATION_DISCRETE
+        LOCATION_DISCRETE,
+        LOCATION_SEEK
 } LocationType;
 
 struct Location {
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index 05a8445..6764f2e 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -58,12 +58,13 @@ static void reset_location(sd_journal *j) {
         zero(j->current_location);
 }
 
-static void init_location(Location *l, JournalFile *f, Object *o) {
+static void init_location(Location *l, LocationType type, JournalFile *f, Object *o) {
         assert(l);
+        assert(type == LOCATION_DISCRETE || type == LOCATION_SEEK);
         assert(f);
         assert(o->object.type == OBJECT_ENTRY);
 
-        l->type = LOCATION_DISCRETE;
+        l->type = type;
         l->seqnum = le64toh(o->entry.seqnum);
         l->seqnum_id = f->header->seqnum_id;
         l->realtime = le64toh(o->entry.realtime);
@@ -74,12 +75,13 @@ static void init_location(Location *l, JournalFile *f, Object *o) {
         l->seqnum_set = l->realtime_set = l->monotonic_set = l->xor_hash_set = true;
 }
 
-static void set_location(sd_journal *j, JournalFile *f, Object *o, uint64_t offset) {
+static void set_location(sd_journal *j, LocationType type, JournalFile *f, Object *o, uint64_t offset) {
         assert(j);
+        assert(type == LOCATION_DISCRETE || type == LOCATION_SEEK);
         assert(f);
         assert(o);
 
-        init_location(&j->current_location, f, o);
+        init_location(&j->current_location, type, f, o);
 
         j->current_file = f;
         j->current_field = 0;
@@ -447,7 +449,7 @@ static int compare_with_location(JournalFile *af, Object *ao, Location *l) {
         assert(af);
         assert(ao);
         assert(l);
-        assert(l->type == LOCATION_DISCRETE);
+        assert(l->type == LOCATION_DISCRETE || l->type == LOCATION_SEEK);
 
         if (l->monotonic_set &&
             sd_id128_equal(ao->entry.boot_id, l->boot_id) &&
@@ -866,7 +868,7 @@ static int real_journal_next(sd_journal *j, direction_t direction) {
         if (r < 0)
                 return r;
 
-        set_location(j, new_file, o, new_offset);
+        set_location(j, LOCATION_DISCRETE, new_file, o, new_offset);
 
         return 1;
 }
@@ -1029,7 +1031,7 @@ _public_ int sd_journal_seek_cursor(sd_journal *j, const char *cursor) {
 
         reset_location(j);
 
-        j->current_location.type = LOCATION_DISCRETE;
+        j->current_location.type = LOCATION_SEEK;
 
         if (realtime_set) {
                 j->current_location.realtime = (uint64_t) realtime;
@@ -1061,7 +1063,7 @@ _public_ int sd_journal_seek_monotonic_usec(sd_journal *j, sd_id128_t boot_id, u
                 return -EINVAL;
 
         reset_location(j);
-        j->current_location.type = LOCATION_DISCRETE;
+        j->current_location.type = LOCATION_SEEK;
         j->current_location.boot_id = boot_id;
         j->current_location.monotonic = usec;
         j->current_location.monotonic_set = true;
@@ -1074,7 +1076,7 @@ _public_ int sd_journal_seek_realtime_usec(sd_journal *j, uint64_t usec) {
                 return -EINVAL;
 
         reset_location(j);
-        j->current_location.type = LOCATION_DISCRETE;
+        j->current_location.type = LOCATION_SEEK;
         j->current_location.realtime = usec;
         j->current_location.realtime_set = true;
 



More information about the systemd-commits mailing list