Skip to content

Commit

Permalink
Support preadv/pwritev on BSDs
Browse files Browse the repository at this point in the history
  • Loading branch information
morrowa committed Apr 19, 2018
1 parent 97e0c47 commit 3502b03
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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.
Expand Down
25 changes: 23 additions & 2 deletions src/sys/uio.rs
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit 3502b03

Please sign in to comment.