Commit ad0890e9 authored by Jakob Unterwurzacher's avatar Jakob Unterwurzacher

loopback: Utimens() has identical implementations in darwin and linux

Merge into files.go
parent 8783b8e8
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"os" "os"
"sync" "sync"
"syscall" "syscall"
"time"
"github.com/hanwen/go-fuse/fuse" "github.com/hanwen/go-fuse/fuse"
) )
...@@ -200,6 +201,32 @@ func (f *loopbackFile) GetAttr(a *fuse.Attr) fuse.Status { ...@@ -200,6 +201,32 @@ func (f *loopbackFile) GetAttr(a *fuse.Attr) fuse.Status {
return fuse.OK return fuse.OK
} }
const _UTIME_NOW = ((1 << 30) - 1)
const _UTIME_OMIT = ((1 << 30) - 2)
func (f *loopbackFile) Utimens(a *time.Time, m *time.Time) fuse.Status {
tv := make([]syscall.Timeval, 2)
if a == nil {
tv[0].Usec = _UTIME_OMIT
} else {
n := a.UnixNano()
tv[0] = syscall.NsecToTimeval(n)
}
if m == nil {
tv[1].Usec = _UTIME_OMIT
} else {
n := m.UnixNano()
tv[1] = syscall.NsecToTimeval(n)
}
f.lock.Lock()
err := syscall.Futimes(int(f.File.Fd()), tv)
f.lock.Unlock()
return fuse.ToStatus(err)
}
// Allocate, Utimens implemented in files_linux.go // Allocate, Utimens implemented in files_linux.go
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
......
...@@ -60,29 +60,3 @@ func (f *loopbackFile) Allocate(off uint64, sz uint64, mode uint32) fuse.Status ...@@ -60,29 +60,3 @@ func (f *loopbackFile) Allocate(off uint64, sz uint64, mode uint32) fuse.Status
} }
return fuse.OK return fuse.OK
} }
const _UTIME_NOW = ((1 << 30) - 1)
const _UTIME_OMIT = ((1 << 30) - 2)
func (f *loopbackFile) Utimens(a *time.Time, m *time.Time) fuse.Status {
tv := make([]syscall.Timeval, 2)
if a == nil {
tv[0].Usec = _UTIME_OMIT
} else {
n := a.UnixNano()
tv[0] = syscall.NsecToTimeval(n)
}
if m == nil {
tv[1].Usec = _UTIME_OMIT
} else {
n := m.UnixNano()
tv[1] = syscall.NsecToTimeval(n)
}
f.lock.Lock()
err := syscall.Futimes(int(f.File.Fd()), tv)
f.lock.Unlock()
return fuse.ToStatus(err)
}
...@@ -2,7 +2,6 @@ package nodefs ...@@ -2,7 +2,6 @@ package nodefs
import ( import (
"syscall" "syscall"
"time"
"github.com/hanwen/go-fuse/fuse" "github.com/hanwen/go-fuse/fuse"
) )
...@@ -16,28 +15,3 @@ func (f *loopbackFile) Allocate(off uint64, sz uint64, mode uint32) fuse.Status ...@@ -16,28 +15,3 @@ func (f *loopbackFile) Allocate(off uint64, sz uint64, mode uint32) fuse.Status
} }
return fuse.OK return fuse.OK
} }
const _UTIME_NOW = ((1 << 30) - 1)
const _UTIME_OMIT = ((1 << 30) - 2)
func (f *loopbackFile) Utimens(a *time.Time, m *time.Time) fuse.Status {
tv := make([]syscall.Timeval, 2)
if a == nil {
tv[0].Usec = _UTIME_OMIT
} else {
n := a.UnixNano()
tv[0] = syscall.NsecToTimeval(n)
}
if m == nil {
tv[1].Usec = _UTIME_OMIT
} else {
n := a.UnixNano()
tv[1] = syscall.NsecToTimeval(n)
}
f.lock.Lock()
err := syscall.Futimes(int(f.File.Fd()), tv)
f.lock.Unlock()
return fuse.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