summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
0b6d6ef)
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@cn.fujitsu.com>
git-svn-id: http://ltt.polymtl.ca/svn@3115
04897980-b3bd-0310-b5e0-
8ef037075253
#include <signal.h>
#include <dirent.h>
#include <string.h>
#include <signal.h>
#include <dirent.h>
#include <string.h>
#include <sys/stat.h>
/* Buffer for file copy : 4k seems optimal. */
#include <sys/stat.h>
/* Buffer for file copy : 4k seems optimal. */
static enum trace_mode mode = LTT_TRACE_NORMAL;
static enum trace_ctl_op op = CTL_OP_NONE;
static char *channel_root = NULL;
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";
static char *trace_root = NULL;
static char *num_threads = "1";
+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;
+ }
+ }
+}
ret = EINVAL;
}
if(channel_root == NULL) {
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;
+ }