aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib/api/fs/fs.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-06-12 22:18:49 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-12 22:18:49 -0400
commit3737a12761636ebde0f09ef49daebb8eed18cc8a (patch)
tree965057f4bccd97049f8c0140f8670c5d4278ca3e /tools/lib/api/fs/fs.c
parentc29deef32e3699e40da3e9e82267610de04e6b54 (diff)
parent82b897782d10fcc4930c9d4a15b175348fdd2871 (diff)
Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull more perf updates from Ingo Molnar: "A second round of perf updates: - wide reaching kprobes sanitization and robustization, with the hope of fixing all 'probe this function crashes the kernel' bugs, by Masami Hiramatsu. - uprobes updates from Oleg Nesterov: tmpfs support, corner case fixes and robustization work. - perf tooling updates and fixes from Jiri Olsa, Namhyung Ki, Arnaldo et al: * Add support to accumulate hist periods (Namhyung Kim) * various fixes, refactorings and enhancements" * 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (101 commits) perf: Differentiate exec() and non-exec() comm events perf: Fix perf_event_comm() vs. exec() assumption uprobes/x86: Rename arch_uprobe->def to ->defparam, minor comment updates perf/documentation: Add description for conditional branch filter perf/x86: Add conditional branch filtering support perf/tool: Add conditional branch filter 'cond' to perf record perf: Add new conditional branch filter 'PERF_SAMPLE_BRANCH_COND' uprobes: Teach copy_insn() to support tmpfs uprobes: Shift ->readpage check from __copy_insn() to uprobe_register() perf/x86: Use common PMU interrupt disabled code perf/ARM: Use common PMU interrupt disabled code perf: Disable sampled events if no PMU interrupt perf: Fix use after free in perf_remove_from_context() perf tools: Fix 'make help' message error perf record: Fix poll return value propagation perf tools: Move elide bool into perf_hpp_fmt struct perf tools: Remove elide setup for SORT_MODE__MEMORY mode perf tools: Fix "==" into "=" in ui_browser__warning assignment perf tools: Allow overriding sysfs and proc finding with env var perf tools: Consider header files outside perf directory in tags target ...
Diffstat (limited to 'tools/lib/api/fs/fs.c')
-rw-r--r--tools/lib/api/fs/fs.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 5b5eb788996e..c1b49c36a951 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -1,8 +1,10 @@
1/* TODO merge/factor in debugfs.c here */ 1/* TODO merge/factor in debugfs.c here */
2 2
3#include <ctype.h>
3#include <errno.h> 4#include <errno.h>
4#include <stdbool.h> 5#include <stdbool.h>
5#include <stdio.h> 6#include <stdio.h>
7#include <stdlib.h>
6#include <string.h> 8#include <string.h>
7#include <sys/vfs.h> 9#include <sys/vfs.h>
8 10
@@ -96,12 +98,51 @@ static bool fs__check_mounts(struct fs *fs)
96 return false; 98 return false;
97} 99}
98 100
101static void mem_toupper(char *f, size_t len)
102{
103 while (len) {
104 *f = toupper(*f);
105 f++;
106 len--;
107 }
108}
109
110/*
111 * Check for "NAME_PATH" environment variable to override fs location (for
112 * testing). This matches the recommendation in Documentation/sysfs-rules.txt
113 * for SYSFS_PATH.
114 */
115static bool fs__env_override(struct fs *fs)
116{
117 char *override_path;
118 size_t name_len = strlen(fs->name);
119 /* name + "_PATH" + '\0' */
120 char upper_name[name_len + 5 + 1];
121 memcpy(upper_name, fs->name, name_len);
122 mem_toupper(upper_name, name_len);
123 strcpy(&upper_name[name_len], "_PATH");
124
125 override_path = getenv(upper_name);
126 if (!override_path)
127 return false;
128
129 fs->found = true;
130 strncpy(fs->path, override_path, sizeof(fs->path));
131 return true;
132}
133
99static const char *fs__get_mountpoint(struct fs *fs) 134static const char *fs__get_mountpoint(struct fs *fs)
100{ 135{
136 if (fs__env_override(fs))
137 return fs->path;
138
101 if (fs__check_mounts(fs)) 139 if (fs__check_mounts(fs))
102 return fs->path; 140 return fs->path;
103 141
104 return fs__read_mounts(fs) ? fs->path : NULL; 142 if (fs__read_mounts(fs))
143 return fs->path;
144
145 return NULL;
105} 146}
106 147
107static const char *fs__mountpoint(int idx) 148static const char *fs__mountpoint(int idx)