* [ltt-dev] [PATCH] make lttctl select channel_root in debugfs automatically
@ 2008-10-16 4:08 Zhaolei
2008-10-16 7:46 ` [ltt-dev] [PATCH] Make ltt_trace_start return error when trace_name not exist Zhaolei
0 siblings, 1 reply; 2+ messages in thread
From: Zhaolei @ 2008-10-16 4:08 UTC (permalink / raw)
Hi Mathieu,
this patch make lttctl select channel_root in debugfs automatically
when no specify.
Applies on top of ltt-control-0.54-10102008.
Signed-off-by: Zhaolei <zhaolei at cn.fujitsu.com>
---
diff -Nur ltt-control-0.54-10102008.org/lttctl/lttctl.c ltt-control-0.54-10102008/lttctl/lttctl.c
--- ltt-control-0.54-10102008.org/lttctl/lttctl.c 2008-10-15 15:29:54.000000000 +0800
+++ ltt-control-0.54-10102008/lttctl/lttctl.c 2008-10-16 11:53:49.000000000 +0800
@@ -22,6 +22,7 @@
#include <signal.h>
#include <dirent.h>
#include <string.h>
+#include <limits.h>
#include <sys/stat.h>
/* Buffer for file copy : 4k seems optimal. */
@@ -52,6 +53,7 @@
static enum trace_mode mode = LTT_TRACE_NORMAL;
static enum trace_ctl_op op = CTL_OP_NONE;
static char *channel_root = NULL;
+static char channel_root_default[PATH_MAX];
static char *trace_root = NULL;
static char *num_threads = "1";
@@ -92,6 +94,26 @@
printf("\n");
}
+int getdebugfsmntdir(char *mntdir)
+{
+ char mnt_dir[PATH_MAX];
+ char mnt_type[PATH_MAX];
+
+ FILE *fp = fopen("/proc/mounts", "r");
+ if (!fp) {
+ return EINVAL;
+ }
+
+ while (1) {
+ if (fscanf(fp, "%*s %s %s %*s %*s %*s", mnt_dir, mnt_type) <= 0) {
+ return ENOENT;
+ }
+ if (!strcmp(mnt_type, "debugfs")) {
+ strcpy(mntdir, mnt_dir);
+ return 0;
+ }
+ }
+}
/* parse_arguments
*
@@ -304,9 +326,16 @@
ret = EINVAL;
}
if(channel_root == NULL) {
- printf("Please specify -l ltt_root_path with the -d option.\n");
- printf("\n");
- ret = EINVAL;
+ if (getdebugfsmntdir(channel_root_default) == 0) {
+ strcat(channel_root_default, "/ltt");
+ printf("No -l ltt_root_path with the -d option, using default: %s\n", channel_root_default);
+ printf("\n");
+ channel_root=channel_root_default;
+ } else {
+ printf("Please specify -l ltt_root_path with the -d option.\n");
+ printf("\n");
+ ret = EINVAL;
+ }
}
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* [ltt-dev] [PATCH] Make ltt_trace_start return error when trace_name not exist
2008-10-16 4:08 [ltt-dev] [PATCH] make lttctl select channel_root in debugfs automatically Zhaolei
@ 2008-10-16 7:46 ` Zhaolei
0 siblings, 0 replies; 2+ messages in thread
From: Zhaolei @ 2008-10-16 7:46 UTC (permalink / raw)
Hi Mathieu,
I find ltt_trace_start don't return error when trace_name is not exist.
So, when we use lttctl -s to start no-exist channel, it will not print
any errormsg:
# ls /mnt/debugfs/ltt/
# lttctl -n zltest -s
Linux Trace Toolkit Trace Control 0.54-10102008
Controlling trace : zltest
# ls /mnt/debugfs/ltt/
#
It can be fixed by following patch, I tested patched kernel with following command:
# ls /mnt/debugfs/ltt/
# lttctl -n zltest -s
Linux Trace Toolkit Trace Control 0.54-10102008
Controlling trace : zltest
Start Trace Error: No such file or directory
#
Signed-off-by: Zhaolei <zhaolei at cn.fujitsu.com>
---
ltt/ltt-tracer.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/ltt/ltt-tracer.c b/ltt/ltt-tracer.c
index 0d0423d..bc8251b 100644
--- a/ltt/ltt-tracer.c
+++ b/ltt/ltt-tracer.c
@@ -641,9 +641,10 @@ static int ltt_trace_start(char *trace_name)
ltt_lock_traces();
trace = _ltt_trace_find(trace_name);
- if (trace == NULL)
- goto no_trace;
err = _ltt_trace_start(trace);
+ if (err) {
+ goto no_trace;
+ }
ltt_unlock_traces();
--
1.5.5.3
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-10-16 7:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-16 4:08 [ltt-dev] [PATCH] make lttctl select channel_root in debugfs automatically Zhaolei
2008-10-16 7:46 ` [ltt-dev] [PATCH] Make ltt_trace_start return error when trace_name not exist Zhaolei
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox