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().
This commit is contained in:
parent
c7313f36de
commit
aa082c235a
@ -341,23 +341,23 @@ const _UTIME_NOW = ((1 << 30) - 1)
|
|||||||
const _UTIME_OMIT = ((1 << 30) - 2)
|
const _UTIME_OMIT = ((1 << 30) - 2)
|
||||||
|
|
||||||
func (f *file) Utimens(a *time.Time, m *time.Time) fuse.Status {
|
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 {
|
if a == nil {
|
||||||
tv[0].Usec = _UTIME_OMIT
|
ts[0].Nsec = _UTIME_OMIT
|
||||||
} else {
|
} else {
|
||||||
n := a.UnixNano()
|
ts[0].Sec = a.Unix()
|
||||||
tv[0] = syscall.NsecToTimeval(n)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if m == nil {
|
if m == nil {
|
||||||
tv[1].Usec = _UTIME_OMIT
|
ts[1].Nsec = _UTIME_OMIT
|
||||||
} else {
|
} else {
|
||||||
n := a.UnixNano()
|
ts[1].Sec = m.Unix()
|
||||||
tv[1] = syscall.NsecToTimeval(n)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
f.lock.Lock()
|
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()
|
f.lock.Unlock()
|
||||||
return fuse.ToStatus(err)
|
return fuse.ToStatus(err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user