diff mbox series

libtracefs: Have tracefs_instance_tracers() return instance tracers

Message ID 20240820173604.29693def@gandalf.local.home (mailing list archive)
State Accepted
Commit 93d9049b0a240985b544f517ba46f09ac4936059
Headers show
Series libtracefs: Have tracefs_instance_tracers() return instance tracers | expand

Commit Message

Steven Rostedt Aug. 20, 2024, 9:36 p.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

The tracefs_instance_tracers() was always returning the top level tracers
and not the tracers that were available for the given instance.

Fixes: 185019c0 ("libtracefs: Add tracefs_instance_tracers() API")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 src/tracefs-events.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/src/tracefs-events.c b/src/tracefs-events.c
index 83069aa..77d1ba8 100644
--- a/src/tracefs-events.c
+++ b/src/tracefs-events.c
@@ -1012,12 +1012,20 @@  char **tracefs_tracers(const char *tracing_dir)
  */
 char **tracefs_instance_tracers(struct tracefs_instance *instance)
 {
-	const char *tracing_dir = NULL;
+	char *tracing_dir = NULL;
+	char **list;
+	int ret;
 
-	if (instance)
-		tracing_dir = instance->trace_dir;
+	if (instance) {
+		ret = asprintf(&tracing_dir, "%s/instances/%s", instance->trace_dir,
+			       instance->name);
+		if (ret < 0)
+			return NULL;
+	}
 
-	return list_tracers(tracing_dir);
+	list = list_tracers(tracing_dir);
+	free(tracing_dir);
+	return list;
 }
 
 static int load_events(struct tep_handle *tep,