diff options
author | Andrew Morrow <andrew.d.morrow@gmail.com> | 2018-04-12 22:23:13 -0600 |
---|---|---|
committer | Andrew Morrow <andrew.d.morrow@gmail.com> | 2018-04-18 21:01:04 -0600 |
commit | 3502b037b6e8f668ca2d2a399b567a0700cda3b3 (patch) | |
tree | 44d492f7c9588ef0e94571169da01b84d34ff643 /src/sys/uio.rs | |
parent | 97e0c4714859eb0f7d15e5e0eddca2a36c7360dc (diff) | |
download | nix-3502b037b6e8f668ca2d2a399b567a0700cda3b3.zip |
Support preadv/pwritev on BSDs
Diffstat (limited to 'src/sys/uio.rs')
-rw-r--r-- | src/sys/uio.rs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/sys/uio.rs b/src/sys/uio.rs index 5713f63c..305c2ad0 100644 --- a/src/sys/uio.rs +++ b/src/sys/uio.rs @@ -19,7 +19,17 @@ pub fn readv(fd: RawFd, iov: &mut [IoVec<&mut [u8]>]) -> Result<usize> { Errno::result(res).map(|r| r as usize) } -#[cfg(target_os = "linux")] +/// Write to `fd` at `offset` from buffers in `iov`. +/// +/// Buffers in `iov` will be written in order until all buffers have been written +/// or an error occurs. The file offset is not changed. +/// +/// See also: [`writev`](fn.writev.html) and [`pwrite`](fn.pwrite.html) +#[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux", + target_os = "netbsd", + target_os = "openbsd"))] pub fn pwritev(fd: RawFd, iov: &[IoVec<&[u8]>], offset: off_t) -> Result<usize> { let res = unsafe { @@ -29,7 +39,18 @@ pub fn pwritev(fd: RawFd, iov: &[IoVec<&[u8]>], Errno::result(res).map(|r| r as usize) } -#[cfg(target_os = "linux")] +/// Read from `fd` at `offset` filling buffers in `iov`. +/// +/// Buffers in `iov` will be filled in order until all buffers have been filled, +/// no more bytes are available, or an error occurs. The file offset is not +/// changed. +/// +/// See also: [`readv`](fn.readv.html) and [`pread`](fn.pread.html) +#[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux", + target_os = "netbsd", + target_os = "openbsd"))] pub fn preadv(fd: RawFd, iov: &mut [IoVec<&mut [u8]>], offset: off_t) -> Result<usize> { let res = unsafe { |