diff --git a/CHANGELOG.md b/CHANGELOG.md index 27ae766d88..e146c48395 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### Added +- Exposed `preadv` and `pwritev` on the BSDs. + ([#883](https://github.com/nix-rust/nix/pull/883)) - Added `mlockall` and `munlockall` ([#876](https://github.com/nix-rust/nix/pull/876)) - Added `SO_MARK` on Linux. diff --git a/src/sys/uio.rs b/src/sys/uio.rs index 5713f63c17..305c2ad0c1 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 { 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 { 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 { let res = unsafe {