diff --git a/src/unix/linux.rs b/src/unix/linux.rs index c803e02..a07dfb1 100644 --- a/src/unix/linux.rs +++ b/src/unix/linux.rs @@ -35,8 +35,7 @@ pub fn set_file_handle_times( if !INVALID.load(SeqCst) { let times = [super::to_timespec(&atime), super::to_timespec(&mtime)]; let rc = unsafe { - libc::syscall( - libc::SYS_utimensat, + libc::utimensat( f.as_raw_fd(), ptr::null::(), times.as_ptr(), @@ -78,15 +77,7 @@ fn set_times( if !INVALID.load(SeqCst) { let p = CString::new(p.as_os_str().as_bytes())?; let times = [super::to_timespec(&atime), super::to_timespec(&mtime)]; - let rc = unsafe { - libc::syscall( - libc::SYS_utimensat, - libc::AT_FDCWD, - p.as_ptr(), - times.as_ptr(), - flags, - ) - }; + let rc = unsafe { libc::utimensat(libc::AT_FDCWD, p.as_ptr(), times.as_ptr(), flags) }; if rc == 0 { return Ok(()); } diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 8b77888..df62de4 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -58,17 +58,16 @@ fn to_timespec(ft: &Option) -> timespec { } } + let mut ts: timespec = unsafe { std::mem::zeroed() }; if let &Some(ft) = ft { - timespec { - tv_sec: ft.seconds() as time_t, - tv_nsec: ft.nanoseconds() as _, - } + ts.tv_sec = ft.seconds() as time_t; + ts.tv_nsec = ft.nanoseconds() as _; } else { - timespec { - tv_sec: 0, - tv_nsec: UTIME_OMIT as _, - } + ts.tv_sec = 0; + ts.tv_nsec = UTIME_OMIT as _; } + + ts } pub fn from_last_modification_time(meta: &fs::Metadata) -> FileTime {