diff options
author | Steven Rostedt (Google) <rostedt@goodmis.org> | 2022-02-01 21:30:48 -0500 |
---|---|---|
committer | Steven Rostedt (Google) <rostedt@goodmis.org> | 2022-02-01 21:30:48 -0500 |
commit | ba30db9e3c3929a05cdb5f4aae657f5fd979cec3 (patch) | |
tree | 1a4e1aa9926777fe95cdc14cd63403ea56b5aae1 | |
parent | 7705add9aef2c188f8dd0f896402833a12812d33 (diff) | |
download | ktrace-ba30db9e3c3929a05cdb5f4aae657f5fd979cec3.tar.gz |
ktrace: Add 'all' and systems to enable and disable of events
All the user to enter 'all' or a particular system to enable all events or
a group of events respectively.
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
-rw-r--r-- | src/enable.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/enable.c b/src/enable.c index c17909e..f588f1a 100644 --- a/src/enable.c +++ b/src/enable.c @@ -34,7 +34,32 @@ static char *get_event(struct ccli *ccli, void *data, char *ename) { struct tep_handle *tep = data; struct tep_event *event; + char *file; char *sav; + int ret; + + if (strcmp(ename, "all") == 0) + return tracefs_instance_get_file(NULL, "events/enable"); + + sav = strchr(ename, '/'); + + /* Get the systme if no '/' or nothing after it */ + if (!sav || !sav[1]) { + if (sav) + *sav = '\0'; + ret = asprintf(&sav, "events/%s/enable", ename); + if (ret < 0) + return NULL; + printf("sav='%s'\n", sav); + if (!tracefs_file_exists(NULL, sav)) { + free(sav); + ccli_printf(ccli, "# System '%s' not found\n", ename); + return NULL; + } + file = tracefs_instance_get_file(NULL, sav); + free(sav); + return file; + } sav = strdup(ename); /* Failure above will just print "(nul)" below */ @@ -129,12 +154,18 @@ static int disenable_event_completion(struct ccli *ccli, void *data, int cnt = 0; int ret = 0; - if (word == 0) + if (word == 0) { + ret = ccli_list_add(ccli, list, &cnt, "all"); + /* Do not add '/' for 'all' */ + if (ret == 1 && strcmp(match, "all") == 0) + return 1; ret = event_completion(ccli, tep, list, &cnt, match, 0); + } if (ret < 0) ccli_list_free(ccli, list, cnt); - return 0; + + return ret; } int enable_completion(struct ccli *ccli, const char *command, |