Skip to content

Commit 71c8c02

Browse files
d-e-s-odanielocfb
authored andcommitted
Remove Link::fd() method
With this change we remove the Link::fd() method in favor of the recently added Link::as_fd(), which uses proper file descriptor wrapper types that honor lifetimes. Signed-off-by: Daniel Müller <[email protected]>
1 parent 08b68f6 commit 71c8c02

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

libbpf-rs/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ Unreleased
1212
`Map`
1313
- Removed support for creating `Map` objects standalone (i.e. maps not created
1414
by libbpf)
15-
- Removed `Map::fd()` in favor of `Map::as_fd()`
16-
- Removed `Program::fd()` in favor of `Program::as_fd()`
15+
- Removed various `<object-type>::fd()` methods in favor of
16+
`<object-type>::as_fd()`
1717
- Improved `btf_type_match!` macro, adding support for most of Rust's `match`
1818
capabilities
1919
- Added `skel` module exposing skeleton related traits

libbpf-rs/src/iter.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
use std::io;
2+
use std::os::unix::io::AsFd as _;
3+
use std::os::unix::io::AsRawFd as _;
4+
15
use nix::errno;
26
use nix::libc;
37
use nix::unistd;
4-
use std::io;
58

69
use crate::libbpf_sys;
710
use crate::Error;
@@ -22,7 +25,7 @@ pub struct Iter {
2225
impl Iter {
2326
/// Create a new `Iter` wrapping the provided `Link`.
2427
pub fn new(link: &Link) -> Result<Self> {
25-
let link_fd = link.fd();
28+
let link_fd = link.as_fd().as_raw_fd();
2629
let fd = unsafe { libbpf_sys::bpf_iter_create(link_fd) };
2730
if fd < 0 {
2831
return Err(Error::System(errno::errno()));

libbpf-rs/src/link.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,6 @@ impl Link {
8383
util::parse_ret(ret)
8484
}
8585

86-
/// Returns the file descriptor of the link.
87-
pub fn fd(&self) -> i32 {
88-
unsafe { libbpf_sys::bpf_link__fd(self.ptr.as_ptr()) }
89-
}
90-
9186
/// Returns path to BPF FS file or `None` if not pinned.
9287
pub fn pin_path(&self) -> Option<PathBuf> {
9388
let path_ptr = unsafe { libbpf_sys::bpf_link__pin_path(self.ptr.as_ptr()) };

0 commit comments

Comments
 (0)