chiark / gitweb /
journalctl: fix counting of -n parameter
[elogind.git] / src / systemctl.c
index 7373e64e8c24c53011694634e01e767fc3136569..6f87b06dd3401c5640bf1e89bdb6fc98940be98f 100644 (file)
@@ -58,6 +58,7 @@
 #include "pager.h"
 #include "spawn-agent.h"
 #include "install.h"
+#include "logs-show.h"
 
 static const char *arg_type = NULL;
 static char **arg_property = NULL;
@@ -377,8 +378,7 @@ static void output_units_list(const struct unit_info *unit_infos, unsigned c) {
 
                 n_shown++;
 
-                if (!streq(u->load_state, "loaded") &&
-                    !streq(u->load_state, "banned")) {
+                if (streq(u->load_state, "error")) {
                         on_loaded = ansi_highlight(true);
                         off_loaded = ansi_highlight(false);
                 } else
@@ -622,8 +622,6 @@ static int list_unit_files(DBusConnection *bus, char **args) {
 
         dbus_error_init(&error);
 
-        assert(bus);
-
         pager_open_if_enabled();
 
         if (avoid_bus()) {
@@ -659,6 +657,8 @@ static int list_unit_files(DBusConnection *bus, char **args) {
 
                 hashmap_free(h);
         } else {
+                assert(bus);
+
                 m = dbus_message_new_method_call(
                                 "org.freedesktop.systemd1",
                                 "/org/freedesktop/systemd1",
@@ -2063,8 +2063,7 @@ static void print_status_info(UnitStatusInfo *i) {
         if (i->following)
                 printf("\t  Follow: unit currently follows state of %s\n", i->following);
 
-        if (streq_ptr(i->load_state, "failed") ||
-            streq_ptr(i->load_state, "banned")) {
+        if (streq_ptr(i->load_state, "error")) {
                 on = ansi_highlight(true);
                 off = ansi_highlight(false);
         } else
@@ -2201,7 +2200,7 @@ static void print_status_info(UnitStatusInfo *i) {
 
                         if (i->running) {
                                 char *t = NULL;
-                                get_process_name(i->main_pid, &t);
+                                get_process_comm(i->main_pid, &t);
                                 if (t) {
                                         printf(" (%s)", t);
                                         free(t);
@@ -2235,7 +2234,7 @@ static void print_status_info(UnitStatusInfo *i) {
 
                         printf(" Control: %u", (unsigned) i->control_pid);
 
-                        get_process_name(i->control_pid, &t);
+                        get_process_comm(i->control_pid, &t);
                         if (t) {
                                 printf(" (%s)", t);
                                 free(t);
@@ -2263,6 +2262,11 @@ static void print_status_info(UnitStatusInfo *i) {
                 }
         }
 
+        if (i->id && arg_transport != TRANSPORT_SSH) {
+                printf("\n");
+                show_journal_by_service(i->id, OUTPUT_SHORT, NULL, 0, 0, 0, arg_all);
+        }
+
         if (i->need_daemon_reload)
                 printf("\n%sWarning:%s Unit file changed on disk, 'systemctl %s daemon-reload' recommended.\n",
                        ansi_highlight(true),
@@ -5000,7 +5004,8 @@ static int systemctl_main(DBusConnection *bus, int argc, char *argv[], DBusError
          * enable/disable */
         if (!streq(verbs[i].verb, "enable") &&
             !streq(verbs[i].verb, "disable") &&
-            !streq(verbs[i].verb, "is-enable") &&
+            !streq(verbs[i].verb, "is-enabled") &&
+            !streq(verbs[i].verb, "list-unit-files") &&
             !streq(verbs[i].verb, "reenable") &&
             !streq(verbs[i].verb, "preset") &&
             !streq(verbs[i].verb, "mask") &&