From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 98FDB13832E for ; Mon, 18 Jul 2016 19:12:39 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id AFB8FE09AF; Mon, 18 Jul 2016 19:12:38 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 3A240E09AF for ; Mon, 18 Jul 2016 19:12:38 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 5EB2F340928 for ; Mon, 18 Jul 2016 19:12:36 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3C1F9E6B for ; Mon, 18 Jul 2016 19:12:04 +0000 (UTC) From: "William Hubbs" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" Message-ID: <1468866056.695be59083cdf0d2ff9296f2c210e591c51bdf40.williamh@OpenRC> Subject: [gentoo-commits] proj/openrc:master commit in: src/rc/, man/ X-VCS-Repository: proj/openrc X-VCS-Files: man/rc-status.8 src/rc/rc-status.c X-VCS-Directories: man/ src/rc/ X-VCS-Committer: williamh X-VCS-Committer-Name: William Hubbs X-VCS-Revision: 695be59083cdf0d2ff9296f2c210e591c51bdf40 X-VCS-Branch: master Date: Mon, 18 Jul 2016 19:12:04 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 8dec53d9-971d-41fb-8112-33752a59f9bd X-Archives-Hash: 737d2529fdf7107217ee02807178e961 commit: 695be59083cdf0d2ff9296f2c210e591c51bdf40 Author: William Hubbs gmail com> AuthorDate: Fri Jul 15 16:37:54 2016 +0000 Commit: William Hubbs gentoo org> CommitDate: Mon Jul 18 18:20:56 2016 +0000 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=695be590 rc-status: add -m/--manual option to show manually started services X-Gentoo-Bug: 585906 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=585906 man/rc-status.8 | 2 ++ src/rc/rc-status.c | 27 +++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/man/rc-status.8 b/man/rc-status.8 index 05d6eee..3b33df4 100644 --- a/man/rc-status.8 +++ b/man/rc-status.8 @@ -33,6 +33,8 @@ Show all runlevels and their services. List all services that have crashed. .It Fl l , -list List all defined runlevels. +.It Fl m , -manual +Show all manually started services. .It Fl r , -runlevel Print the current runlevel name. .It Fl s , -servicelist diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c index 6724db8..8a591db 100644 --- a/src/rc/rc-status.c +++ b/src/rc/rc-status.c @@ -29,11 +29,12 @@ const char *applet = NULL; const char *extraopts = NULL; -const char *getoptstring = "aclrsu" getoptstring_COMMON; +const char *getoptstring = "aclmrsu" getoptstring_COMMON; const struct option longopts[] = { {"all", 0, NULL, 'a'}, {"crashed", 0, NULL, 'c'}, {"list", 0, NULL, 'l'}, + {"manual", 0, NULL, 'm'}, {"runlevel", 0, NULL, 'r'}, {"servicelist", 0, NULL, 's'}, {"unused", 0, NULL, 'u'}, @@ -43,6 +44,7 @@ const char * const longopts_help[] = { "Show services from all run levels", "Show crashed services", "Show list of run levels", + "Show manually started services", "Show the name of the current runlevel", "Show service list", "Show services not assigned to any runlevel", @@ -50,7 +52,7 @@ const char * const longopts_help[] = { }; const char *usagestring = "" \ "Usage: rc-status [options] ...\n" \ - " or: rc-status [options] [-a | -c | -l | -r | -s | -u]"; + " or: rc-status [options] [-a | -c | -l | -m | -r | -s | -u]"; static bool test_crashed = false; static RC_DEPTREE *deptree; @@ -205,6 +207,27 @@ int main(int argc, char **argv) TAILQ_FOREACH(l, levels, entries) printf("%s\n", l->value); goto exit; + case 'm': + services = rc_services_in_runlevel(NULL); + levels = rc_runlevel_list(); + TAILQ_FOREACH_SAFE(s, services, entries, t) { + TAILQ_FOREACH(l, levels, entries) + if (rc_service_in_runlevel(s->value, l->value)) { + TAILQ_REMOVE(services, s, entries); + free(s->value); + free(s); + break; + } + } + TAILQ_FOREACH_SAFE(s, services, entries, t) + if (rc_service_state(s->value) & + (RC_SERVICE_STOPPED | RC_SERVICE_HOTPLUGGED)) { + TAILQ_REMOVE(services, s, entries); + free(s->value); + free(s); + } + print_services(NULL, services); + goto exit; case 'r': runlevel = rc_runlevel_get(); printf("%s\n", runlevel);