Skip to contentSkip to conversation

libtracefs: Add tracefs_cpu_alloc_fd() and tracefs_cpu_free_fd()

PATCH New Steven Rostedt 1 participant 1 message Oct 26, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libtracefs: Add tracefs_cpu_alloc_fd() and tracefs_cpu_free_fd()

From: "Steven Rostedt (Google)" <[email protected]>

Add tracefs_cpu_alloc_fd() to attach a tracefs_cpu descriptor to an already opened file descriptor, and tracefs_cpu_free_fd() to clean up the descriptor that tracefs_cpu_alloc_fd() created.

---
Changes since v1: https://lore.kernel.org/linux-trace-devel/[email protected]

- Renamed tracefs_cpu_create_fd() to tracefs_cpu_alloc_fd()

- Added tracefs_cpu_free_fd() to clean up the descriptor created.

 include/tracefs.h    |   2 +
 src/tracefs-record.c | 118 +++++++++++++++++++++++++++++--------------
 2 files changed, 83 insertions(+), 37 deletions(-)
include/tracefs.h +2 -0
index f500cb47c372..fd4f0668e7cc 100644
@@ -597,9 +597,11 @@ tracefs_synth_get_event(struct tep_handle *tep, struct tracefs_synth *synth);
 
 struct tracefs_cpu;
 
+struct tracefs_cpu *tracefs_cpu_alloc_fd(int fd, int subbuf_size, bool nonblock);
 struct tracefs_cpu *tracefs_cpu_open(struct tracefs_instance *instance,
 				     int cpu, bool nonblock);
 void tracefs_cpu_close(struct tracefs_cpu *tcpu);
+void tracefs_cpu_free_fd(struct tracefs_cpu *tcpu);
 int tracefs_cpu_read_size(struct tracefs_cpu *tcpu);
 int tracefs_cpu_read(struct tracefs_cpu *tcpu, void *buffer, bool nonblock);
 int tracefs_cpu_buffered_read(struct tracefs_cpu *tcpu, void *buffer, bool nonblock);
src/tracefs-record.c +81 -37

174 lines not on this page · raw message

Signature · 1 line
2.35.1