diff options
author | Clark Williams <williams@redhat.com> | 2009-11-08 10:03:07 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-11-08 12:01:35 -0500 |
commit | 549104f22b3cd4761145eb5fba6ee4d59822da61 (patch) | |
tree | 2966d464ffe82e391fad654d8e91ecf7a40f4367 /tools/perf/perf.c | |
parent | afe61f677866ffc484e69c4ecca2d316d564d78b (diff) |
perf tools: Modify perf routines to use new debugfs routines
modify perf.c get_debugfs_mntpnt() to use the util/debugfs.c
debugfs_find_mountpoint()
modify util/parse-events.c to use debugfs_valid_mountpoint().
Signed-off-by: Clark Williams <williams@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
LKML-Reference: <20091101155720.624cc87e@torg>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/perf.c')
-rw-r--r-- | tools/perf/perf.c | 44 |
1 files changed, 6 insertions, 38 deletions
diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 624e62d9d1e0..601f403fbdac 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include "util/run-command.h" | 14 | #include "util/run-command.h" |
15 | #include "util/parse-events.h" | 15 | #include "util/parse-events.h" |
16 | #include "util/string.h" | 16 | #include "util/string.h" |
17 | #include "util/debugfs.h" | ||
17 | 18 | ||
18 | const char perf_usage_string[] = | 19 | const char perf_usage_string[] = |
19 | "perf [--version] [--help] COMMAND [ARGS]"; | 20 | "perf [--version] [--help] COMMAND [ARGS]"; |
@@ -382,45 +383,12 @@ static int run_argv(int *argcp, const char ***argv) | |||
382 | /* mini /proc/mounts parser: searching for "^blah /mount/point debugfs" */ | 383 | /* mini /proc/mounts parser: searching for "^blah /mount/point debugfs" */ |
383 | static void get_debugfs_mntpt(void) | 384 | static void get_debugfs_mntpt(void) |
384 | { | 385 | { |
385 | FILE *file; | 386 | const char *path = debugfs_find_mountpoint(); |
386 | char fs_type[100]; | ||
387 | char debugfs[MAXPATHLEN]; | ||
388 | 387 | ||
389 | /* | 388 | if (path) |
390 | * try the standard location | 389 | strncpy(debugfs_mntpt, path, sizeof(debugfs_mntpt)); |
391 | */ | 390 | else |
392 | if (valid_debugfs_mount("/sys/kernel/debug/") == 0) { | 391 | debugfs_mntpt[0] = '\0'; |
393 | strcpy(debugfs_mntpt, "/sys/kernel/debug/"); | ||
394 | return; | ||
395 | } | ||
396 | |||
397 | /* | ||
398 | * try the sane location | ||
399 | */ | ||
400 | if (valid_debugfs_mount("/debug/") == 0) { | ||
401 | strcpy(debugfs_mntpt, "/debug/"); | ||
402 | return; | ||
403 | } | ||
404 | |||
405 | /* | ||
406 | * give up and parse /proc/mounts | ||
407 | */ | ||
408 | file = fopen("/proc/mounts", "r"); | ||
409 | if (file == NULL) | ||
410 | return; | ||
411 | |||
412 | while (fscanf(file, "%*s %" | ||
413 | STR(MAXPATHLEN) | ||
414 | "s %99s %*s %*d %*d\n", | ||
415 | debugfs, fs_type) == 2) { | ||
416 | if (strcmp(fs_type, "debugfs") == 0) | ||
417 | break; | ||
418 | } | ||
419 | fclose(file); | ||
420 | if (strcmp(fs_type, "debugfs") == 0) { | ||
421 | strncpy(debugfs_mntpt, debugfs, MAXPATHLEN); | ||
422 | debugfs_mntpt[MAXPATHLEN - 1] = '\0'; | ||
423 | } | ||
424 | } | 392 | } |
425 | 393 | ||
426 | int main(int argc, const char **argv) | 394 | int main(int argc, const char **argv) |