diff options
| author | Steven Rostedt <srostedt@redhat.com> | 2010-02-02 20:56:12 -0500 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2010-02-02 20:56:12 -0500 |
| commit | 0c66746ba19704aef37cd233c60cd16e39a0ad2e (patch) | |
| tree | 99cf94151eca0c84e0411edd7cdbc4cae1039436 | |
| parent | 27cee48bc89693e42756296adda000ffcbc06611 (diff) | |
trace-cmd: Mount debugfs if it is not mounted
If debugfs is not mounted, then mount it for the user. When debugfs
is configured in the kernel the directory /sys/kernel/debug should
exist. Mount it there and make Greg KH happy.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
| -rw-r--r-- | trace-util.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/trace-util.c b/trace-util.c index 7d168f9..d6c1948 100644 --- a/trace-util.c +++ b/trace-util.c | |||
| @@ -6,12 +6,14 @@ | |||
| 6 | #include <ctype.h> | 6 | #include <ctype.h> |
| 7 | #include <errno.h> | 7 | #include <errno.h> |
| 8 | #include <dlfcn.h> | 8 | #include <dlfcn.h> |
| 9 | #include <sys/mount.h> | ||
| 9 | #include <sys/types.h> | 10 | #include <sys/types.h> |
| 10 | #include <sys/stat.h> | 11 | #include <sys/stat.h> |
| 11 | 12 | ||
| 12 | #include "trace-cmd.h" | 13 | #include "trace-cmd.h" |
| 13 | 14 | ||
| 14 | #define PLUGIN_DIR ".trace-cmd/plugins" | 15 | #define PLUGIN_DIR ".trace-cmd/plugins" |
| 16 | #define DEBUGFS_PATH "/sys/kernel/debug" | ||
| 15 | 17 | ||
| 16 | #define __weak __attribute__((weak)) | 18 | #define __weak __attribute__((weak)) |
| 17 | 19 | ||
| @@ -197,6 +199,22 @@ load_plugin(struct pevent *pevent, struct plugin_list *plugin_list, | |||
| 197 | return plugin_list; | 199 | return plugin_list; |
| 198 | } | 200 | } |
| 199 | 201 | ||
| 202 | static int mount_debugfs(void) | ||
| 203 | { | ||
| 204 | struct stat st; | ||
| 205 | int ret; | ||
| 206 | |||
| 207 | /* make sure debugfs exists */ | ||
| 208 | ret = stat(DEBUGFS_PATH, &st); | ||
| 209 | if (ret < 0) | ||
| 210 | die("debugfs is not configured on this kernel"); | ||
| 211 | |||
| 212 | ret = mount("nodev", DEBUGFS_PATH, | ||
| 213 | "debugfs", 0, NULL); | ||
| 214 | |||
| 215 | return ret; | ||
| 216 | } | ||
| 217 | |||
| 200 | char *tracecmd_find_tracing_dir(void) | 218 | char *tracecmd_find_tracing_dir(void) |
| 201 | { | 219 | { |
| 202 | char debugfs[MAX_PATH+1]; | 220 | char debugfs[MAX_PATH+1]; |
| @@ -219,8 +237,12 @@ char *tracecmd_find_tracing_dir(void) | |||
| 219 | fclose(fp); | 237 | fclose(fp); |
| 220 | 238 | ||
| 221 | if (strcmp(type, "debugfs") != 0) { | 239 | if (strcmp(type, "debugfs") != 0) { |
| 222 | warning("debugfs not mounted, please mount"); | 240 | /* If debugfs is not mounted, try to mount it */ |
| 223 | return NULL; | 241 | if (mount_debugfs() < 0) { |
| 242 | warning("debugfs not mounted, please mount"); | ||
| 243 | return NULL; | ||
| 244 | } | ||
| 245 | strcpy(debugfs, DEBUGFS_PATH); | ||
| 224 | } | 246 | } |
| 225 | 247 | ||
| 226 | tracing_dir = malloc_or_die(strlen(debugfs) + 9); | 248 | tracing_dir = malloc_or_die(strlen(debugfs) + 9); |
