chiark / gitweb /
systemctl: introduce --failed to show only failed services
authorLennart Poettering <lennart@poettering.net>
Wed, 16 Feb 2011 19:34:59 +0000 (20:34 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 16 Feb 2011 19:34:59 +0000 (20:34 +0100)
TODO
man/systemctl.xml
src/systemctl-bash-completion.sh
src/systemctl.c

diff --git a/TODO b/TODO
index 65a102c..aa405e6 100644 (file)
--- a/TODO
+++ b/TODO
@@ -5,8 +5,6 @@ Bugs:
 * when plymouth is disabled the console password entry stuff seems to be borked
   https://bugzilla.redhat.com/show_bug.cgi?id=655538
 
-* systemctl default is started when we type "reboot" at rescue mode prompt
-
 * exclude java hsp files by default
   https://bugzilla.redhat.com/show_bug.cgi?id=527425
 
@@ -14,8 +12,6 @@ Features:
 
 * add --ignore-deps to systemctl
 
-* add --failed to systemctl
-
 * increase password timeout
 
 * look up crypto partition mount points via fstab to show to the user when prompting for a password
index c21ed85..c45b11a 100644 (file)
                         </varlistentry>
 
                         <varlistentry>
+                                <term><option>--failed</option></term>
+
+                                <listitem><para>When listing units,
+                                show only failed units. Do not confuse
+                                with
+                                <option>--fail</option>.</para></listitem>
+                        </varlistentry>
+
+                        <varlistentry>
                                 <term><option>--full</option></term>
 
                                 <listitem><para>Do not ellipsize unit
                                 unfinished job, fail the command. If
                                 this is not specified the requested
                                 operation will replace the pending job,
-                                if necessary.</para></listitem>
+                                if necessary. Do not confuse
+                                with
+                                <option>--failed</option>.</para></listitem>
                         </varlistentry>
 
                         <varlistentry>
index 3e3380c..834e11d 100644 (file)
@@ -42,7 +42,7 @@ _systemctl () {
         local verb comps
 
         local -A OPTS=(
-               [STANDALONE]='--all -a --defaults --fail --force -f --full --global
+               [STANDALONE]='--all -a --defaults --fail --failed --force -f --full --global
                              --help -h --no-ask-password --no-block --no-reload --no-wall
                              --order --require --quiet -q --system --user --version'
                       [ARG]='--kill-mode --kill-who --property -p --signal -s --type -t'
index dfa952e..df4fccc 100644 (file)
@@ -76,6 +76,7 @@ static bool arg_full = false;
 static bool arg_force = false;
 static bool arg_defaults = false;
 static bool arg_ask_password = false;
+static bool arg_failed = false;
 static char **arg_wall = NULL;
 static const char *arg_kill_who = NULL;
 static const char *arg_kill_mode = NULL;
@@ -347,9 +348,12 @@ static int compare_unit_info(const void *a, const void *b) {
         return strcasecmp(u->id, v->id);
 }
 
-static bool output_show_job(const struct unit_info *u) {
+static bool output_show_unit(const struct unit_info *u) {
         const char *dot;
 
+        if (arg_failed)
+                return streq(u->active_state, "failed");
+
         return (!arg_type || ((dot = strrchr(u->id, '.')) &&
                               streq(dot+1, arg_type))) &&
                 (arg_all || !(streq(u->active_state, "inactive") || u->following[0]) || u->job_id > 0);
@@ -364,7 +368,7 @@ static void output_units_list(const struct unit_info *unit_infos, unsigned c) {
         job_len = sizeof("JOB")-1;
 
         for (u = unit_infos; u < unit_infos + c; u++) {
-                if (!output_show_job(u))
+                if (!output_show_unit(u))
                         continue;
 
                 active_len = MAX(active_len, strlen(u->active_state));
@@ -388,7 +392,7 @@ static void output_units_list(const struct unit_info *unit_infos, unsigned c) {
                 const char *on_loaded, *off_loaded;
                 const char *on_active, *off_active;
 
-                if (!output_show_job(u))
+                if (!output_show_unit(u))
                         continue;
 
                 n_shown++;
@@ -4190,6 +4194,7 @@ static int systemctl_help(void) {
                "  -t --type=TYPE      List only units of a particular type\n"
                "  -p --property=NAME  Show only properties by this name\n"
                "  -a --all            Show all units/properties, including dead/empty ones\n"
+               "     --failed         Show only failed units\n"
                "     --full           Don't ellipsize unit names on output\n"
                "     --fail           When queueing a new job, fail if conflicting jobs are\n"
                "                      pending\n"
@@ -4344,7 +4349,8 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
                 ARG_DEFAULTS,
                 ARG_KILL_MODE,
                 ARG_KILL_WHO,
-                ARG_NO_ASK_PASSWORD
+                ARG_NO_ASK_PASSWORD,
+                ARG_FAILED
         };
 
         static const struct option options[] = {
@@ -4353,6 +4359,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
                 { "type",      required_argument, NULL, 't'           },
                 { "property",  required_argument, NULL, 'p'           },
                 { "all",       no_argument,       NULL, 'a'           },
+                { "failed",    no_argument,       NULL, ARG_FAILED    },
                 { "full",      no_argument,       NULL, ARG_FULL      },
                 { "fail",      no_argument,       NULL, ARG_FAIL      },
                 { "user",      no_argument,       NULL, ARG_USER      },
@@ -4456,6 +4463,10 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
                         arg_full = true;
                         break;
 
+                case ARG_FAILED:
+                        arg_failed = true;
+                        break;
+
                 case 'q':
                         arg_quiet = true;
                         break;