[systemd-devel] [PATCH] [RFC] Add DropIn paths to status message
Oleksii Shevchuk
alxchk at gmail.com
Fri Apr 5 08:27:04 PDT 2013
> dctl status null.target
null.target - NYAN
Loaded: loaded (/home/alxchk/.config/systemd/user/null.target; disabled)
DropIn: /home/alxchk/.config/systemd/user/null.target.d
├─descr.conf
├─install-1.conf
└─install.conf
/etc/systemd/user/null.target.d
└─test.conf
Active: inactive (dead)
---
src/systemctl/systemctl.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+)
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index a7c2eef..45688d0 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -2225,6 +2225,8 @@ typedef struct UnitStatusInfo {
const char *source_path;
const char *default_control_group;
+ char **dropin_paths;
+
const char *load_error;
const char *result;
@@ -2285,6 +2287,7 @@ static void print_status_info(UnitStatusInfo *i) {
arg_full * OUTPUT_FULL_WIDTH;
int maxlen = 8; /* a value that'll suffice most of the time */
char **t, **t2;
+ unsigned dropins_count = 0;
assert(i);
@@ -2331,6 +2334,50 @@ static void print_status_info(UnitStatusInfo *i) {
printf(" %*s: %s%s%s\n",
maxlen, "Loaded", on, strna(i->load_state), off);
+ dropins_count = strv_length(i->dropin_paths);
+ if (dropins_count > 0) {
+ char ** dropin;
+ char * last_dir = NULL;
+ bool last = false;
+
+ STRV_FOREACH(dropin, i->dropin_paths) {
+ const char *dp;
+
+ if (! last_dir || last) {
+ char *dd;
+
+ printf(" %*s ", maxlen, last_dir ? "" : "DropIn:");
+
+ free(last_dir);
+ last_dir = strdup(*dropin);
+
+ if (! last_dir) {
+ log_oom();
+ return;
+ }
+
+ dd = strrchr(last_dir, '/');
+
+ assert(dd);
+
+ *dd = '\0';
+
+ printf("%s\n", last_dir);
+ }
+
+ last = ! (*(dropin+1) && startswith(*(dropin+1), last_dir));
+
+ dp = strrchr(*dropin, '/');
+ assert(dp);
+
+ printf(" %*s\t%s%s\n", maxlen, "",
+ draw_special_char(last ? DRAW_TREE_RIGHT : DRAW_TREE_BRANCH),
+ dp + 1);
+ }
+
+ free(last_dir);
+ }
+
ss = streq_ptr(i->active_state, i->sub_state) ? NULL : i->sub_state;
if (streq_ptr(i->active_state, "failed")) {
@@ -2771,6 +2818,24 @@ static int status_property(const char *name, DBusMessageIter *iter, UnitStatusIn
return 0;
+ } else if (dbus_message_iter_get_element_type(iter) == DBUS_TYPE_STRING && streq(name, "DropInPaths")) {
+
+ DBusMessageIter sub;
+
+ dbus_message_iter_recurse(iter, &sub);
+ while (dbus_message_iter_get_arg_type(&sub) == DBUS_TYPE_STRING) {
+ const char *s;
+ int r;
+
+ dbus_message_iter_get_basic(&sub, &s);
+
+ r = strv_extend(&i->dropin_paths, s);
+ if (r < 0)
+ return r;
+
+ dbus_message_iter_next(&sub);
+ }
+
} else if (dbus_message_iter_get_element_type(iter) == DBUS_TYPE_STRING &&
streq(name, "Documentation")) {
@@ -3106,6 +3171,7 @@ static int show_one(const char *verb, DBusConnection *bus, const char *path, boo
}
strv_free(info.documentation);
+ strv_free(info.dropin_paths);
strv_free(info.listen);
if (!streq_ptr(info.active_state, "active") &&
--
1.8.1.2
More information about the systemd-devel
mailing list