Skip to content

Commit 3502b03

Browse files
committed
Support preadv/pwritev on BSDs
1 parent 97e0c47 commit 3502b03

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
66
## [Unreleased]
77

88
### Added
9+
- Exposed `preadv` and `pwritev` on the BSDs.
10+
([#883](https://github.com/nix-rust/nix/pull/883))
911
- Added `mlockall` and `munlockall`
1012
([#876](https://github.com/nix-rust/nix/pull/876))
1113
- Added `SO_MARK` on Linux.

src/sys/uio.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,17 @@ pub fn readv(fd: RawFd, iov: &mut [IoVec<&mut [u8]>]) -> Result<usize> {
1919
Errno::result(res).map(|r| r as usize)
2020
}
2121

22-
#[cfg(target_os = "linux")]
22+
/// Write to `fd` at `offset` from buffers in `iov`.
23+
///
24+
/// Buffers in `iov` will be written in order until all buffers have been written
25+
/// or an error occurs. The file offset is not changed.
26+
///
27+
/// See also: [`writev`](fn.writev.html) and [`pwrite`](fn.pwrite.html)
28+
#[cfg(any(target_os = "dragonfly",
29+
target_os = "freebsd",
30+
target_os = "linux",
31+
target_os = "netbsd",
32+
target_os = "openbsd"))]
2333
pub fn pwritev(fd: RawFd, iov: &[IoVec<&[u8]>],
2434
offset: off_t) -> Result<usize> {
2535
let res = unsafe {
@@ -29,7 +39,18 @@ pub fn pwritev(fd: RawFd, iov: &[IoVec<&[u8]>],
2939
Errno::result(res).map(|r| r as usize)
3040
}
3141

32-
#[cfg(target_os = "linux")]
42+
/// Read from `fd` at `offset` filling buffers in `iov`.
43+
///
44+
/// Buffers in `iov` will be filled in order until all buffers have been filled,
45+
/// no more bytes are available, or an error occurs. The file offset is not
46+
/// changed.
47+
///
48+
/// See also: [`readv`](fn.readv.html) and [`pread`](fn.pread.html)
49+
#[cfg(any(target_os = "dragonfly",
50+
target_os = "freebsd",
51+
target_os = "linux",
52+
target_os = "netbsd",
53+
target_os = "openbsd"))]
3354
pub fn preadv(fd: RawFd, iov: &mut [IoVec<&mut [u8]>],
3455
offset: off_t) -> Result<usize> {
3556
let res = unsafe {

0 commit comments

Comments
 (0)