mirror of
https://github.com/troglobit/finit.git
synced 2026-12-05 22:08:20 +00:00
initctl: add optional TYPE argument to 'cond dump' command
Allow filtering of conditions in raw dump, i.e., the possibility to show only conditions of a certain type. The TYPE argument is not validated in any way, so any prefix match is allowed, e.g. initctl cond dump service/s Shows all conditions for services starting with 's'. Fixes issue #272 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
4a8ca787d3
commit
6286ede985
3 files changed
+10
-4
No files matched your search
@@ -464,7 +464,7 @@ Commands:
|
|||||||
cond get <COND> Get status of user-defined condition, see $? and -v
|
cond get <COND> Get status of user-defined condition, see $? and -v
|
||||||
cond clear <COND> Clear (deassert) user-defined condition -usr/COND
|
cond clear <COND> Clear (deassert) user-defined condition -usr/COND
|
||||||
cond status Show condition status, default cond command
|
cond status Show condition status, default cond command
|
||||||
cond dump Dump all conditions and their status
|
cond dump [TYPE] Dump all, or a type of, conditions and their status
|
||||||
|
|
||||||
log [NAME] Show ten last Finit, or NAME, messages from syslog
|
log [NAME] Show ten last Finit, or NAME, messages from syslog
|
||||||
start <NAME>[:ID] Start service by name, with optional ID
|
start <NAME>[:ID] Start service by name, with optional ID
|
||||||
|
|||||||
+2
-2
@@ -145,8 +145,8 @@ Clear (deassert) user-defined condition,
|
|||||||
Show condition status, default
|
Show condition status, default
|
||||||
.Cm cond
|
.Cm cond
|
||||||
command.
|
command.
|
||||||
.It Nm Ar cond dump
|
.It Nm Ar cond dump Op Cm TYPE
|
||||||
Dump all conditions and their status
|
Dump all, or a given type of, conditions and their status
|
||||||
.It Nm Ar ident Op Cm NAME
|
.It Nm Ar ident Op Cm NAME
|
||||||
Display indentities of all run/task/services, or only instances
|
Display indentities of all run/task/services, or only instances
|
||||||
matching
|
matching
|
||||||
|
|||||||
+7
-1
@@ -320,6 +320,7 @@ int do_signal(int argc, char *argv[])
|
|||||||
return client_send(&rq, sizeof(rq));
|
return client_send(&rq, sizeof(rq));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *dump_filter;
|
||||||
static int dump_one_cond(const char *fpath, const struct stat *sb, int tflag, struct FTW *ftwbuf)
|
static int dump_one_cond(const char *fpath, const struct stat *sb, int tflag, struct FTW *ftwbuf)
|
||||||
{
|
{
|
||||||
const char *cond, *asserted;
|
const char *cond, *asserted;
|
||||||
@@ -334,6 +335,10 @@ static int dump_one_cond(const char *fpath, const struct stat *sb, int tflag, st
|
|||||||
|
|
||||||
asserted = condstr(cond_get_path(fpath));
|
asserted = condstr(cond_get_path(fpath));
|
||||||
cond = &fpath[strlen(_PATH_COND)];
|
cond = &fpath[strlen(_PATH_COND)];
|
||||||
|
|
||||||
|
if (dump_filter && dump_filter[0] && strncmp(cond, dump_filter, strlen(dump_filter)))
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (strncmp("pid/", cond, 4) == 0) {
|
if (strncmp("pid/", cond, 4) == 0) {
|
||||||
svc_t *svc;
|
svc_t *svc;
|
||||||
|
|
||||||
@@ -365,6 +370,7 @@ static int do_cond_dump(char *arg)
|
|||||||
print_header("%-*s %-*s %-6s %s", pw, "PID", iw, "IDENT",
|
print_header("%-*s %-*s %-6s %s", pw, "PID", iw, "IDENT",
|
||||||
"STATUS", "CONDITION");
|
"STATUS", "CONDITION");
|
||||||
|
|
||||||
|
dump_filter = arg;
|
||||||
if (nftw(_PATH_COND, dump_one_cond, 20, 0) == -1) {
|
if (nftw(_PATH_COND, dump_one_cond, 20, 0) == -1) {
|
||||||
WARNX("Failed parsing %s", _PATH_COND);
|
WARNX("Failed parsing %s", _PATH_COND);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -1004,7 +1010,7 @@ static int usage(int rc)
|
|||||||
" cond get <COND> Get status of user-defined condition, see $? and -v\n"
|
" cond get <COND> Get status of user-defined condition, see $? and -v\n"
|
||||||
" cond clear <COND> Clear (deassert) user-defined condition -usr/COND\n"
|
" cond clear <COND> Clear (deassert) user-defined condition -usr/COND\n"
|
||||||
" cond status Show condition status, default cond command\n"
|
" cond status Show condition status, default cond command\n"
|
||||||
" cond dump Dump all conditions and their status\n"
|
" cond dump [TYPE] Dump all, or a type of, conditions and their status\n"
|
||||||
"\n"
|
"\n"
|
||||||
" log [NAME] Show ten last Finit, or NAME, messages from syslog\n"
|
" log [NAME] Show ten last Finit, or NAME, messages from syslog\n"
|
||||||
" start <NAME>[:ID] Start service by name, with optional ID\n"
|
" start <NAME>[:ID] Start service by name, with optional ID\n"
|
||||||
|
|||||||
Reference in new issue
Block a user