bool ftrace_init(void)

{

    char mount_point[PATH_MAX];

    char path[PATH_MAX];

    int debugfs_found;

    int trace_fd = -1;



    debugfs_found = find_mount(mount_point, "debugfs");

    if (debugfs_found) {

        snprintf(path, PATH_MAX, "%s/tracing/tracing_on", mount_point);

        trace_fd = open(path, O_WRONLY);

        if (trace_fd < 0) {

            if (errno == EACCES) {

                trace_marker_fd = open("/dev/null", O_WRONLY);

                if (trace_marker_fd != -1) {

                    return true;

                }

            }

            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", mount_point);

        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;

}

bool ftrace_init(void)

{

    char mount_point[PATH_MAX];

    char path[PATH_MAX];

    int debugfs_found;

    int trace_fd = -1;



    debugfs_found = find_mount(mount_point, "debugfs");

    if (debugfs_found) {

        snprintf(path, PATH_MAX, "%s/tracing/tracing_on", mount_point);

        trace_fd = open(path, O_WRONLY);

        if (trace_fd < 0) {

            if (errno == EACCES) {

                trace_marker_fd = open("/dev/null", O_WRONLY);

                if (trace_marker_fd != -1) {

                    return true;

                }

            }

            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", mount_point);

        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;

}

    int debugfs_found;     debugfs_found = find_mount(mount_point, "debugfs");     if (debugfs_found) {         snprintf(path, PATH_MAX, "%s/tracing/tracing_on", mount_point);         snprintf(path, PATH_MAX, "%s/tracing/trace_marker", mount_point);         fprintf(stderr, "debugfs is not mounted\n");
bool FUNC_0(void)

{

    char VAR_0[PATH_MAX];

    char VAR_1[PATH_MAX];

    int VAR_2;

    int VAR_3 = -1;



    VAR_2 = find_mount(VAR_0, "debugfs");

    if (VAR_2) {

        snprintf(VAR_1, PATH_MAX, "%s/tracing/tracing_on", VAR_0);

        VAR_3 = open(VAR_1, O_WRONLY);

        if (VAR_3 < 0) {

            if (errno == EACCES) {

                trace_marker_fd = open("/dev/null", O_WRONLY);

                if (trace_marker_fd != -1) {

                    return true;

                }

            }

            perror("Could not open ftrace 'tracing_on' file");

            return false;

        } else {

            if (write(VAR_3, "1", 1) < 0) {

                perror("Could not write to 'tracing_on' file");

                close(VAR_3);

                return false;

            }

            close(VAR_3);

        }

        snprintf(VAR_1, PATH_MAX, "%s/tracing/trace_marker", VAR_0);

        trace_marker_fd = open(VAR_1, 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;

}

bool FUNC_0(void)
{ char VAR_0[PATH_MAX]; char VAR_1[PATH_MAX]; int VAR_2; int VAR_3 = -1; VAR_2 = find_mount(VAR_0, "debugfs"); if (VAR_2) { snprintf(VAR_1, PATH_MAX, "%s/tracing/tracing_on", VAR_0); VAR_3 = open(VAR_1, O_WRONLY); if (VAR_3 < 0) { if (errno == EACCES) { trace_marker_fd = open("/dev/null", O_WRONLY); if (trace_marker_fd != -1) { return true; } } perror("Could not open ftrace 'tracing_on' file"); return false; } else { if (write(VAR_3, "1", 1) < 0) { perror("Could not write to 'tracing_on' file"); close(VAR_3); return false; } close(VAR_3); } snprintf(VAR_1, PATH_MAX, "%s/tracing/trace_marker", VAR_0); trace_marker_fd = open(VAR_1, 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; }