Skip to content

Commit

Permalink
fix compile on mac os
Browse files Browse the repository at this point in the history
Signed-off-by: qupeng <[email protected]>
  • Loading branch information
hicqu committed Oct 20, 2020
1 parent 06e9b01 commit c651c2d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/pipe_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use log::{info, warn};
use nix::errno::Errno;
use nix::fcntl::{self, OFlag};
use nix::sys::stat::Mode;
use nix::sys::uio::{pread, pwrite, pwritev, IoVec as NixIoVec};
use nix::sys::uio::{pread, pwrite, IoVec as NixIoVec};
use nix::unistd::{close, fsync, ftruncate, lseek, Whence};
use nix::NixPath;
use protobuf::Message;
Expand Down Expand Up @@ -691,6 +691,7 @@ fn pwrite_exact(fd: RawFd, mut offset: u64, content: &[u8]) -> Result<()> {
Ok(())
}

#[cfg(unix)]
fn pwritev_exact<'a>(
fd: RawFd,
mut offset: u64,
Expand Down Expand Up @@ -719,7 +720,7 @@ fn pwritev_exact<'a>(
}

while !vecs.is_empty() {
let bytes = match pwritev(fd, vecs, offset as _) {
let bytes = match nix::sys::uio::pwritev(fd, vecs, offset as _) {
Ok(bytes) => bytes,
Err(e) if e.as_errno() == Some(Errno::EAGAIN) => continue,
Err(e) => return Err(parse_nix_error(e, "pwrite")),
Expand All @@ -730,6 +731,17 @@ fn pwritev_exact<'a>(
Ok(())
}

#[cfg(not(unix))]
fn pwritev_exact<'a>(fd: RawFd, mut offset: u64, vecs: &'a [NixIoVec<&'a [u8]>]) -> Result<()> {
for vec in vecs {
let content = vec.as_slice();
let len = content.len();
pwrite_exact(fd, offset, content)?;
offset += len as u64;
}
Ok(())
}

fn write_file_header(fd: RawFd) -> Result<usize> {
let len = FILE_MAGIC_HEADER.len() + VERSION.len();
let mut header = Vec::with_capacity(len);
Expand Down

0 comments on commit c651c2d

Please sign in to comment.