@@ -1298,6 +1298,15 @@ LIBBPF_API size_t ring__avail_data_size(const struct ring *r);
*/
LIBBPF_API size_t ring__size(const struct ring *r);
+/**
+ * @brief **ring__map_fd()** returns the file descriptor underlying the given
+ * ringbuffer.
+ *
+ * @param r A ring object.
+ * @return The underlying ringbuffer file descriptor
+ */
+LIBBPF_API int ring__map_fd(const struct ring *r);
+
struct user_ring_buffer_opts {
size_t sz; /* size of this struct, for forward/backward compatibility */
};
@@ -403,6 +403,7 @@ LIBBPF_1.3.0 {
ring_buffer__ring;
ring__avail_data_size;
ring__consumer_pos;
+ ring__map_fd;
ring__producer_pos;
ring__size;
} LIBBPF_1.2.0;
@@ -360,6 +360,11 @@ size_t ring__size(const struct ring *r)
return r->mask + 1;
}
+int ring__map_fd(const struct ring *r)
+{
+ return r->map_fd;
+}
+
static void user_ringbuf_unmap_ring(struct user_ring_buffer *rb)
{
if (rb->consumer_pos) {
Add ring__map_fd to get the file descriptor underlying a given ringbuffer. Signed-off-by: Martin Kelly <martin.kelly@crowdstrike.com> --- tools/lib/bpf/libbpf.h | 9 +++++++++ tools/lib/bpf/libbpf.map | 1 + tools/lib/bpf/ringbuf.c | 5 +++++ 3 files changed, 15 insertions(+)