touch_chunk: use libc::lutimensat

This commit is contained in:
Dietmar Maurer 2018-12-25 11:59:02 +01:00
parent 2c32fdde86
commit 7ee2aa1b94
1 changed files with 18 additions and 1 deletions

View File

@ -154,7 +154,24 @@ impl ChunkStore {
let digest_str = digest_to_hex(&digest); let digest_str = digest_to_hex(&digest);
chunk_path.push(&digest_str); chunk_path.push(&digest_str);
std::fs::metadata(&chunk_path)?; const UTIME_NOW: i64 = ((1 << 30) - 1);
const UTIME_OMIT: i64 = ((1 << 30) - 2);
let mut times: [libc::timespec; 2] = [
libc::timespec { tv_sec: 0, tv_nsec: UTIME_NOW },
libc::timespec { tv_sec: 0, tv_nsec: UTIME_OMIT }
];
use nix::NixPath;
let res = chunk_path.with_nix_path(|cstr| unsafe {
libc::utimensat(-1, cstr.as_ptr(), &times[0], libc::AT_SYMLINK_NOFOLLOW)
})?;
if let Err(err) = nix::errno::Errno::result(res) {
bail!("updata atime failed for chunk {:?} - {}", chunk_path, err);
}
Ok(()) Ok(())
} }