From aa082c235a9ba2726385c07913bf1917faf928b2 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 4 Oct 2015 20:32:15 +0200 Subject: [PATCH] Utimens: Use UtimesNano instead of Futimes Futimes() only takes microsecond resolution while the FUSE call Utimens() wants nanosecond precision. This is why UTIME_OMIT did not work - this change fixes the xfstests generic/258 test failure. The go library does not provide a FutimesNano() function which is why I use UtimesNano() on /proc/self/fd/n. This is what the Go library does in Futimes(). --- pathfs_frontend/file.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pathfs_frontend/file.go b/pathfs_frontend/file.go index 02ebc42..7f5cc90 100644 --- a/pathfs_frontend/file.go +++ b/pathfs_frontend/file.go @@ -341,23 +341,23 @@ const _UTIME_NOW = ((1 << 30) - 1) const _UTIME_OMIT = ((1 << 30) - 2) func (f *file) Utimens(a *time.Time, m *time.Time) fuse.Status { - tv := make([]syscall.Timeval, 2) + ts := make([]syscall.Timespec, 2) + if a == nil { - tv[0].Usec = _UTIME_OMIT + ts[0].Nsec = _UTIME_OMIT } else { - n := a.UnixNano() - tv[0] = syscall.NsecToTimeval(n) + ts[0].Sec = a.Unix() } if m == nil { - tv[1].Usec = _UTIME_OMIT + ts[1].Nsec = _UTIME_OMIT } else { - n := a.UnixNano() - tv[1] = syscall.NsecToTimeval(n) + ts[1].Sec = m.Unix() } f.lock.Lock() - err := syscall.Futimes(int(f.fd.Fd()), tv) + fn := fmt.Sprintf("/proc/self/fd/%d", f.fd.Fd()) + err := syscall.UtimesNano(fn, ts) f.lock.Unlock() return fuse.ToStatus(err) }