|
2 | 2 | #![allow(improper_ctypes)]
|
3 | 3 |
|
4 | 4 | use {Errno, Result};
|
5 |
| -use libc::{self, c_int, c_void, size_t, off_t}; |
| 5 | +use libc::{self, c_int, c_ulong, c_void, size_t, off_t}; |
6 | 6 | use std::marker::PhantomData;
|
7 | 7 | use std::os::unix::io::RawFd;
|
8 | 8 |
|
@@ -56,6 +56,24 @@ pub fn pread(fd: RawFd, buf: &mut [u8], offset: off_t) -> Result<usize>{
|
56 | 56 | Errno::result(res).map(|r| r as usize)
|
57 | 57 | }
|
58 | 58 |
|
| 59 | +pub fn process_vm_writev(pid: libc::pid_t, local_iov: &[IoVec<&[u8]>], remote_iov: &mut [IoVec<&mut [u8]>]) -> Result<usize> { |
| 60 | + let res = unsafe { |
| 61 | + libc::process_vm_writev(pid, local_iov.as_ptr() as *const libc::iovec, local_iov.len() as c_ulong, |
| 62 | + remote_iov.as_ptr() as *const libc::iovec, remote_iov.len() as c_ulong, 0) |
| 63 | + }; |
| 64 | + |
| 65 | + Errno::result(res).map(|r| r as usize) |
| 66 | +} |
| 67 | + |
| 68 | +pub fn process_vm_readv(pid: libc::pid_t, local_iov: &mut [IoVec<&mut [u8]>], remote_iov: &[IoVec<&[u8]>]) -> Result<usize> { |
| 69 | + let res = unsafe { |
| 70 | + libc::process_vm_readv(pid, local_iov.as_ptr() as *const libc::iovec, local_iov.len() as c_ulong, |
| 71 | + remote_iov.as_ptr() as *const libc::iovec, remote_iov.len() as c_ulong, 0) |
| 72 | + }; |
| 73 | + |
| 74 | + Errno::result(res).map(|r| r as usize) |
| 75 | +} |
| 76 | + |
59 | 77 | #[repr(C)]
|
60 | 78 | pub struct IoVec<T>(libc::iovec, PhantomData<T>);
|
61 | 79 |
|
|
0 commit comments