- r = sd_bus_get_property_string(
- bus,
- "org.freedesktop.systemd1",
- unit,
- "org.freedesktop.systemd1.Unit",
- "FragmentPath",
- &error,
- &fragment_path);
- if (r < 0) {
- log_warning("Failed to get FragmentPath: %s", bus_error_message(&error, r));
- continue;
- }
-
- r = sd_bus_get_property_strv(
- bus,
- "org.freedesktop.systemd1",
- unit,
- "org.freedesktop.systemd1.Unit",
- "DropInPaths",
- &error,
- &dropin_paths);
- if (r < 0) {
- log_warning("Failed to get DropInPaths: %s", bus_error_message(&error, r));
- continue;
- }
-
- if (first)
- first = false;
- else
- puts("");
-
- if (!isempty(fragment_path)) {
- printf("%s# %s%s\n",
- ansi_highlight_blue(),
- fragment_path,
- ansi_highlight_off());
- fflush(stdout);
-
- r = sendfile_full(STDOUT_FILENO, fragment_path);
- if (r < 0) {
- log_warning("Failed to cat %s: %s", fragment_path, strerror(-r));
- continue;
- }
- }
-
- STRV_FOREACH(path, dropin_paths) {
- printf("%s%s# %s%s\n",
- isempty(fragment_path) && path == dropin_paths ? "" : "\n",
- ansi_highlight_blue(),
- *path,
- ansi_highlight_off());
- fflush(stdout);
-
- r = sendfile_full(STDOUT_FILENO, *path);
- if (r < 0) {
- log_warning("Failed to cat %s: %s", *path, strerror(-r));
- continue;
- }
- }
- }
-
- return r < 0 ? r : 0;
-}
-
-static int show_system_status(sd_bus *bus) {
- char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], since2[FORMAT_TIMESTAMP_MAX];
- _cleanup_free_ char *hn = NULL;
- struct machine_info mi = {};
- const char *on, *off;
- int r;
-
- hn = gethostname_malloc();
- if (!hn)
- return log_oom();
-
- r = bus_map_all_properties(bus, "org.freedesktop.systemd1", "/org/freedesktop/systemd1", machine_info_property_map, &mi);
- if (r < 0) {
- log_error("Failed to read server status: %s", strerror(-r));
- return r;
- }
-
- if (streq_ptr(mi.state, "degraded")) {
- on = ansi_highlight_red();
- off = ansi_highlight_off();
- } else if (!streq_ptr(mi.state, "running")) {
- on = ansi_highlight_yellow();
- off = ansi_highlight_off();
- } else
- on = off = "";
-
- printf("%s%s%s%s\n", on, draw_special_char(DRAW_BLACK_CIRCLE), off, arg_host ? arg_host : hn);
-
- printf(" State: %s%s%s\n",
- on, strna(mi.state), off);
-
- printf(" Jobs: %u queued\n", mi.n_jobs);
- printf(" Failed: %u units\n", mi.n_failed_units);