aboutsummaryrefslogtreecommitdiff
path: root/pathfs_frontend
diff options
context:
space:
mode:
authorJakob Unterwurzacher2015-10-04 20:32:15 +0200
committerJakob Unterwurzacher2015-10-04 20:32:15 +0200
commitaa082c235a9ba2726385c07913bf1917faf928b2 (patch)
tree23d6df7940b8e47e64e0a1ec83d59b1f6e22169e /pathfs_frontend
parentc7313f36dee285a8adab801632c8d692bd5f5e7e (diff)
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().
Diffstat (limited to 'pathfs_frontend')
-rw-r--r--pathfs_frontend/file.go16
1 files 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)
}