X-Git-Url: http://git.liburcu.org/?p=ltt-control.git;a=blobdiff_plain;f=trunk%2Fltt-control%2Flttctl%2Flttctl.c;h=c04d4f5ca10d9569eb42eea98b7c5029a39fc605;hp=46dc2895505e4d1f0bd8b79433ca23abbb22dcb8;hb=a9c10be29dd6c32478e6383e43c5b8fd6c4b762c;hpb=0b6d6ef0d8bc47c41ecc5990587304ce161371b0 diff --git a/trunk/ltt-control/lttctl/lttctl.c b/trunk/ltt-control/lttctl/lttctl.c index 46dc289..c04d4f5 100644 --- a/trunk/ltt-control/lttctl/lttctl.c +++ b/trunk/ltt-control/lttctl/lttctl.c @@ -22,6 +22,7 @@ #include #include #include +#include #include /* Buffer for file copy : 4k seems optimal. */ @@ -52,6 +53,7 @@ static unsigned append_trace = 0; 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 @@ void show_arguments(void) 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 @@ int parse_arguments(int argc, char **argv) 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; + } } }