[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1310370416-6322-4-git-send-email-jim.cromie@gmail.com>
Date: Mon, 11 Jul 2011 01:46:38 -0600
From: Jim Cromie <jim.cromie@...il.com>
To: jbaron@...hat.com
Cc: linux-kernel@...r.kernel.org, bvanassche@....org, joe@...ches.com,
gregkh@...e.de, gnb@...h.org, Jim Cromie <jim.cromie@...il.com>
Subject: [PATCH 03/21] dynamic_debug: process multiple commands on a line
Process multiple commands per line, separated by ';'. All commands are
processed, independent of errors, allowing individual commands to fail,
for example when a module is not installed. Last error code is returned.
With this, extensive command sets can be given on the boot-line.
Signed-off-by: Jim Cromie <jim.cromie@...il.com>
---
lib/dynamic_debug.c | 30 ++++++++++++++++++++++++++++--
1 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 1597d5a..ae72402 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -423,6 +423,32 @@ static int ddebug_exec_query(char *query_string)
return 0;
}
+/* handle multiple queries, continue on error, return last error */
+static int ddebug_exec_queries(char *query)
+{
+ char *split;
+ int i, errs = 0, exitcode = 0, rc;
+
+ for (i = 0; query; query = split, i++) {
+ split = strchr(query, ';');
+ if (split)
+ *split++ = '\0';
+
+ if (verbose)
+ pr_info("query %d: \"%s\"\n", i, query);
+
+ rc = ddebug_exec_query(query);
+ if (rc) {
+ errs++;
+ exitcode = rc;
+ }
+ }
+ if (verbose)
+ pr_info("processed %d queries, with %d errs\n", i, errs);
+
+ return exitcode;
+}
+
static int dynamic_emit_prefix(const struct _ddebug *descriptor)
{
char tid[sizeof(int) + sizeof(int)/2 + 4];
@@ -557,7 +583,7 @@ static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf,
if (verbose)
pr_info("read %d bytes from userspace\n", (int)len);
- ret = ddebug_exec_query(tmpbuf);
+ ret = ddebug_exec_queries(tmpbuf);
if (ret)
return ret;
@@ -862,7 +888,7 @@ static int __init dynamic_debug_init(void)
/* ddebug_query boot param got passed -> set it up */
if (ddebug_setup_string[0] != '\0') {
- ret = ddebug_exec_query(ddebug_setup_string);
+ ret = ddebug_exec_queries(ddebug_setup_string);
if (ret)
pr_warn("Invalid ddebug boot param %s",
ddebug_setup_string);
--
1.7.4.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists