mirror of
https://github.com/netdata/libbpf.git
synced 2026-03-28 12:19:07 +08:00
libbpf: Add ring_buffer__ring
Add a new function ring_buffer__ring, which exposes struct ring * to the user, representing a single ringbuffer. Signed-off-by: Martin Kelly <martin.kelly@crowdstrike.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20230925215045.2375758-4-martin.kelly@crowdstrike.com
This commit is contained in:
committed by
Andrii Nakryiko
parent
bfa471bc85
commit
a20576f5f2
@@ -330,6 +330,14 @@ int ring_buffer__epoll_fd(const struct ring_buffer *rb)
|
||||
return rb->epoll_fd;
|
||||
}
|
||||
|
||||
struct ring *ring_buffer__ring(struct ring_buffer *rb, unsigned int idx)
|
||||
{
|
||||
if (idx >= rb->ring_cnt)
|
||||
return errno = ERANGE, NULL;
|
||||
|
||||
return rb->rings[idx];
|
||||
}
|
||||
|
||||
static void user_ringbuf_unmap_ring(struct user_ring_buffer *rb)
|
||||
{
|
||||
if (rb->consumer_pos) {
|
||||
|
||||
Reference in New Issue
Block a user