Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

accurate mtimes for directories, overwrite symlinks, preserve ownership #217

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
improve macos compatibility by abstracting over errno
  • Loading branch information
moschroe committed Nov 23, 2019
commit e3e197838ffbb12d0d773b0fe68cb664d422bc61
12 changes: 11 additions & 1 deletion src/entry.rs
Original file line number Diff line number Diff line change
@@ -903,7 +903,17 @@ unsafe fn set_owner<P: AsRef<Path>>(path: P, uid: u64, gid: u64) -> io::Result<(
let res_chown =
/*unsafe*/ { libc::chown(cstr_path.as_ptr(), uid as libc::uid_t, gid as libc::gid_t) };
if res_chown != 0 {
return Err(io::Error::from_raw_os_error(*libc::__errno_location()));
return Err(io::Error::from_raw_os_error(libc_errno()));
}
Ok(())
}

#[cfg(all(unix, target_os = "linux"))]
fn libc_errno() -> libc::c_int {
unsafe { *libc::__errno_location() }
}

#[cfg(all(unix, not(target_os = "linux")))]
fn errno() -> i32 {
unsafe { *libc::__errno() }
}