On Fri, 17.05.13 12:09, m.were...@partner.samsung.com (m.were...@partner.samsung.com) wrote:
> From: Maciej Wereski <m.were...@partner.samsung.com> > > This allows to show only units with specified SUB or ACTIVE state. Sounds like a worthwile addition. Sorry for the way too late review. But in cse you are still interested: We already support filtering for load states via --type= which is overloaded for both load states and unit types. I think it would probably be nicer to have --type= as you suggest, and then overload it with load state, active state, and sub state. These three namespaces are closer to each other so that we can avoid clashes easier. > +static const char *arg_state = NULL; > +static const char *const failed_str = "failed"; You can just use "failed" insted of failed_str where you need it, no need to define this. > static enum action { > ACTION_INVALID, > ACTION_SYSTEMCTL, > @@ -300,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 (arg_state != NULL) > + return (streq(u->sub_state, arg_state) || > - streq(u->active_state, arg_state)); No need for the surrounding parenthesis. > > return (!arg_types || ((dot = strrchr(u->id, '.')) && > strv_find(arg_types, dot+1))) && > @@ -4503,7 +4504,7 @@ static int systemctl_help(void) { > " ones. To list all units installed on > the system, use\n" > " the 'list-unit-files' command > instead.\n" > " --reverse Show reverse dependencies with > 'list-dependencies'\n" > - " --failed Show only failed units\n" > + " --failed Show only failed units (the same as > --state=failed)\n" > " --full Don't ellipsize unit names on output\n" > " --fail When queueing a new job, fail if > conflicting jobs are\n" > " pending\n" > @@ -4536,7 +4537,8 @@ static int systemctl_help(void) { > " --runtime Enable unit files only temporarily > until next reboot\n" > " -n --lines=INTEGER Journal entries to show\n" > " -o --output=STRING Change journal output mode (short, > short-monotonic,\n" > - " verbose, export, json, json-pretty, > json-sse, cat)\n\n" > + " verbose, export, json, json-pretty, > json-sse, cat)\n" > + " --state=STATE Show only units with particular > sub or active state\n\n" Please move this up to the other filter switches like --type=. I'd really like to see support for passing multiple states at once, the same way as we support filtering for multiple types at once. Lennart -- Lennart Poettering - Red Hat, Inc. _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel