Skip to content
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
7 changes: 3 additions & 4 deletions src/backend/libc/fs/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,8 @@ pub(crate) fn copy_file_range(
off_in: Option<&mut u64>,
fd_out: BorrowedFd<'_>,
off_out: Option<&mut u64>,
len: u64,
) -> io::Result<u64> {
len: usize,
) -> io::Result<usize> {
assert_eq!(size_of::<c::loff_t>(), size_of::<u64>());

let mut off_in_val: c::loff_t = 0;
Expand All @@ -798,7 +798,6 @@ pub(crate) fn copy_file_range(
} else {
null_mut()
};
let len: usize = len.try_into().unwrap_or(usize::MAX);
let copied = unsafe {
syscall_ret_ssize_t(c::syscall(
c::SYS_copy_file_range,
Expand All @@ -816,7 +815,7 @@ pub(crate) fn copy_file_range(
if let Some(off_out) = off_out {
*off_out = off_out_val as u64;
}
Ok(copied as u64)
Ok(copied as usize)
}

#[cfg(not(any(
Expand Down
16 changes: 2 additions & 14 deletions src/backend/linux_raw/fs/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use crate::fs::{
};
use crate::io::{self, SeekFrom};
use crate::process::{Gid, Uid};
#[cfg(any(target_pointer_width = "32", target_arch = "mips64"))]
use core::convert::TryInto;
use core::mem::MaybeUninit;
#[cfg(target_arch = "mips64")]
Expand Down Expand Up @@ -1342,24 +1343,11 @@ pub(crate) fn accessat(

#[inline]
pub(crate) fn copy_file_range(
fd_in: BorrowedFd<'_>,
off_in: Option<&mut u64>,
fd_out: BorrowedFd<'_>,
off_out: Option<&mut u64>,
len: u64,
) -> io::Result<u64> {
let len: usize = len.try_into().unwrap_or(usize::MAX);
_copy_file_range(fd_in, off_in, fd_out, off_out, len, 0).map(|result| result as u64)
}

#[inline]
fn _copy_file_range(
fd_in: BorrowedFd<'_>,
off_in: Option<&mut u64>,
fd_out: BorrowedFd<'_>,
off_out: Option<&mut u64>,
len: usize,
flags: c::c_uint,
) -> io::Result<usize> {
unsafe {
ret_usize(syscall!(
Expand All @@ -1369,7 +1357,7 @@ fn _copy_file_range(
fd_out,
opt_mut(off_out),
pass_usize(len),
c_uint(flags)
c_uint(0)
))
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/fs/copy_file_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn copy_file_range<InFd: AsFd, OutFd: AsFd>(
off_in: Option<&mut u64>,
fd_out: OutFd,
off_out: Option<&mut u64>,
len: u64,
) -> io::Result<u64> {
len: usize,
) -> io::Result<usize> {
backend::fs::syscalls::copy_file_range(fd_in.as_fd(), off_in, fd_out.as_fd(), off_out, len)
}