This allows to show only units with specified LOAD or SUB or ACTIVE state.
Signed-off-by: Maciej Wereski m.were...@partner.samsung.com
---
changes since v4:
* removed help information about deprecated behaviour
Sorry, that I've forgot about this in previous patch!
regards,
Maciej
---
man/systemctl.xml | 29 -
src/systemctl/systemctl.c | 40 +++-
2 files changed, 39 insertions(+), 30 deletions(-)
diff --git a/man/systemctl.xml b/man/systemctl.xml
index f550215..9820517 100644
--- a/man/systemctl.xml
+++ b/man/systemctl.xml
@@ -94,19 +94,13 @@ along with systemd; If not, see
http://www.gnu.org/licenses/.
listitem
paraThe argument should be a comma-separated list of unit
types such as optionservice/option and
- optionsocket/option, or unit load states such as
- optionloaded/option and optionmasked/option
- (types and states can be mixed)./para
+ optionsocket/option.
+ /para
paraIf one of the arguments is a unit type, when listing
units, limit display to certain unit types. Otherwise, units
of all types will be shown./para
- paraIf one of the arguments is a unit load state, when
- listing units, limit display to certain unit
- types. Otherwise, units of in all load states will be
- shown./para
-
paraAs a special case, if one of the arguments is
optionhelp/option, a list of allowed values will be
printed and the program will exit./para
@@ -114,6 +108,16 @@ along with systemd; If not, see
http://www.gnu.org/licenses/.
/varlistentry
varlistentry
+termoption--state=/option/term
+
+listitem
+paraArgument should be a comma-separated list of unit LOAD
+or SUB or ACTIVE states. When listing units show only those
+with specified LOAD or SUB or ACTIVE state./para
+/listitem
+ /varlistentry
+
+ varlistentry
termoption-p/option/term
termoption--property=/option/term
@@ -166,15 +170,6 @@ along with systemd; If not, see
http://www.gnu.org/licenses/.
/varlistentry
varlistentry
-termoption--failed/option/term
-
-listitem
- paraWhen listing units, show only failed units. Do not
- confuse with option--fail/option./para
-/listitem
- /varlistentry
-
- varlistentry
termoption-l/option/term
termoption--full/option/term
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index b3b679e..c15d099 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -93,13 +93,13 @@ static bool arg_quiet = false;
static bool arg_full = false;
static int arg_force = 0;
static bool arg_ask_password = true;
-static bool arg_failed = false;
static bool arg_runtime = false;
static char **arg_wall = NULL;
static const char *arg_kill_who = NULL;
static int arg_signal = SIGTERM;
static const char *arg_root = NULL;
static usec_t arg_when = 0;
+static char **arg_state = NULL;
static enum action {
ACTION_INVALID,
ACTION_SYSTEMCTL,
@@ -301,8 +301,8 @@ static int compare_unit_info(const void *a, const void *b) {
static bool output_show_unit(const struct unit_info *u) {
const char *dot;
-if (arg_failed)
-return streq(u-active_state, failed);
+if (!strv_isempty(arg_state))
+return strv_contains(arg_state, u-load_state) ||
strv_contains(arg_state, u-sub_state) || strv_contains(arg_state,
u-active_state);
return (!arg_types || ((dot = strrchr(u-id, '.'))
strv_find(arg_types, dot+1)))
@@ -4705,12 +4705,12 @@ static int systemctl_help(void) {
-h --help Show this help\n
--versionShow package version\n
-t --type=TYPE List only units of a particular type\n
+--state=STATEShow only units with particular LOAD or
SUB or ACTIVE state\n
-p --property=NAME Show only properties by this name\n
-a --allShow all loaded units/properties,
including dead/empty\n
ones. To list all units installed on the
system, use\n
the 'list-unit-files' command instead.\n
--reverseShow reverse dependencies with
'list-dependencies'\n
---failed Show only failed units\n
-l --full Don't ellipsize unit names on output\n
--fail When queueing a new job, fail if
conflicting jobs are\n
pending\n
@@ -4896,13 +4896,6 @@ static int help_types(void) {
puts(t);
}
-puts(\nAvailable unit load