Skip to content

Commit

Permalink
use a local helper macro to evade integer type confusion
Browse files Browse the repository at this point in the history
This is relevant on musl, where ioctl() accepts an i32, not a u64,
apparently.

Fixes nicokoch#4.
  • Loading branch information
FauxFaux committed Jun 4, 2019
1 parent 4aa58e5 commit 2a7528e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/sys/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub fn reflink(from: &Path, to: &Path) -> io::Result<()> {
use std::os::unix::io::AsRawFd;

// TODO is this equal on all archs? Just tested on x86_64 and x86.
const IOCTL_FICLONE: u64 = 0x40049409;
macro_rules! IOCTL_FICLONE { () => (0x40049409) };

let src = fs::File::open(&from)?;

Expand All @@ -18,7 +18,7 @@ pub fn reflink(from: &Path, to: &Path) -> io::Result<()> {
.open(&to)?;
let ret = unsafe {
// http://man7.org/linux/man-pages/man2/ioctl_ficlonerange.2.html
libc::ioctl(dest.as_raw_fd(), IOCTL_FICLONE, src.as_raw_fd())
libc::ioctl(dest.as_raw_fd(), IOCTL_FICLONE!(), src.as_raw_fd())
};

if ret == -1 {
Expand Down

0 comments on commit 2a7528e

Please sign in to comment.