Commit 92e2381b authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Add untested Utimens implementation for loopbackFile.

parent 1fa5a003
......@@ -4,7 +4,6 @@ import (
"fmt"
"os"
"sync"
"time"
"syscall"
)
......@@ -212,11 +211,7 @@ func (f *loopbackFile) GetAttr(a *Attr) Status {
return OK
}
func (f *loopbackFile) Utimens(a *time.Time, m *time.Time) Status {
return ENOSYS
}
// Allocate implemented in files_linux.go
// Allocate, Utimens implemented in files_linux.go
////////////////////////////////////////////////////////////////
......
package fuse
import (
"time"
"syscall"
)
......@@ -13,3 +14,28 @@ func (f *loopbackFile) Allocate(off uint64, sz uint64, mode uint32) Status {
}
return OK
}
const _UTIME_NOW = ((1 << 30) - 1)
const _UTIME_OMIT = ((1 << 30) - 2)
func (f *loopbackFile) Utimens(a *time.Time, m *time.Time) Status {
tv := make([]syscall.Timeval, 2)
if a == nil {
tv[0].Usec = _UTIME_OMIT
} else {
n := a.UnixNano()
tv[0].Sec = n / 1e9
tv[0].Usec = (n % 1e9) / 1e3
}
if m == nil {
tv[1].Usec = _UTIME_OMIT
} else {
n := a.UnixNano()
tv[1].Sec = n / 1e9
tv[1].Usec = (n % 1e9) / 1e3
}
err := syscall.Futimes(int(f.File.Fd()), tv)
return ToStatus(err)
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment