From 6e922b240977010b0f257d22c379df95cf1a6fb9 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Sat, 22 Oct 2011 19:48:50 -0400 Subject: [PATCH] Add ustctl_open_stream_read and ustctl_close_stream_read Signed-off-by: Mathieu Desnoyers --- include/ust/lttng-ust-ctl.h | 6 ++++++ libustctl/ustctl.c | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/include/ust/lttng-ust-ctl.h b/include/ust/lttng-ust-ctl.h index 58906a57..52c954aa 100644 --- a/include/ust/lttng-ust-ctl.h +++ b/include/ust/lttng-ust-ctl.h @@ -90,6 +90,12 @@ void ustctl_unmap_channel(struct shm_handle *shm_handle); struct shm_handle; struct lib_ring_buffer; +/* Open/close stream buffers for read */ +struct lib_ring_buffer *ustctl_open_stream_read(struct shm_handle *handle, + int cpu); +void ustctl_close_stream_read(struct shm_handle *handle, + struct lib_ring_buffer *buf); + /* For mmap mode, readable without "get" operation */ int ustctl_get_mmap_len(struct shm_handle *handle, struct lib_ring_buffer *buf, diff --git a/libustctl/ustctl.c b/libustctl/ustctl.c index 581de965..abe6d034 100644 --- a/libustctl/ustctl.c +++ b/libustctl/ustctl.c @@ -452,6 +452,31 @@ void ustctl_unmap_channel(struct shm_handle *handle) channel_destroy(chan, handle, 1); } +struct lib_ring_buffer *ustctl_open_stream_read(struct shm_handle *handle, + int cpu) +{ + struct channel *chan = handle->shadow_chan; + int shm_fd, wait_fd; + uint64_t memory_map_size; + struct lib_ring_buffer *buf; + int ret; + + buf = channel_get_ring_buffer(&chan->backend.config, + chan, cpu, handle, &shm_fd, &wait_fd, &memory_map_size); + if (!buf) + return NULL; + ret = lib_ring_buffer_open_read(buf, handle, 1); + if (ret) + return NULL; + return buf; +} + +void ustctl_close_stream_read(struct shm_handle *handle, + struct lib_ring_buffer *buf) +{ + lib_ring_buffer_release_read(buf, handle, 1); +} + /* For mmap mode, readable without "get" operation */ /* returns the length to mmap. */ -- 2.34.1