Fallback to userspace copy if splice failed

Fix #9032
This commit is contained in:
topjohnwu
2025-09-03 11:35:29 -07:00
committed by John Wu
parent bc89c60977
commit fb0c4ea838
3 changed files with 99 additions and 69 deletions

View File

@@ -885,3 +885,19 @@ pub fn parse_mount_info(pid: &str) -> Vec<MountInfo> {
}
res
}
pub struct PipeFd {
pub read: OwnedFd,
pub write: OwnedFd,
}
pub fn make_pipe(flags: i32) -> OsResult<'static, PipeFd> {
let mut pipefd: [RawFd; 2] = [0; 2];
unsafe {
libc::pipe2(pipefd.as_mut_ptr(), flags).check_os_err("pipe2", None, None)?;
Ok(PipeFd {
read: OwnedFd::from_raw_fd(pipefd[0]),
write: OwnedFd::from_raw_fd(pipefd[1]),
})
}
}