mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-11 03:24:58 -06:00
trace: Generalize searching for debugfs
The find_debugfs() can be shared to find a different filesystem like tracefs. So make it more general and rename to find_mount(). Signed-off-by: Namhyung Kim <namhyung@gmail.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
5070570c90
commit
babfff8e11
1 changed files with 7 additions and 7 deletions
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
int trace_marker_fd;
|
int trace_marker_fd;
|
||||||
|
|
||||||
static int find_debugfs(char *debugfs)
|
static int find_mount(char *mount_point, const char *fstype)
|
||||||
{
|
{
|
||||||
char type[100];
|
char type[100];
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
@ -27,8 +27,8 @@ static int find_debugfs(char *debugfs)
|
||||||
}
|
}
|
||||||
|
|
||||||
while (fscanf(fp, "%*s %" STR(PATH_MAX) "s %99s %*s %*d %*d\n",
|
while (fscanf(fp, "%*s %" STR(PATH_MAX) "s %99s %*s %*d %*d\n",
|
||||||
debugfs, type) == 2) {
|
mount_point, type) == 2) {
|
||||||
if (strcmp(type, "debugfs") == 0) {
|
if (strcmp(type, fstype) == 0) {
|
||||||
ret = 1;
|
ret = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -40,14 +40,14 @@ static int find_debugfs(char *debugfs)
|
||||||
|
|
||||||
bool ftrace_init(void)
|
bool ftrace_init(void)
|
||||||
{
|
{
|
||||||
char debugfs[PATH_MAX];
|
char mount_point[PATH_MAX];
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
int debugfs_found;
|
int debugfs_found;
|
||||||
int trace_fd = -1;
|
int trace_fd = -1;
|
||||||
|
|
||||||
debugfs_found = find_debugfs(debugfs);
|
debugfs_found = find_mount(mount_point, "debugfs");
|
||||||
if (debugfs_found) {
|
if (debugfs_found) {
|
||||||
snprintf(path, PATH_MAX, "%s/tracing/tracing_on", debugfs);
|
snprintf(path, PATH_MAX, "%s/tracing/tracing_on", mount_point);
|
||||||
trace_fd = open(path, O_WRONLY);
|
trace_fd = open(path, O_WRONLY);
|
||||||
if (trace_fd < 0) {
|
if (trace_fd < 0) {
|
||||||
if (errno == EACCES) {
|
if (errno == EACCES) {
|
||||||
|
@ -66,7 +66,7 @@ bool ftrace_init(void)
|
||||||
}
|
}
|
||||||
close(trace_fd);
|
close(trace_fd);
|
||||||
}
|
}
|
||||||
snprintf(path, PATH_MAX, "%s/tracing/trace_marker", debugfs);
|
snprintf(path, PATH_MAX, "%s/tracing/trace_marker", mount_point);
|
||||||
trace_marker_fd = open(path, O_WRONLY);
|
trace_marker_fd = open(path, O_WRONLY);
|
||||||
if (trace_marker_fd < 0) {
|
if (trace_marker_fd < 0) {
|
||||||
perror("Could not open ftrace 'trace_marker' file");
|
perror("Could not open ftrace 'trace_marker' file");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue