From 69c751c61cb2b386afe51f03b58f8f7ceeeb643e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 27 Sep 2024 20:17:12 +0200 Subject: [PATCH 1/2] systemctl: fix printing of RootImageOptions The type is a(ss), so a custom printer is required. Fixes https://github.com/systemd/systemd/issues/33967. --- src/systemctl/systemctl-show.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c index 2f39bc2b12fef..67a72bdc94a26 100644 --- a/src/systemctl/systemctl-show.c +++ b/src/systemctl/systemctl-show.c @@ -1769,6 +1769,29 @@ static int print_property(const char *name, const char *expected_value, sd_bus_m return bus_log_parse_error(r); return 1; + + } else if (streq(name, "RootImageOptions")) { + const char *a, *p; + + /* In config files, the syntax allows the partition name to be omitted. Here, we + * always print the partition name, also because we have no way of knowing if it was + * originally omitted or not. We also print the partitions on separate lines. */ + + r = sd_bus_message_enter_container(m, SD_BUS_TYPE_ARRAY, "(ss)"); + if (r < 0) + return bus_log_parse_error(r); + + while ((r = sd_bus_message_read(m, "(ss)", &a, &p)) > 0) + bus_print_property_valuef(name, expected_value, flags, "%s:%s", a, p); + if (r < 0) + return bus_log_parse_error(r); + + r = sd_bus_message_exit_container(m); + if (r < 0) + return bus_log_parse_error(r); + + return 1; + } else if (streq(name, "MountImages")) { _cleanup_free_ char *paths = NULL; From 8dc40c25a46fb6bc99a051d8cf8b796fdf290947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 27 Sep 2024 20:18:16 +0200 Subject: [PATCH 2/2] shared: adjust whitespace and formatting --- src/shared/bus-print-properties.c | 4 +++- src/shared/bus-unit-util.c | 11 +++++++---- src/systemctl/systemctl-show.c | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/shared/bus-print-properties.c b/src/shared/bus-print-properties.c index 99b1cc7c70992..7da8cb1b12638 100644 --- a/src/shared/bus-print-properties.c +++ b/src/shared/bus-print-properties.c @@ -363,8 +363,10 @@ int bus_message_print_all_properties( if (!name_with_equal) return log_oom(); - if (!filter || strv_contains(filter, name) || + if (!filter || + strv_contains(filter, name) || (expected_value = strv_find_startswith(filter, name_with_equal))) { + r = sd_bus_message_peek_type(m, NULL, &contents); if (r < 0) return r; diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c index dc92c5f609dd7..fc923314364a6 100644 --- a/src/shared/bus-unit-util.c +++ b/src/shared/bus-unit-util.c @@ -656,9 +656,9 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons if (r >= 0) { char *n; - /* When this is a percentage we'll convert this into a relative value in the range 0…UINT32_MAX - * and pass it in the MemoryLowScale property (and related ones). This way the physical memory - * size can be determined server-side. */ + /* When this is a percentage we'll convert this into a relative value in the range + * 0…UINT32_MAX and pass it in the MemoryLowScale property (and related ones). This + * way the physical memory size can be determined server-side. */ n = strjoina(field, "Scale"); r = sd_bus_message_append(m, "(sv)", n, "u", UINT32_SCALE_FROM_PERMYRIAD(r)); @@ -728,7 +728,10 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons return 1; } - if (cgroup_io_limit_type_from_string(field) >= 0 || STR_IN_SET(field, "BlockIOReadBandwidth", "BlockIOWriteBandwidth")) { + if (cgroup_io_limit_type_from_string(field) >= 0 || + STR_IN_SET(field, "BlockIOReadBandwidth", + "BlockIOWriteBandwidth")) { + if (isempty(eq)) r = sd_bus_message_append(m, "(sv)", field, "a(st)", 0); else { diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c index 67a72bdc94a26..bdd438bc2ca0a 100644 --- a/src/systemctl/systemctl-show.c +++ b/src/systemctl/systemctl-show.c @@ -2031,8 +2031,8 @@ typedef enum SystemctlShowMode{ static const char* const systemctl_show_mode_table[_SYSTEMCTL_SHOW_MODE_MAX] = { [SYSTEMCTL_SHOW_PROPERTIES] = "show", - [SYSTEMCTL_SHOW_STATUS] = "status", - [SYSTEMCTL_SHOW_HELP] = "help", + [SYSTEMCTL_SHOW_STATUS] = "status", + [SYSTEMCTL_SHOW_HELP] = "help", }; DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(systemctl_show_mode, SystemctlShowMode);