Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 169577
b: refs/heads/master
c: 549104f
h: refs/heads/master
i:
  169575: 147b0b3
v: v3
  • Loading branch information
Clark Williams authored and Ingo Molnar committed Nov 8, 2009
1 parent 811dd3c commit 729e006
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 52 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: afe61f677866ffc484e69c4ecca2d316d564d78b
refs/heads/master: 549104f22b3cd4761145eb5fba6ee4d59822da61
44 changes: 6 additions & 38 deletions trunk/tools/perf/perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]";
Expand Down Expand Up @@ -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)
Expand Down
17 changes: 4 additions & 13 deletions trunk/tools/perf/util/parse-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "string.h"
#include "cache.h"
#include "header.h"
#include "debugfs.h"

int nr_counters;

Expand Down Expand Up @@ -149,16 +150,6 @@ static int tp_event_has_id(struct dirent *sys_dir, struct dirent *evt_dir)

#define MAX_EVENT_LENGTH 512

int valid_debugfs_mount(const char *debugfs)
{
struct statfs st_fs;

if (statfs(debugfs, &st_fs) < 0)
return -ENOENT;
else if (st_fs.f_type != (long) DEBUGFS_MAGIC)
return -ENOENT;
return 0;
}

struct tracepoint_path *tracepoint_id_to_path(u64 config)
{
Expand All @@ -171,7 +162,7 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config)
char evt_path[MAXPATHLEN];
char dir_path[MAXPATHLEN];

if (valid_debugfs_mount(debugfs_path))
if (debugfs_valid_mountpoint(debugfs_path))
return NULL;

sys_dir = opendir(debugfs_path);
Expand Down Expand Up @@ -510,7 +501,7 @@ static enum event_result parse_tracepoint_event(const char **strp,
char sys_name[MAX_EVENT_LENGTH];
unsigned int sys_length, evt_length;

if (valid_debugfs_mount(debugfs_path))
if (debugfs_valid_mountpoint(debugfs_path))
return 0;

evt_name = strchr(*strp, ':');
Expand Down Expand Up @@ -788,7 +779,7 @@ static void print_tracepoint_events(void)
char evt_path[MAXPATHLEN];
char dir_path[MAXPATHLEN];

if (valid_debugfs_mount(debugfs_path))
if (debugfs_valid_mountpoint(debugfs_path))
return;

sys_dir = opendir(debugfs_path);
Expand Down

0 comments on commit 729e006

Please sign in to comment.