mirror of
https://github.com/netdata/libbpf.git
synced 2026-04-06 00:29:07 +08:00
libbpf: Add ring__map_fd
Add ring__map_fd to get the file descriptor underlying a given 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-12-martin.kelly@crowdstrike.com
This commit is contained in:
committed by
Andrii Nakryiko
parent
cd3fe56c75
commit
6413c2d063
@@ -1303,6 +1303,15 @@ LIBBPF_API size_t ring__avail_data_size(const struct ring *r);
|
|||||||
*/
|
*/
|
||||||
LIBBPF_API size_t ring__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 ringbuffer object.
|
||||||
|
* @return The underlying ringbuffer file descriptor
|
||||||
|
*/
|
||||||
|
LIBBPF_API int ring__map_fd(const struct ring *r);
|
||||||
|
|
||||||
struct user_ring_buffer_opts {
|
struct user_ring_buffer_opts {
|
||||||
size_t sz; /* size of this struct, for forward/backward compatibility */
|
size_t sz; /* size of this struct, for forward/backward compatibility */
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -402,6 +402,7 @@ LIBBPF_1.3.0 {
|
|||||||
bpf_program__attach_uprobe_multi;
|
bpf_program__attach_uprobe_multi;
|
||||||
ring__avail_data_size;
|
ring__avail_data_size;
|
||||||
ring__consumer_pos;
|
ring__consumer_pos;
|
||||||
|
ring__map_fd;
|
||||||
ring__producer_pos;
|
ring__producer_pos;
|
||||||
ring__size;
|
ring__size;
|
||||||
ring_buffer__ring;
|
ring_buffer__ring;
|
||||||
|
|||||||
@@ -366,6 +366,11 @@ size_t ring__size(const struct ring *r)
|
|||||||
return r->mask + 1;
|
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)
|
static void user_ringbuf_unmap_ring(struct user_ring_buffer *rb)
|
||||||
{
|
{
|
||||||
if (rb->consumer_pos) {
|
if (rb->consumer_pos) {
|
||||||
|
|||||||
Reference in New Issue
Block a user