Esempio n. 1
0
bool ftrace_init(void)
{
    char debugfs[PATH_MAX];
    char path[PATH_MAX];
    int debugfs_found;
    int trace_fd = -1;

    debugfs_found = find_debugfs(debugfs);
    if (debugfs_found) {
        snprintf(path, PATH_MAX, "%s/tracing/tracing_on", debugfs);
        trace_fd = open(path, O_WRONLY);
        if (trace_fd < 0) {
            perror("Could not open ftrace 'tracing_on' file");
            return false;
        } else {
            if (write(trace_fd, "1", 1) < 0) {
                perror("Could not write to 'tracing_on' file");
                close(trace_fd);
                return false;
            }
            close(trace_fd);
        }
        snprintf(path, PATH_MAX, "%s/tracing/trace_marker", debugfs);
        trace_marker_fd = open(path, O_WRONLY);
        if (trace_marker_fd < 0) {
            perror("Could not open ftrace 'trace_marker' file");
            return false;
        }
    } else {
        fprintf(stderr, "debugfs is not mounted\n");
        return false;
    }

    return true;
}
Esempio n. 2
0
int main(int argc, char **argv)
{
	const char *dfs = find_debugfs();
	if (!dfs)
		die("could not find debugfs");

	return 0;
}
/*
 * Finds the path to the debugfs/tracing
 * Allocates the string and stores it.
 */
static const char *find_tracing_dir(void)
{
	static char *tracing;
	static int tracing_found;
	const char *debugfs;

	if (tracing_found)
		return tracing;

	debugfs = find_debugfs();

	tracing = malloc_or_die(strlen(debugfs) + 9);

	sprintf(tracing, "%s/tracing", debugfs);

	tracing_found = 1;
	return tracing;
}
Esempio n. 4
0
static const char *find_trace(void)
{
	static char t[MAX_PATH + 1];
	if (t[0] != '\0')
		return t;

	const char *mt = getenv("T");
	if (mt)
		strcpy(t, mt);
	if (t[0] != '\0')
		return t;

	const char *d = find_debugfs();
	if (!d)
		return NULL;

	strcpy(t, d);
	strcat(t, "/trace/trace");
	return t;
}
Esempio n. 5
0
File: util.c Progetto: 19Dan01/linux
/*
 * Finds the path to the debugfs/tracing
 * Allocates the string and stores it.
 */
const char *find_tracing_dir(void)
{
	const char *tracing_dir = "";
	static char *tracing;
	static int tracing_found;
	const char *debugfs;

	if (tracing_found)
		return tracing;

	debugfs = find_tracefs();
	if (!debugfs) {
		tracing_dir = "/tracing";
		debugfs = find_debugfs();
		if (!debugfs)
			return NULL;
	}

	if (asprintf(&tracing, "%s%s", debugfs, tracing_dir) < 0)
		return NULL;

	tracing_found = 1;
	return tracing;
}