Skip to content

Commit 3d0c87b

Browse files
author
Pat Hickey
committed
examples: fix build for nix 0.27, where PollFd takes an AsFd
instead of a RawFd. And there are some other places where mmap got changed from taking a RawFd to an Option<impl AsFd>, so pass it a None, which unfortunately requires some type annotation to work out
1 parent 9b3854b commit 3d0c87b

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

examples/manpage.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use libc::{self, c_void};
33
use nix::poll::{poll, PollFd, PollFlags};
44
use nix::sys::mman::{mmap, MapFlags, ProtFlags};
55
use nix::unistd::{sysconf, SysconfVar};
6-
use std::os::unix::io::AsRawFd;
76
use std::{convert::TryInto, env};
87
use userfaultfd::{Event, Uffd, UffdBuilder};
98

@@ -18,7 +17,7 @@ fn fault_handler_thread(uffd: Uffd) {
1817
page_size.try_into().unwrap(),
1918
ProtFlags::PROT_READ | ProtFlags::PROT_WRITE,
2019
MapFlags::MAP_PRIVATE | MapFlags::MAP_ANONYMOUS,
21-
-1,
20+
None::<std::os::fd::BorrowedFd>,
2221
0,
2322
)
2423
.expect("mmap")
@@ -30,7 +29,7 @@ fn fault_handler_thread(uffd: Uffd) {
3029
loop {
3130
// See what poll() tells us about the userfaultfd
3231

33-
let pollfd = PollFd::new(uffd.as_raw_fd(), PollFlags::POLLIN);
32+
let pollfd = PollFd::new(&uffd, PollFlags::POLLIN);
3433
let nready = poll(&mut [pollfd], -1).expect("poll");
3534

3635
println!("\nfault_handler_thread():");
@@ -101,7 +100,7 @@ fn main() {
101100
len.try_into().unwrap(),
102101
ProtFlags::PROT_READ | ProtFlags::PROT_WRITE,
103102
MapFlags::MAP_PRIVATE | MapFlags::MAP_ANONYMOUS,
104-
-1,
103+
None::<std::os::fd::BorrowedFd>,
105104
0,
106105
)
107106
.expect("mmap")

0 commit comments

Comments
 (0)