4 * Copyright (C) 2013 Hitachi, Ltd.
7 * This work is licensed under the terms of the GNU GPL, version 2. See
8 * the COPYING file in the top-level directory.
17 #include "trace/control.h"
21 static int find_debugfs(char *debugfs)
26 fp = fopen("/proc/mounts", "r");
31 while (fscanf(fp, "%*s %" STR(PATH_MAX) "s %99s %*s %*d %*d\n",
32 debugfs, type) == 2) {
33 if (strcmp(type, "debugfs") == 0) {
39 if (strcmp(type, "debugfs") != 0) {
45 bool ftrace_init(void)
47 char debugfs[PATH_MAX];
52 debugfs_found = find_debugfs(debugfs);
54 snprintf(path, PATH_MAX, "%s/tracing/tracing_on", debugfs);
55 trace_fd = open(path, O_WRONLY);
57 perror("Could not open ftrace 'tracing_on' file");
60 if (write(trace_fd, "1", 1) < 0) {
61 perror("Could not write to 'tracing_on' file");
67 snprintf(path, PATH_MAX, "%s/tracing/trace_marker", debugfs);
68 trace_marker_fd = open(path, O_WRONLY);
69 if (trace_marker_fd < 0) {
70 perror("Could not open ftrace 'trace_marker' file");
74 fprintf(stderr, "debugfs is not mounted\n");