chiark / gitweb /
systemctl: minor coding style fixes
[elogind.git] / src / systemctl / systemctl.c
index 14f8a129d58a321ddee28f5970d9906beaf6df45..efb9ae29462be9ed911fb88c04afd2e4738f3e53 100644 (file)
@@ -425,9 +425,11 @@ static void output_units_list(const struct unit_info *unit_infos, unsigned c) {
                        "JOB    = Pending job for the unit.\n");
 
                 if (arg_all)
-                        printf("\n%u units listed.\n", n_shown);
+                        printf("\n%u loaded units listed.\n"
+                               "To show all installed unit files use 'systemctl list-unit-files'.\n", n_shown);
                 else
-                        printf("\n%u units listed. Pass --all to see inactive units, too.\n", n_shown);
+                        printf("\n%u loaded units listed. Pass --all to see loaded but inactive units, too.\n"
+                               "To show all installed unit files use 'systemctl list-unit-files'.\n", n_shown);
         }
 }
 
@@ -585,7 +587,8 @@ static void output_unit_file_list(const UnitFileList *units, unsigned c) {
 
                 if (u->state == UNIT_FILE_MASKED ||
                     u->state == UNIT_FILE_MASKED_RUNTIME ||
-                    u->state == UNIT_FILE_DISABLED) {
+                    u->state == UNIT_FILE_DISABLED ||
+                    u->state == UNIT_FILE_INVALID) {
                         on  = ansi_highlight_red(true);
                         off = ansi_highlight_red(false);
                 } else if (u->state == UNIT_FILE_ENABLED) {
@@ -2259,7 +2262,7 @@ static void print_status_info(UnitStatusInfo *i) {
 
         if (i->id && arg_transport != TRANSPORT_SSH) {
                 int flags =
-                        arg_lines * OUTPUT_SHOW_ALL |
+                        arg_all * OUTPUT_SHOW_ALL |
                         arg_follow * OUTPUT_FOLLOW |
                         !arg_quiet * OUTPUT_WARN_CUTOFF |
                         on_tty() * OUTPUT_COLOR;
@@ -3548,6 +3551,30 @@ finish:
         return r;
 }
 
+static int mangle_names(char **original_names, char ***mangled_names) {
+        char **i, **l, **name;
+
+        l = new(char*, strv_length(original_names) + 1);
+        if (!l)
+                return log_oom();
+
+        i = l;
+        STRV_FOREACH(name, original_names) {
+                *i = unit_name_mangle(*name);
+                if (!*i) {
+                        strv_free(l);
+                        return log_oom();
+                }
+
+                i++;
+        }
+
+        *i = NULL;
+        *mangled_names = l;
+
+        return 0;
+}
+
 static int enable_unit(DBusConnection *bus, char **args) {
         const char *verb = args[0];
         UnitFileChange *changes = NULL;
@@ -3556,6 +3583,7 @@ static int enable_unit(DBusConnection *bus, char **args) {
         DBusMessage *m = NULL, *reply = NULL;
         int r;
         DBusError error;
+        char **mangled_names = NULL;
 
         r = enable_sysv_units(args);
         if (r < 0)
@@ -3641,7 +3669,11 @@ static int enable_unit(DBusConnection *bus, char **args) {
 
                 dbus_message_iter_init_append(m, &iter);
 
-                r = bus_append_strv_iter(&iter, args+1);
+                r = mangle_names(args+1, &mangled_names);
+                if(r < 0)
+                        goto finish;
+
+                r = bus_append_strv_iter(&iter, mangled_names);
                 if (r < 0) {
                         log_error("Failed to append unit files.");
                         goto finish;
@@ -3741,6 +3773,9 @@ finish:
         unit_file_changes_free(changes, n_changes);
 
         dbus_error_free(&error);
+
+        strv_free(mangled_names);
+
         return r;
 }