diff options
author | Karel Zak | 2011-07-20 17:03:24 +0200 |
---|---|---|
committer | Karel Zak | 2011-07-20 17:03:24 +0200 |
commit | 608d45015f78d85510b22181e7afd189876ac6c6 (patch) | |
tree | d029eacbed8cba43d2aeeaf44a1dc1d66204bd37 /sys-utils/dmesg.c | |
parent | dmesg: mark some options mutually exclusive (diff) | |
download | kernel-qcow2-util-linux-608d45015f78d85510b22181e7afd189876ac6c6.tar.gz kernel-qcow2-util-linux-608d45015f78d85510b22181e7afd189876ac6c6.tar.xz kernel-qcow2-util-linux-608d45015f78d85510b22181e7afd189876ac6c6.zip |
dmesg: allow to print time delta without timestamp
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/dmesg.c')
-rw-r--r-- | sys-utils/dmesg.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c index 2be34075a..7123c7fb6 100644 --- a/sys-utils/dmesg.c +++ b/sys-utils/dmesg.c @@ -512,14 +512,14 @@ static int get_next_record(struct dmesg_control *ctl, struct dmesg_record *rec) if (*begin == '[' && (*(begin + 1) == ' ' || isdigit(*(begin + 1)))) { - if (ctl->notime) { /* ignore timestamp */ + if (ctl->delta || ctl->ctime) { + begin = parse_timestamp(begin + 1, &rec->tv); + } else if (ctl->notime) { while (begin < end) { begin++; if (*(begin - 1) == ']') break; } - } else if (ctl->delta || ctl->ctime) { - begin = parse_timestamp(begin + 1, &rec->tv); } } @@ -596,6 +596,8 @@ static void print_buffer(const char *buf, size_t size, if (ctl->ctime && *tbuf) printf("[%s ", tbuf); + else if (ctl->notime) + putchar('['); else printf("[%5d.%06d ", (int) rec.tv.tv_sec, (int) rec.tv.tv_usec); @@ -738,9 +740,8 @@ int main(int argc, char *argv[]) errx(EXIT_FAILURE, _("--raw can't be used together with level, " "facility, decode, delta, ctime or notime options")); - if (ctl.notime && (ctl.ctime || ctl.delta)) - errx(EXIT_FAILURE, _("--notime can't be used together with ctime " - "or delta options")); + if (ctl.notime && ctl.ctime) + errx(EXIT_FAILURE, _("--notime can't be used together with ctime ")); switch (cmd) { case SYSLOG_ACTION_READ_ALL: |