diff --git a/src/file_util.rs b/src/file_util.rs index 8f86a55f..32f99795 100644 --- a/src/file_util.rs +++ b/src/file_util.rs @@ -10,15 +10,12 @@ use std::os::unix::io::AsRawFd; use std::os::unix::ffi::OsStrExt; use nix; -use libc::{uid_t, gid_t, c_int, utime, utimbuf}; +use libc; +use libc::{uid_t, gid_t, utime, utimbuf, time_t}; use nix::fcntl::{flock, FlockArg}; use path_util::ToCString; -extern "C" { - fn lchown(path: *const i8, owner: uid_t, group: gid_t) -> c_int; -} - pub struct Lock { file: fs::File, } @@ -304,7 +301,7 @@ pub fn set_owner_group(target: &Path, uid: uid_t, gid: gid_t) -> Result<(), io::Error> { let c_target = target.to_cstring(); - let rc = unsafe { lchown( c_target.as_ptr(), uid, gid) }; + let rc = unsafe { libc::lchown( c_target.as_ptr(), uid, gid) }; if rc != 0 { warn!("Can't chown {:?}: {}", target, io::Error::last_os_error()); Ok(()) @@ -471,8 +468,8 @@ pub fn set_times>(path: P, atime: i64, mtime: i64) { let filename = CString::new(path.as_ref().as_os_str().as_bytes()).unwrap(); let utimes = utimbuf { - actime: atime, - modtime: mtime, + actime: atime as time_t, + modtime: mtime as time_t, }; let rc = unsafe { utime(filename.as_ptr(), &utimes) }; if rc != 0 {