Commit 6e5a2cc2 authored by Kirill Smelkov's avatar Kirill Smelkov

fixup! Y nodefs: Propagate context to File methods

Darwin build was failing:

    $ ./all.bash
    + go build ./...
    + GOOS=darwin
    + go build ./fuse/... ./fs/... ./example/loopback/...
    # github.com/hanwen/go-fuse/fuse/nodefs
    fuse/nodefs/files.go:99:9: cannot use &loopbackFile{…} (value of type *loopbackFile) as File value in return statement: *loopbackFile does not implement File (wrong type for method Allocate)
                    have Allocate(uint64, uint64, uint32) fuse.Status
                    want Allocate(uint64, uint64, uint32, *fuse.Context) (fuse.Status)
    fuse/nodefs/files_darwin.go:87:22: not enough arguments in call to f.GetAttr
            have (*fuse.Attr)
            want (*fuse.Attr, *fuse.Context)
parent 643585d7
......@@ -13,7 +13,7 @@ import (
"github.com/hanwen/go-fuse/v2/internal/utimens"
)
func (f *loopbackFile) Allocate(off uint64, sz uint64, mode uint32) fuse.Status {
func (f *loopbackFile) Allocate(off uint64, sz uint64, mode uint32, ctx *fuse.Context) fuse.Status {
// TODO: Handle `mode` parameter.
// From `man fcntl` on OSX:
......@@ -57,6 +57,7 @@ func (f *loopbackFile) Allocate(off uint64, sz uint64, mode uint32) fuse.Status
// Linux version for reference:
// err := syscall.Fallocate(int(f.File.Fd()), mode, int64(off), int64(sz))
// XXX cancel not propagated
f.lock.Lock()
_, _, errno := syscall.Syscall(syscall.SYS_FCNTL, f.File.Fd(), uintptr(syscall.F_PREALLOCATE), uintptr(unsafe.Pointer(&k)))
f.lock.Unlock()
......@@ -80,18 +81,18 @@ func timeToTimeval(t *time.Time) syscall.Timeval {
// MacOS before High Sierra lacks utimensat() and UTIME_OMIT.
// We emulate using utimes() and extra GetAttr() calls.
func (f *loopbackFile) Utimens(a *time.Time, m *time.Time) fuse.Status {
func (f *loopbackFile) Utimens(a *time.Time, m *time.Time, ctx *fuse.Context) fuse.Status {
var attr fuse.Attr
if a == nil || m == nil {
var status fuse.Status
status = f.GetAttr(&attr)
status = f.GetAttr(&attr, ctx)
if !status.Ok() {
return status
}
}
tv := utimens.Fill(a, m, &attr)
f.lock.Lock()
err := syscall.Futimes(int(f.File.Fd()), tv)
err := syscall.Futimes(int(f.File.Fd()), tv) // XXX cancel not propagated
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