diff options
Diffstat (limited to 'src/machine/machinectl.c')
-rw-r--r-- | src/machine/machinectl.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index 9c754b4327..3294ea7821 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -138,7 +138,7 @@ static void clean_machine_info(MachineInfo *machines, size_t n_machines) { free(machines); } -static int get_os_release_property(sd_bus *bus, const char *name, const char *query, ...) { +static int call_get_os_release(sd_bus *bus, const char *method, const char *name, const char *query, ...) { _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; const char *k, *v, *iter, **query_res = NULL; size_t count = 0, awaited_args = 0; @@ -153,12 +153,13 @@ static int get_os_release_property(sd_bus *bus, const char *name, const char *qu awaited_args++; query_res = newa0(const char *, awaited_args); - r = sd_bus_call_method(bus, - "org.freedesktop.machine1", - "/org/freedesktop/machine1", - "org.freedesktop.machine1.Manager", - "GetMachineOSRelease", - NULL, &reply, "s", name); + r = sd_bus_call_method( + bus, + "org.freedesktop.machine1", + "/org/freedesktop/machine1", + "org.freedesktop.machine1.Manager", + method, + NULL, &reply, "s", name); if (r < 0) return r; @@ -193,7 +194,7 @@ static int get_os_release_property(sd_bus *bus, const char *name, const char *qu val = strdup(query_res[count]); if (!val) { va_end(ap); - return log_oom(); + return -ENOMEM; } *out = val; } @@ -249,8 +250,12 @@ static int list_machines(int argc, char *argv[], void *userdata) { machines[n_machines].os = NULL; machines[n_machines].version_id = NULL; - r = get_os_release_property(bus, name, - "ID\0" "VERSION_ID\0", + r = call_get_os_release( + bus, + "GetMachineOSRelease", + name, + "ID\0" + "VERSION_ID\0", &machines[n_machines].os, &machines[n_machines].version_id); if (r < 0) @@ -610,7 +615,7 @@ static int print_addresses(sd_bus *bus, const char *name, int ifi, const char *p return 0; } -static int print_os_release(sd_bus *bus, const char *name, const char *prefix) { +static int print_os_release(sd_bus *bus, const char *method, const char *name, const char *prefix) { _cleanup_free_ char *pretty = NULL; int r; @@ -618,7 +623,7 @@ static int print_os_release(sd_bus *bus, const char *name, const char *prefix) { assert(name); assert(prefix); - r = get_os_release_property(bus, name, "PRETTY_NAME\0", &pretty, NULL); + r = call_get_os_release(bus, method, name, "PRETTY_NAME\0", &pretty, NULL); if (r < 0) return r; @@ -729,7 +734,7 @@ static void print_machine_status_info(sd_bus *bus, MachineStatusInfo *i) { "\n\t ", ALL_IP_ADDRESSES); - print_os_release(bus, i->name, "\t OS: "); + print_os_release(bus, "GetMachineOSRelease", i->name, "\t OS: "); if (i->unit) { printf("\t Unit: %s\n", i->unit); @@ -927,6 +932,8 @@ static void print_image_status_info(sd_bus *bus, ImageStatusInfo *i) { if (i->path) printf("\t Path: %s\n", i->path); + print_os_release(bus, "GetImageOSRelease", i->name, "\t OS: "); + printf("\t RO: %s%s%s\n", i->read_only ? ansi_highlight_red() : "", i->read_only ? "read-only" : "writable", |