Resolve a page fault by copying data into the faulted address.
(fd: BorrowedFd<'_>, dst: u64, src: *const u8, len: u64)
| 152 | |
| 153 | /// Resolve a page fault by copying data into the faulted address. |
| 154 | pub(crate) fn copy(fd: BorrowedFd<'_>, dst: u64, src: *const u8, len: u64) -> Result<(), Error> { |
| 155 | let mut cp = UffdioCopy { |
| 156 | dst, |
| 157 | src: src as u64, |
| 158 | len, |
| 159 | mode: 0, |
| 160 | copy: 0, |
| 161 | }; |
| 162 | // SAFETY: `cp` is a valid, correctly-sized struct for this ioctl. |
| 163 | let ret = unsafe { |
| 164 | libc::ioctl( |
| 165 | fd.as_raw_fd(), |
| 166 | userfaultfd::UFFDIO_COPY as libc::Ioctl, |
| 167 | &mut cp, |
| 168 | ) |
| 169 | }; |
| 170 | if ret < 0 { |
| 171 | return Err(Error::last_os_error()); |
| 172 | } |
| 173 | Ok(()) |
| 174 | } |
| 175 | |
| 176 | #[repr(C)] |
| 177 | struct UffdioRange { |