Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/gpio/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl ServerBackend for TestBackend {
offset: u64,
address: u64,
size: u64,
fd: Option<&File>,
fd: Option<File>,
) -> Result<(), std::io::Error> {
info!("dma_map flags = {flags:?} offset = {offset} address = {address} size = {size} fd = {fd:?}");
Ok(())
Expand Down
12 changes: 10 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ pub trait ServerBackend {
_offset: u64,
_address: u64,
_size: u64,
_fd: Option<&File>,
_fd: Option<File>,
) -> Result<(), std::io::Error>;
fn dma_unmap(
&mut self,
Expand Down Expand Up @@ -951,13 +951,21 @@ impl Server {
.read_exact(&mut cmd.as_mut_slice()[size_of::<Header>()..])
.map_err(Error::StreamRead)?;

let mut fds = fds;

// The specification demands that the caller passes 0
// or 1 file descriptor.
if fds.len() > 1 {
return Err(Error::InvalidInput);
}

backend
.dma_map(
DmaMapFlags::from_bits_truncate(cmd.flags),
cmd.offset,
cmd.address,
cmd.size,
if fds.len() > 1 { Some(&fds[0]) } else { None },
fds.pop(),
)
.map_err(Error::Backend)?;

Expand Down
Loading