|
|
8d419f |
From ab458e74eccf14550711ca024e9176fba7993abc Mon Sep 17 00:00:00 2001
|
|
|
8d419f |
From: Frantisek Sumsal <frantisek@sumsal.cz>
|
|
|
8d419f |
Date: Fri, 18 Feb 2022 23:09:18 +0100
|
|
|
8d419f |
Subject: [PATCH] systemctl: make `--timestamp=` affect the `show` verb as well
|
|
|
8d419f |
|
|
|
8d419f |
Currently the `--timestamp=` option has no effect on timestamps shown by
|
|
|
8d419f |
`systemctl show`, let's fix that.
|
|
|
8d419f |
|
|
|
8d419f |
Spotted in #22567.
|
|
|
8d419f |
|
|
|
8d419f |
Before:
|
|
|
8d419f |
```
|
|
|
8d419f |
$ systemctl show --timestamp=us+utc systemd-journald | grep Timestamp=
|
|
|
8d419f |
ExecMainStartTimestamp=Sat 2021-12-11 15:25:57 CET
|
|
|
8d419f |
StateChangeTimestamp=Sat 2021-12-11 15:25:57 CET
|
|
|
8d419f |
InactiveExitTimestamp=Sat 2021-12-11 15:25:57 CET
|
|
|
8d419f |
ActiveEnterTimestamp=Sat 2021-12-11 15:25:57 CET
|
|
|
8d419f |
ActiveExitTimestamp=Sat 2021-12-11 15:25:57 CET
|
|
|
8d419f |
InactiveEnterTimestamp=Sat 2021-12-11 15:25:57 CET
|
|
|
8d419f |
ConditionTimestamp=Sat 2021-12-11 15:25:57 CET
|
|
|
8d419f |
AssertTimestamp=Sat 2021-12-11 15:25:57 CET
|
|
|
8d419f |
```
|
|
|
8d419f |
|
|
|
8d419f |
After:
|
|
|
8d419f |
```
|
|
|
8d419f |
$ systemctl show --timestamp=us+utc systemd-journald | grep Timestamp=
|
|
|
8d419f |
ExecMainStartTimestamp=Sat 2021-12-11 14:25:57.177848 UTC
|
|
|
8d419f |
StateChangeTimestamp=Sat 2021-12-11 14:25:57.196714 UTC
|
|
|
8d419f |
InactiveExitTimestamp=Sat 2021-12-11 14:25:57.177871 UTC
|
|
|
8d419f |
ActiveEnterTimestamp=Sat 2021-12-11 14:25:57.196714 UTC
|
|
|
8d419f |
ActiveExitTimestamp=Sat 2021-12-11 14:25:57.144677 UTC
|
|
|
8d419f |
InactiveEnterTimestamp=Sat 2021-12-11 14:25:57.176331 UTC
|
|
|
8d419f |
ConditionTimestamp=Sat 2021-12-11 14:25:57.176980 UTC
|
|
|
8d419f |
AssertTimestamp=Sat 2021-12-11 14:25:57.176980 UTC
|
|
|
8d419f |
|
|
|
8d419f |
```
|
|
|
8d419f |
|
|
|
8d419f |
(cherry picked from commit a59e5c625da5a6e0c46e493d55f2f4212e9457ca)
|
|
|
8d419f |
|
|
|
8d419f |
Related: #2017035
|
|
|
8d419f |
---
|
|
|
8d419f |
src/systemctl/systemctl-show.c | 14 ++++++++++++++
|
|
|
8d419f |
1 file changed, 14 insertions(+)
|
|
|
8d419f |
|
|
|
8d419f |
diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c
|
|
|
8d419f |
index 9b23471990..7a6655da74 100644
|
|
|
8d419f |
--- a/src/systemctl/systemctl-show.c
|
|
|
8d419f |
+++ b/src/systemctl/systemctl-show.c
|
|
|
8d419f |
@@ -1001,6 +1001,20 @@ static int print_property(const char *name, const char *expected_value, sd_bus_m
|
|
|
8d419f |
}
|
|
|
8d419f |
break;
|
|
|
8d419f |
|
|
|
8d419f |
+ case SD_BUS_TYPE_UINT64:
|
|
|
8d419f |
+ if (endswith(name, "Timestamp")) {
|
|
|
8d419f |
+ uint64_t timestamp;
|
|
|
8d419f |
+
|
|
|
8d419f |
+ r = sd_bus_message_read_basic(m, bus_type, ×tamp);
|
|
|
8d419f |
+ if (r < 0)
|
|
|
8d419f |
+ return r;
|
|
|
8d419f |
+
|
|
|
8d419f |
+ bus_print_property_value(name, expected_value, flags, FORMAT_TIMESTAMP_STYLE(timestamp, arg_timestamp_style));
|
|
|
8d419f |
+
|
|
|
8d419f |
+ return 1;
|
|
|
8d419f |
+ }
|
|
|
8d419f |
+ break;
|
|
|
8d419f |
+
|
|
|
8d419f |
case SD_BUS_TYPE_STRUCT:
|
|
|
8d419f |
|
|
|
8d419f |
if (contents[0] == SD_BUS_TYPE_UINT32 && streq(name, "Job")) {
|