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>
This commit is contained in:
Clark Williams
2009-11-08 09:03:07 -06:00
committed by Ingo Molnar
parent afe61f6778
commit 549104f22b
2 changed files with 10 additions and 51 deletions

View File

@@ -14,6 +14,7 @@
#include "util/run-command.h"
#include "util/parse-events.h"
#include "util/string.h"
#include "util/debugfs.h"
const char perf_usage_string[] =
"perf [--version] [--help] COMMAND [ARGS]";
@@ -382,45 +383,12 @@ static int run_argv(int *argcp, const char ***argv)
/* mini /proc/mounts parser: searching for "^blah /mount/point debugfs" */
static void get_debugfs_mntpt(void)
{
FILE *file;
char fs_type[100];
char debugfs[MAXPATHLEN];
const char *path = debugfs_find_mountpoint();
/*
* try the standard location
*/
if (valid_debugfs_mount("/sys/kernel/debug/") == 0) {
strcpy(debugfs_mntpt, "/sys/kernel/debug/");
return;
}
/*
* try the sane location
*/
if (valid_debugfs_mount("/debug/") == 0) {
strcpy(debugfs_mntpt, "/debug/");
return;
}
/*
* give up and parse /proc/mounts
*/
file = fopen("/proc/mounts", "r");
if (file == NULL)
return;
while (fscanf(file, "%*s %"
STR(MAXPATHLEN)
"s %99s %*s %*d %*d\n",
debugfs, fs_type) == 2) {
if (strcmp(fs_type, "debugfs") == 0)
break;
}
fclose(file);
if (strcmp(fs_type, "debugfs") == 0) {
strncpy(debugfs_mntpt, debugfs, MAXPATHLEN);
debugfs_mntpt[MAXPATHLEN - 1] = '\0';
}
if (path)
strncpy(debugfs_mntpt, path, sizeof(debugfs_mntpt));
else
debugfs_mntpt[0] = '\0';
}
int main(int argc, const char **argv)