Commit 2275cf72 authored by Kirill Smelkov's avatar Kirill Smelkov

Y nodefs: Propagate context to File methods

So that e.g. File.Read could be canceled.

This is already so in fs/ package. However WCFS in Wendelin.core still
uses older nodefs package, and for now it was faster to teach old
nodefs.File about cancel propagation.

References:

kirr/wendelin.core@b17aeb8c
kirr/wendelin.core@f05271b1
kirr/wendelin.core@5ba816da
kirr/go123@7ad867a3
kirr/go123@0bdac628
kirr/go123@d2dc6c09
parent fe141f38
...@@ -144,34 +144,34 @@ type File interface { ...@@ -144,34 +144,34 @@ type File interface {
// the inner file here. // the inner file here.
InnerFile() File InnerFile() File
Read(dest []byte, off int64) (fuse.ReadResult, fuse.Status) Read(dest []byte, off int64, ctx *fuse.Context) (fuse.ReadResult, fuse.Status)
Write(data []byte, off int64) (written uint32, code fuse.Status) Write(data []byte, off int64, ctx *fuse.Context) (written uint32, code fuse.Status)
// File locking // File locking
GetLk(owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (code fuse.Status) GetLk(owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock, ctx *fuse.Context) (code fuse.Status)
SetLk(owner uint64, lk *fuse.FileLock, flags uint32) (code fuse.Status) SetLk(owner uint64, lk *fuse.FileLock, flags uint32, ctx *fuse.Context) (code fuse.Status)
SetLkw(owner uint64, lk *fuse.FileLock, flags uint32) (code fuse.Status) SetLkw(owner uint64, lk *fuse.FileLock, flags uint32, ctx *fuse.Context) (code fuse.Status)
// Flush is called for close() call on a file descriptor. In // Flush is called for close() call on a file descriptor. In
// case of duplicated descriptor, it may be called more than // case of duplicated descriptor, it may be called more than
// once for a file. // once for a file.
Flush() fuse.Status Flush(ctx *fuse.Context) fuse.Status
// This is called to before the file handle is forgotten. This // This is called to before the file handle is forgotten. This
// method has no return value, so nothing can synchronizes on // method has no return value, so nothing can synchronizes on
// the call. Any cleanup that requires specific synchronization or // the call. Any cleanup that requires specific synchronization or
// could fail with I/O errors should happen in Flush instead. // could fail with I/O errors should happen in Flush instead.
Release() Release() // XXX +ctx ?
Fsync(flags int) (code fuse.Status) Fsync(flags int, ctx *fuse.Context) (code fuse.Status)
// The methods below may be called on closed files, due to // The methods below may be called on closed files, due to
// concurrency. In that case, you should return EBADF. // concurrency. In that case, you should return EBADF.
Truncate(size uint64) fuse.Status Truncate(size uint64, ctx *fuse.Context) fuse.Status
GetAttr(out *fuse.Attr) fuse.Status GetAttr(out *fuse.Attr, ctx *fuse.Context) fuse.Status
Chown(uid uint32, gid uint32) fuse.Status Chown(uid uint32, gid uint32, ctx *fuse.Context) fuse.Status
Chmod(perms uint32) fuse.Status Chmod(perms uint32, ctx *fuse.Context) fuse.Status
Utimens(atime *time.Time, mtime *time.Time) fuse.Status Utimens(atime *time.Time, mtime *time.Time, ctx *fuse.Context) fuse.Status
Allocate(off uint64, size uint64, mode uint32) (code fuse.Status) Allocate(off uint64, size uint64, mode uint32, ctx *fuse.Context) (code fuse.Status)
} }
// Wrap a File return in this to set FUSE flags. Also used internally // Wrap a File return in this to set FUSE flags. Also used internally
......
...@@ -29,27 +29,27 @@ func (f *defaultFile) String() string { ...@@ -29,27 +29,27 @@ func (f *defaultFile) String() string {
return "defaultFile" return "defaultFile"
} }
func (f *defaultFile) Read(buf []byte, off int64) (fuse.ReadResult, fuse.Status) { func (f *defaultFile) Read(buf []byte, off int64, ctx *fuse.Context) (fuse.ReadResult, fuse.Status) {
return nil, fuse.ENOSYS return nil, fuse.ENOSYS
} }
func (f *defaultFile) Write(data []byte, off int64) (uint32, fuse.Status) { func (f *defaultFile) Write(data []byte, off int64, ctx *fuse.Context) (uint32, fuse.Status) {
return 0, fuse.ENOSYS return 0, fuse.ENOSYS
} }
func (f *defaultFile) GetLk(owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (code fuse.Status) { func (f *defaultFile) GetLk(owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock, ctx *fuse.Context) (code fuse.Status) {
return fuse.ENOSYS return fuse.ENOSYS
} }
func (f *defaultFile) SetLk(owner uint64, lk *fuse.FileLock, flags uint32) (code fuse.Status) { func (f *defaultFile) SetLk(owner uint64, lk *fuse.FileLock, flags uint32, ctx *fuse.Context) (code fuse.Status) {
return fuse.ENOSYS return fuse.ENOSYS
} }
func (f *defaultFile) SetLkw(owner uint64, lk *fuse.FileLock, flags uint32) (code fuse.Status) { func (f *defaultFile) SetLkw(owner uint64, lk *fuse.FileLock, flags uint32, ctx *fuse.Context) (code fuse.Status) {
return fuse.ENOSYS return fuse.ENOSYS
} }
func (f *defaultFile) Flush() fuse.Status { func (f *defaultFile) Flush(ctx *fuse.Context) fuse.Status {
return fuse.OK return fuse.OK
} }
...@@ -57,30 +57,30 @@ func (f *defaultFile) Release() { ...@@ -57,30 +57,30 @@ func (f *defaultFile) Release() {
} }
func (f *defaultFile) GetAttr(*fuse.Attr) fuse.Status { func (f *defaultFile) GetAttr(_ *fuse.Attr, ctx *fuse.Context) fuse.Status {
return fuse.ENOSYS return fuse.ENOSYS
} }
func (f *defaultFile) Fsync(flags int) (code fuse.Status) { func (f *defaultFile) Fsync(flags int, ctx *fuse.Context) (code fuse.Status) {
return fuse.ENOSYS return fuse.ENOSYS
} }
func (f *defaultFile) Utimens(atime *time.Time, mtime *time.Time) fuse.Status { func (f *defaultFile) Utimens(atime *time.Time, mtime *time.Time, ctx *fuse.Context) fuse.Status {
return fuse.ENOSYS return fuse.ENOSYS
} }
func (f *defaultFile) Truncate(size uint64) fuse.Status { func (f *defaultFile) Truncate(size uint64, ctx *fuse.Context) fuse.Status {
return fuse.ENOSYS return fuse.ENOSYS
} }
func (f *defaultFile) Chown(uid uint32, gid uint32) fuse.Status { func (f *defaultFile) Chown(uid uint32, gid uint32, ctx *fuse.Context) fuse.Status {
return fuse.ENOSYS return fuse.ENOSYS
} }
func (f *defaultFile) Chmod(perms uint32) fuse.Status { func (f *defaultFile) Chmod(perms uint32, ctx *fuse.Context) fuse.Status {
return fuse.ENOSYS return fuse.ENOSYS
} }
func (f *defaultFile) Allocate(off uint64, size uint64, mode uint32) (code fuse.Status) { func (f *defaultFile) Allocate(off uint64, size uint64, mode uint32, ctx *fuse.Context) (code fuse.Status) {
return fuse.ENOSYS return fuse.ENOSYS
} }
...@@ -127,7 +127,7 @@ func (n *defaultNode) ListXAttr(context *fuse.Context) (attrs []string, code fus ...@@ -127,7 +127,7 @@ func (n *defaultNode) ListXAttr(context *fuse.Context) (attrs []string, code fus
func (n *defaultNode) GetAttr(out *fuse.Attr, file File, context *fuse.Context) (code fuse.Status) { func (n *defaultNode) GetAttr(out *fuse.Attr, file File, context *fuse.Context) (code fuse.Status) {
if file != nil { if file != nil {
return file.GetAttr(out) return file.GetAttr(out, context)
} }
if n.Inode().IsDir() { if n.Inode().IsDir() {
out.Mode = fuse.S_IFDIR | 0755 out.Mode = fuse.S_IFDIR | 0755
...@@ -171,14 +171,14 @@ func (n *defaultNode) Fallocate(file File, off uint64, size uint64, mode uint32, ...@@ -171,14 +171,14 @@ func (n *defaultNode) Fallocate(file File, off uint64, size uint64, mode uint32,
func (n *defaultNode) Read(file File, dest []byte, off int64, context *fuse.Context) (fuse.ReadResult, fuse.Status) { func (n *defaultNode) Read(file File, dest []byte, off int64, context *fuse.Context) (fuse.ReadResult, fuse.Status) {
if file != nil { if file != nil {
return file.Read(dest, off) return file.Read(dest, off, context)
} }
return nil, fuse.ENOSYS return nil, fuse.ENOSYS
} }
func (n *defaultNode) Write(file File, data []byte, off int64, context *fuse.Context) (written uint32, code fuse.Status) { func (n *defaultNode) Write(file File, data []byte, off int64, context *fuse.Context) (written uint32, code fuse.Status) {
if file != nil { if file != nil {
return file.Write(data, off) return file.Write(data, off, context)
} }
return 0, fuse.ENOSYS return 0, fuse.ENOSYS
} }
...@@ -30,7 +30,7 @@ func (f *dataFile) String() string { ...@@ -30,7 +30,7 @@ func (f *dataFile) String() string {
return fmt.Sprintf("dataFile(%x)", f.data[:l]) return fmt.Sprintf("dataFile(%x)", f.data[:l])
} }
func (f *dataFile) GetAttr(out *fuse.Attr) fuse.Status { func (f *dataFile) GetAttr(out *fuse.Attr, ctx *fuse.Context) fuse.Status {
out.Mode = fuse.S_IFREG | 0644 out.Mode = fuse.S_IFREG | 0644
out.Size = uint64(len(f.data)) out.Size = uint64(len(f.data))
return fuse.OK return fuse.OK
...@@ -43,7 +43,7 @@ func NewDataFile(data []byte) File { ...@@ -43,7 +43,7 @@ func NewDataFile(data []byte) File {
return f return f
} }
func (f *dataFile) Read(buf []byte, off int64) (res fuse.ReadResult, code fuse.Status) { func (f *dataFile) Read(buf []byte, off int64, ctx *fuse.Context) (res fuse.ReadResult, code fuse.Status) {
end := int(off) + int(len(buf)) end := int(off) + int(len(buf))
if end > len(f.data) { if end > len(f.data) {
end = len(f.data) end = len(f.data)
...@@ -64,7 +64,7 @@ func NewDevNullFile() File { ...@@ -64,7 +64,7 @@ func NewDevNullFile() File {
} }
} }
func (f *devNullFile) Allocate(off uint64, size uint64, mode uint32) (code fuse.Status) { func (f *devNullFile) Allocate(off uint64, size uint64, mode uint32, ctx *fuse.Context) (code fuse.Status) {
return fuse.OK return fuse.OK
} }
...@@ -72,23 +72,23 @@ func (f *devNullFile) String() string { ...@@ -72,23 +72,23 @@ func (f *devNullFile) String() string {
return "devNullFile" return "devNullFile"
} }
func (f *devNullFile) Read(buf []byte, off int64) (fuse.ReadResult, fuse.Status) { func (f *devNullFile) Read(buf []byte, off int64, ctx *fuse.Context) (fuse.ReadResult, fuse.Status) {
return fuse.ReadResultData(nil), fuse.OK return fuse.ReadResultData(nil), fuse.OK
} }
func (f *devNullFile) Write(content []byte, off int64) (uint32, fuse.Status) { func (f *devNullFile) Write(content []byte, off int64, ctx *fuse.Context) (uint32, fuse.Status) {
return uint32(len(content)), fuse.OK return uint32(len(content)), fuse.OK
} }
func (f *devNullFile) Flush() fuse.Status { func (f *devNullFile) Flush(ctx *fuse.Context) fuse.Status {
return fuse.OK return fuse.OK
} }
func (f *devNullFile) Fsync(flags int) (code fuse.Status) { func (f *devNullFile) Fsync(flags int, ctx *fuse.Context) (code fuse.Status) {
return fuse.OK return fuse.OK
} }
func (f *devNullFile) Truncate(size uint64) (code fuse.Status) { func (f *devNullFile) Truncate(size uint64, ctx *fuse.Context) (code fuse.Status) {
return fuse.OK return fuse.OK
} }
...@@ -121,7 +121,7 @@ func (f *loopbackFile) String() string { ...@@ -121,7 +121,7 @@ func (f *loopbackFile) String() string {
return fmt.Sprintf("loopbackFile(%s)", f.File.Name()) return fmt.Sprintf("loopbackFile(%s)", f.File.Name())
} }
func (f *loopbackFile) Read(buf []byte, off int64) (res fuse.ReadResult, code fuse.Status) { func (f *loopbackFile) Read(buf []byte, off int64, ctx *fuse.Context) (res fuse.ReadResult, code fuse.Status) {
f.lock.Lock() f.lock.Lock()
// This is not racy by virtue of the kernel properly // This is not racy by virtue of the kernel properly
// synchronizing the open/write/close. // synchronizing the open/write/close.
...@@ -130,7 +130,7 @@ func (f *loopbackFile) Read(buf []byte, off int64) (res fuse.ReadResult, code fu ...@@ -130,7 +130,7 @@ func (f *loopbackFile) Read(buf []byte, off int64) (res fuse.ReadResult, code fu
return r, fuse.OK return r, fuse.OK
} }
func (f *loopbackFile) Write(data []byte, off int64) (uint32, fuse.Status) { func (f *loopbackFile) Write(data []byte, off int64, ctx *fuse.Context) (uint32, fuse.Status) {
f.lock.Lock() f.lock.Lock()
n, err := f.File.WriteAt(data, off) n, err := f.File.WriteAt(data, off)
f.lock.Unlock() f.lock.Unlock()
...@@ -143,7 +143,7 @@ func (f *loopbackFile) Release() { ...@@ -143,7 +143,7 @@ func (f *loopbackFile) Release() {
f.lock.Unlock() f.lock.Unlock()
} }
func (f *loopbackFile) Flush() fuse.Status { func (f *loopbackFile) Flush(ctx *fuse.Context) fuse.Status {
f.lock.Lock() f.lock.Lock()
// Since Flush() may be called for each dup'd fd, we don't // Since Flush() may be called for each dup'd fd, we don't
...@@ -159,7 +159,7 @@ func (f *loopbackFile) Flush() fuse.Status { ...@@ -159,7 +159,7 @@ func (f *loopbackFile) Flush() fuse.Status {
return fuse.ToStatus(err) return fuse.ToStatus(err)
} }
func (f *loopbackFile) Fsync(flags int) (code fuse.Status) { func (f *loopbackFile) Fsync(flags int, ctx *fuse.Context) (code fuse.Status) {
f.lock.Lock() f.lock.Lock()
r := fuse.ToStatus(syscall.Fsync(int(f.File.Fd()))) r := fuse.ToStatus(syscall.Fsync(int(f.File.Fd())))
f.lock.Unlock() f.lock.Unlock()
...@@ -173,7 +173,7 @@ const ( ...@@ -173,7 +173,7 @@ const (
F_OFD_SETLKW = 38 F_OFD_SETLKW = 38
) )
func (f *loopbackFile) GetLk(owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (code fuse.Status) { func (f *loopbackFile) GetLk(owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock, ctx *fuse.Context) (code fuse.Status) {
flk := syscall.Flock_t{} flk := syscall.Flock_t{}
lk.ToFlockT(&flk) lk.ToFlockT(&flk)
code = fuse.ToStatus(syscall.FcntlFlock(f.File.Fd(), F_OFD_GETLK, &flk)) code = fuse.ToStatus(syscall.FcntlFlock(f.File.Fd(), F_OFD_GETLK, &flk))
...@@ -181,11 +181,11 @@ func (f *loopbackFile) GetLk(owner uint64, lk *fuse.FileLock, flags uint32, out ...@@ -181,11 +181,11 @@ func (f *loopbackFile) GetLk(owner uint64, lk *fuse.FileLock, flags uint32, out
return return
} }
func (f *loopbackFile) SetLk(owner uint64, lk *fuse.FileLock, flags uint32) (code fuse.Status) { func (f *loopbackFile) SetLk(owner uint64, lk *fuse.FileLock, flags uint32, ctx *fuse.Context) (code fuse.Status) {
return f.setLock(owner, lk, flags, false) return f.setLock(owner, lk, flags, false)
} }
func (f *loopbackFile) SetLkw(owner uint64, lk *fuse.FileLock, flags uint32) (code fuse.Status) { func (f *loopbackFile) SetLkw(owner uint64, lk *fuse.FileLock, flags uint32, ctx *fuse.Context) (code fuse.Status) {
return f.setLock(owner, lk, flags, true) return f.setLock(owner, lk, flags, true)
} }
...@@ -219,7 +219,7 @@ func (f *loopbackFile) setLock(owner uint64, lk *fuse.FileLock, flags uint32, bl ...@@ -219,7 +219,7 @@ func (f *loopbackFile) setLock(owner uint64, lk *fuse.FileLock, flags uint32, bl
} }
} }
func (f *loopbackFile) Truncate(size uint64) fuse.Status { func (f *loopbackFile) Truncate(size uint64, ctx *fuse.Context) fuse.Status {
f.lock.Lock() f.lock.Lock()
r := fuse.ToStatus(syscall.Ftruncate(int(f.File.Fd()), int64(size))) r := fuse.ToStatus(syscall.Ftruncate(int(f.File.Fd()), int64(size)))
f.lock.Unlock() f.lock.Unlock()
...@@ -227,7 +227,7 @@ func (f *loopbackFile) Truncate(size uint64) fuse.Status { ...@@ -227,7 +227,7 @@ func (f *loopbackFile) Truncate(size uint64) fuse.Status {
return r return r
} }
func (f *loopbackFile) Chmod(mode uint32) fuse.Status { func (f *loopbackFile) Chmod(mode uint32, ctx *fuse.Context) fuse.Status {
f.lock.Lock() f.lock.Lock()
r := fuse.ToStatus(f.File.Chmod(os.FileMode(mode))) r := fuse.ToStatus(f.File.Chmod(os.FileMode(mode)))
f.lock.Unlock() f.lock.Unlock()
...@@ -235,7 +235,7 @@ func (f *loopbackFile) Chmod(mode uint32) fuse.Status { ...@@ -235,7 +235,7 @@ func (f *loopbackFile) Chmod(mode uint32) fuse.Status {
return r return r
} }
func (f *loopbackFile) Chown(uid uint32, gid uint32) fuse.Status { func (f *loopbackFile) Chown(uid uint32, gid uint32, ctx *fuse.Context) fuse.Status {
f.lock.Lock() f.lock.Lock()
r := fuse.ToStatus(f.File.Chown(int(uid), int(gid))) r := fuse.ToStatus(f.File.Chown(int(uid), int(gid)))
f.lock.Unlock() f.lock.Unlock()
...@@ -243,7 +243,7 @@ func (f *loopbackFile) Chown(uid uint32, gid uint32) fuse.Status { ...@@ -243,7 +243,7 @@ func (f *loopbackFile) Chown(uid uint32, gid uint32) fuse.Status {
return r return r
} }
func (f *loopbackFile) GetAttr(a *fuse.Attr) fuse.Status { func (f *loopbackFile) GetAttr(a *fuse.Attr, ctx *fuse.Context) fuse.Status {
st := syscall.Stat_t{} st := syscall.Stat_t{}
f.lock.Lock() f.lock.Lock()
err := syscall.Fstat(int(f.File.Fd()), &st) err := syscall.Fstat(int(f.File.Fd()), &st)
...@@ -279,26 +279,26 @@ func (f *readOnlyFile) String() string { ...@@ -279,26 +279,26 @@ func (f *readOnlyFile) String() string {
return fmt.Sprintf("readOnlyFile(%s)", f.File.String()) return fmt.Sprintf("readOnlyFile(%s)", f.File.String())
} }
func (f *readOnlyFile) Write(data []byte, off int64) (uint32, fuse.Status) { func (f *readOnlyFile) Write(data []byte, off int64, ctx *fuse.Context) (uint32, fuse.Status) {
return 0, fuse.EPERM return 0, fuse.EPERM
} }
func (f *readOnlyFile) Fsync(flag int) (code fuse.Status) { func (f *readOnlyFile) Fsync(flag int, ctx *fuse.Context) (code fuse.Status) {
return fuse.OK return fuse.OK
} }
func (f *readOnlyFile) Truncate(size uint64) fuse.Status { func (f *readOnlyFile) Truncate(size uint64, ctx *fuse.Context) fuse.Status {
return fuse.EPERM return fuse.EPERM
} }
func (f *readOnlyFile) Chmod(mode uint32) fuse.Status { func (f *readOnlyFile) Chmod(mode uint32, ctx *fuse.Context) fuse.Status {
return fuse.EPERM return fuse.EPERM
} }
func (f *readOnlyFile) Chown(uid uint32, gid uint32) fuse.Status { func (f *readOnlyFile) Chown(uid uint32, gid uint32, ctx *fuse.Context) fuse.Status {
return fuse.EPERM return fuse.EPERM
} }
func (f *readOnlyFile) Allocate(off uint64, sz uint64, mode uint32) fuse.Status { func (f *readOnlyFile) Allocate(off uint64, sz uint64, mode uint32, ctx *fuse.Context) fuse.Status {
return fuse.EPERM return fuse.EPERM
} }
...@@ -11,9 +11,9 @@ import ( ...@@ -11,9 +11,9 @@ import (
"github.com/hanwen/go-fuse/v2/fuse" "github.com/hanwen/go-fuse/v2/fuse"
) )
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 {
f.lock.Lock() f.lock.Lock()
err := syscall.Fallocate(int(f.File.Fd()), mode, int64(off), int64(sz)) err := syscall.Fallocate(int(f.File.Fd()), mode, int64(off), int64(sz)) // XXX cancel not propagated
f.lock.Unlock() f.lock.Unlock()
if err != nil { if err != nil {
return fuse.ToStatus(err) return fuse.ToStatus(err)
...@@ -22,12 +22,12 @@ func (f *loopbackFile) Allocate(off uint64, sz uint64, mode uint32) fuse.Status ...@@ -22,12 +22,12 @@ func (f *loopbackFile) Allocate(off uint64, sz uint64, mode uint32) fuse.Status
} }
// Utimens - file handle based version of loopbackFileSystem.Utimens() // Utimens - file handle based version of loopbackFileSystem.Utimens()
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 ts [2]syscall.Timespec var ts [2]syscall.Timespec
ts[0] = fuse.UtimeToTimespec(a) ts[0] = fuse.UtimeToTimespec(a)
ts[1] = fuse.UtimeToTimespec(m) ts[1] = fuse.UtimeToTimespec(m)
f.lock.Lock() f.lock.Lock()
err := futimens(int(f.File.Fd()), &ts) err := futimens(int(f.File.Fd()), &ts) // XXX cancel not propagated
f.lock.Unlock() f.lock.Unlock()
return fuse.ToStatus(err) return fuse.ToStatus(err)
} }
...@@ -26,7 +26,7 @@ func TestLoopbackFileUtimens(t *testing.T) { ...@@ -26,7 +26,7 @@ func TestLoopbackFileUtimens(t *testing.T) {
f := NewLoopbackFile(f2) f := NewLoopbackFile(f2)
utimensFn := func(atime *time.Time, mtime *time.Time) fuse.Status { utimensFn := func(atime *time.Time, mtime *time.Time) fuse.Status {
return f.Utimens(atime, mtime) return f.Utimens(atime, mtime, &fuse.Context{Cancel: nil})
} }
testutil.TestLoopbackUtimens(t, path, utimensFn) testutil.TestLoopbackUtimens(t, path, utimensFn)
} }
...@@ -28,7 +28,7 @@ func (c *rawBridge) Fsync(cancel <-chan struct{}, input *fuse.FsyncIn) fuse.Stat ...@@ -28,7 +28,7 @@ func (c *rawBridge) Fsync(cancel <-chan struct{}, input *fuse.FsyncIn) fuse.Stat
opened := node.mount.getOpenedFile(input.Fh) opened := node.mount.getOpenedFile(input.Fh)
if opened != nil { if opened != nil {
return opened.WithFlags.File.Fsync(int(input.FsyncFlags)) return opened.WithFlags.File.Fsync(int(input.FsyncFlags), &fuse.Context{Caller: input.Caller, Cancel: cancel})
} }
return fuse.ENOSYS return fuse.ENOSYS
...@@ -490,7 +490,7 @@ func (c *rawBridge) Flush(cancel <-chan struct{}, input *fuse.FlushIn) fuse.Stat ...@@ -490,7 +490,7 @@ func (c *rawBridge) Flush(cancel <-chan struct{}, input *fuse.FlushIn) fuse.Stat
opened := node.mount.getOpenedFile(input.Fh) opened := node.mount.getOpenedFile(input.Fh)
if opened != nil { if opened != nil {
return opened.WithFlags.File.Flush() return opened.WithFlags.File.Flush(&fuse.Context{Caller: input.Caller, Cancel: cancel})
} }
return fuse.OK return fuse.OK
} }
......
...@@ -36,40 +36,40 @@ func (f *lockingFile) String() string { ...@@ -36,40 +36,40 @@ func (f *lockingFile) String() string {
return fmt.Sprintf("lockingFile(%s)", f.file.String()) return fmt.Sprintf("lockingFile(%s)", f.file.String())
} }
func (f *lockingFile) Read(buf []byte, off int64) (fuse.ReadResult, fuse.Status) { func (f *lockingFile) Read(buf []byte, off int64, ctx *fuse.Context) (fuse.ReadResult, fuse.Status) {
f.mu.Lock() f.mu.Lock()
defer f.mu.Unlock() defer f.mu.Unlock()
return f.file.Read(buf, off) return f.file.Read(buf, off, ctx)
} }
func (f *lockingFile) Write(data []byte, off int64) (uint32, fuse.Status) { func (f *lockingFile) Write(data []byte, off int64, ctx *fuse.Context) (uint32, fuse.Status) {
f.mu.Lock() f.mu.Lock()
defer f.mu.Unlock() defer f.mu.Unlock()
return f.file.Write(data, off) return f.file.Write(data, off, ctx)
} }
func (f *lockingFile) Flush() fuse.Status { func (f *lockingFile) Flush(ctx *fuse.Context) fuse.Status {
f.mu.Lock() f.mu.Lock()
defer f.mu.Unlock() defer f.mu.Unlock()
return f.file.Flush() return f.file.Flush(ctx)
} }
func (f *lockingFile) GetLk(owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock) (code fuse.Status) { func (f *lockingFile) GetLk(owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock, ctx *fuse.Context) (code fuse.Status) {
f.mu.Lock() f.mu.Lock()
defer f.mu.Unlock() defer f.mu.Unlock()
return f.file.GetLk(owner, lk, flags, out) return f.file.GetLk(owner, lk, flags, out, ctx)
} }
func (f *lockingFile) SetLk(owner uint64, lk *fuse.FileLock, flags uint32) (code fuse.Status) { func (f *lockingFile) SetLk(owner uint64, lk *fuse.FileLock, flags uint32, ctx *fuse.Context) (code fuse.Status) {
f.mu.Lock() f.mu.Lock()
defer f.mu.Unlock() defer f.mu.Unlock()
return f.file.SetLk(owner, lk, flags) return f.file.SetLk(owner, lk, flags, ctx)
} }
func (f *lockingFile) SetLkw(owner uint64, lk *fuse.FileLock, flags uint32) (code fuse.Status) { func (f *lockingFile) SetLkw(owner uint64, lk *fuse.FileLock, flags uint32, ctx *fuse.Context) (code fuse.Status) {
f.mu.Lock() f.mu.Lock()
defer f.mu.Unlock() defer f.mu.Unlock()
return f.file.SetLkw(owner, lk, flags) return f.file.SetLkw(owner, lk, flags, ctx)
} }
func (f *lockingFile) Release() { func (f *lockingFile) Release() {
...@@ -78,44 +78,44 @@ func (f *lockingFile) Release() { ...@@ -78,44 +78,44 @@ func (f *lockingFile) Release() {
f.file.Release() f.file.Release()
} }
func (f *lockingFile) GetAttr(a *fuse.Attr) fuse.Status { func (f *lockingFile) GetAttr(a *fuse.Attr, ctx *fuse.Context) fuse.Status {
f.mu.Lock() f.mu.Lock()
defer f.mu.Unlock() defer f.mu.Unlock()
return f.file.GetAttr(a) return f.file.GetAttr(a, ctx)
} }
func (f *lockingFile) Fsync(flags int) (code fuse.Status) { func (f *lockingFile) Fsync(flags int, ctx *fuse.Context) (code fuse.Status) {
f.mu.Lock() f.mu.Lock()
defer f.mu.Unlock() defer f.mu.Unlock()
return f.file.Fsync(flags) return f.file.Fsync(flags, ctx)
} }
func (f *lockingFile) Utimens(atime *time.Time, mtime *time.Time) fuse.Status { func (f *lockingFile) Utimens(atime *time.Time, mtime *time.Time, ctx *fuse.Context) fuse.Status {
f.mu.Lock() f.mu.Lock()
defer f.mu.Unlock() defer f.mu.Unlock()
return f.file.Utimens(atime, mtime) return f.file.Utimens(atime, mtime, ctx)
} }
func (f *lockingFile) Truncate(size uint64) fuse.Status { func (f *lockingFile) Truncate(size uint64, ctx *fuse.Context) fuse.Status {
f.mu.Lock() f.mu.Lock()
defer f.mu.Unlock() defer f.mu.Unlock()
return f.file.Truncate(size) return f.file.Truncate(size, ctx)
} }
func (f *lockingFile) Chown(uid uint32, gid uint32) fuse.Status { func (f *lockingFile) Chown(uid uint32, gid uint32, ctx *fuse.Context) fuse.Status {
f.mu.Lock() f.mu.Lock()
defer f.mu.Unlock() defer f.mu.Unlock()
return f.file.Chown(uid, gid) return f.file.Chown(uid, gid, ctx)
} }
func (f *lockingFile) Chmod(perms uint32) fuse.Status { func (f *lockingFile) Chmod(perms uint32, ctx *fuse.Context) fuse.Status {
f.mu.Lock() f.mu.Lock()
defer f.mu.Unlock() defer f.mu.Unlock()
return f.file.Chmod(perms) return f.file.Chmod(perms, ctx)
} }
func (f *lockingFile) Allocate(off uint64, size uint64, mode uint32) (code fuse.Status) { func (f *lockingFile) Allocate(off uint64, size uint64, mode uint32, ctx *fuse.Context) (code fuse.Status) {
f.mu.Lock() f.mu.Lock()
defer f.mu.Unlock() defer f.mu.Unlock()
return f.file.Allocate(off, size, mode) return f.file.Allocate(off, size, mode, ctx)
} }
...@@ -162,8 +162,8 @@ func (n *memNodeFile) InnerFile() File { ...@@ -162,8 +162,8 @@ func (n *memNodeFile) InnerFile() File {
return n.File return n.File
} }
func (n *memNodeFile) Flush() fuse.Status { func (n *memNodeFile) Flush(ctx *fuse.Context) fuse.Status {
code := n.File.Flush() code := n.File.Flush(ctx)
if !code.Ok() { if !code.Ok() {
return code return code
...@@ -205,7 +205,7 @@ func (n *memNode) GetAttr(fi *fuse.Attr, file File, context *fuse.Context) (code ...@@ -205,7 +205,7 @@ func (n *memNode) GetAttr(fi *fuse.Attr, file File, context *fuse.Context) (code
func (n *memNode) Truncate(file File, size uint64, context *fuse.Context) (code fuse.Status) { func (n *memNode) Truncate(file File, size uint64, context *fuse.Context) (code fuse.Status) {
if file != nil { if file != nil {
code = file.Truncate(size) code = file.Truncate(size, context)
} else { } else {
err := os.Truncate(n.filename(), int64(size)) err := os.Truncate(n.filename(), int64(size))
code = fuse.ToStatus(err) code = fuse.ToStatus(err)
......
...@@ -16,7 +16,7 @@ func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string, context *fuse. ...@@ -16,7 +16,7 @@ func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string, context *fuse.
return code return code
} }
defer src.Release() defer src.Release()
defer src.Flush() defer src.Flush(context)
attr, code := srcFs.GetAttr(srcFile, context) attr, code := srcFs.GetAttr(srcFile, context)
if !code.Ok() { if !code.Ok() {
...@@ -28,12 +28,12 @@ func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string, context *fuse. ...@@ -28,12 +28,12 @@ func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string, context *fuse.
return code return code
} }
defer dst.Release() defer dst.Release()
defer dst.Flush() defer dst.Flush(context)
buf := make([]byte, 128*(1<<10)) buf := make([]byte, 128*(1<<10))
off := int64(0) off := int64(0)
for { for {
res, code := src.Read(buf, off) res, code := src.Read(buf, off, context)
if !code.Ok() { if !code.Ok() {
return code return code
} }
...@@ -45,7 +45,7 @@ func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string, context *fuse. ...@@ -45,7 +45,7 @@ func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string, context *fuse.
if len(data) == 0 { if len(data) == 0 {
break break
} }
n, code := dst.Write(data, off) n, code := dst.Write(data, off, context)
if !code.Ok() { if !code.Ok() {
return code return code
} }
......
...@@ -404,7 +404,7 @@ func (n *pathInode) ListXAttr(context *fuse.Context) (attrs []string, code fuse. ...@@ -404,7 +404,7 @@ func (n *pathInode) ListXAttr(context *fuse.Context) (attrs []string, code fuse.
} }
func (n *pathInode) Flush(file nodefs.File, openFlags uint32, context *fuse.Context) (code fuse.Status) { func (n *pathInode) Flush(file nodefs.File, openFlags uint32, context *fuse.Context) (code fuse.Status) {
return file.Flush() return file.Flush(context)
} }
func (n *pathInode) OpenDir(context *fuse.Context) ([]fuse.DirEntry, fuse.Status) { func (n *pathInode) OpenDir(context *fuse.Context) ([]fuse.DirEntry, fuse.Status) {
...@@ -592,7 +592,7 @@ func (n *pathInode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Cont ...@@ -592,7 +592,7 @@ func (n *pathInode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Cont
} }
// If we have found an open file, try to fstat it. // If we have found an open file, try to fstat it.
if file != nil { if file != nil {
code = file.GetAttr(out) code = file.GetAttr(out, context)
if code.Ok() { if code.Ok() {
return code return code
} }
...@@ -629,7 +629,7 @@ func (n *pathInode) Chmod(file nodefs.File, perms uint32, context *fuse.Context) ...@@ -629,7 +629,7 @@ func (n *pathInode) Chmod(file nodefs.File, perms uint32, context *fuse.Context)
// Note that Linux currently (Linux 4.4) DOES NOT pass a file descriptor // Note that Linux currently (Linux 4.4) DOES NOT pass a file descriptor
// to FUSE for fchmod. We still check because that may change in the future. // to FUSE for fchmod. We still check because that may change in the future.
if file != nil { if file != nil {
code = file.Chmod(perms) code = file.Chmod(perms, context)
if code != fuse.ENOSYS { if code != fuse.ENOSYS {
return code return code
} }
...@@ -637,8 +637,7 @@ func (n *pathInode) Chmod(file nodefs.File, perms uint32, context *fuse.Context) ...@@ -637,8 +637,7 @@ func (n *pathInode) Chmod(file nodefs.File, perms uint32, context *fuse.Context)
files := n.Inode().Files(fuse.O_ANYWRITE) files := n.Inode().Files(fuse.O_ANYWRITE)
for _, f := range files { for _, f := range files {
// TODO - pass context code = f.Chmod(perms, context)
code = f.Chmod(perms)
if code.Ok() { if code.Ok() {
return return
} }
...@@ -654,7 +653,7 @@ func (n *pathInode) Chown(file nodefs.File, uid uint32, gid uint32, context *fus ...@@ -654,7 +653,7 @@ func (n *pathInode) Chown(file nodefs.File, uid uint32, gid uint32, context *fus
// Note that Linux currently (Linux 4.4) DOES NOT pass a file descriptor // Note that Linux currently (Linux 4.4) DOES NOT pass a file descriptor
// to FUSE for fchown. We still check because it may change in the future. // to FUSE for fchown. We still check because it may change in the future.
if file != nil { if file != nil {
code = file.Chown(uid, gid) code = file.Chown(uid, gid, context)
if code != fuse.ENOSYS { if code != fuse.ENOSYS {
return code return code
} }
...@@ -662,8 +661,7 @@ func (n *pathInode) Chown(file nodefs.File, uid uint32, gid uint32, context *fus ...@@ -662,8 +661,7 @@ func (n *pathInode) Chown(file nodefs.File, uid uint32, gid uint32, context *fus
files := n.Inode().Files(fuse.O_ANYWRITE) files := n.Inode().Files(fuse.O_ANYWRITE)
for _, f := range files { for _, f := range files {
// TODO - pass context code = f.Chown(uid, gid, context)
code = f.Chown(uid, gid)
if code.Ok() { if code.Ok() {
return code return code
} }
...@@ -679,7 +677,7 @@ func (n *pathInode) Truncate(file nodefs.File, size uint64, context *fuse.Contex ...@@ -679,7 +677,7 @@ func (n *pathInode) Truncate(file nodefs.File, size uint64, context *fuse.Contex
// A file descriptor was passed in AND the filesystem implements the // A file descriptor was passed in AND the filesystem implements the
// operation on the file handle. This the common case for ftruncate. // operation on the file handle. This the common case for ftruncate.
if file != nil { if file != nil {
code = file.Truncate(size) code = file.Truncate(size, context)
if code != fuse.ENOSYS { if code != fuse.ENOSYS {
return code return code
} }
...@@ -687,8 +685,7 @@ func (n *pathInode) Truncate(file nodefs.File, size uint64, context *fuse.Contex ...@@ -687,8 +685,7 @@ func (n *pathInode) Truncate(file nodefs.File, size uint64, context *fuse.Contex
files := n.Inode().Files(fuse.O_ANYWRITE) files := n.Inode().Files(fuse.O_ANYWRITE)
for _, f := range files { for _, f := range files {
// TODO - pass context code = f.Truncate(size, context)
code = f.Truncate(size)
if code.Ok() { if code.Ok() {
return code return code
} }
...@@ -703,7 +700,7 @@ func (n *pathInode) Utimens(file nodefs.File, atime *time.Time, mtime *time.Time ...@@ -703,7 +700,7 @@ func (n *pathInode) Utimens(file nodefs.File, atime *time.Time, mtime *time.Time
// Note that Linux currently (Linux 4.4) DOES NOT pass a file descriptor // Note that Linux currently (Linux 4.4) DOES NOT pass a file descriptor
// to FUSE for futimens. We still check because it may change in the future. // to FUSE for futimens. We still check because it may change in the future.
if file != nil { if file != nil {
code = file.Utimens(atime, mtime) code = file.Utimens(atime, mtime, context)
if code != fuse.ENOSYS { if code != fuse.ENOSYS {
return code return code
} }
...@@ -711,8 +708,7 @@ func (n *pathInode) Utimens(file nodefs.File, atime *time.Time, mtime *time.Time ...@@ -711,8 +708,7 @@ func (n *pathInode) Utimens(file nodefs.File, atime *time.Time, mtime *time.Time
files := n.Inode().Files(fuse.O_ANYWRITE) files := n.Inode().Files(fuse.O_ANYWRITE)
for _, f := range files { for _, f := range files {
// TODO - pass context code = f.Utimens(atime, mtime, context)
code = f.Utimens(atime, mtime)
if code.Ok() { if code.Ok() {
return code return code
} }
...@@ -725,7 +721,7 @@ func (n *pathInode) Utimens(file nodefs.File, atime *time.Time, mtime *time.Time ...@@ -725,7 +721,7 @@ func (n *pathInode) Utimens(file nodefs.File, atime *time.Time, mtime *time.Time
func (n *pathInode) Fallocate(file nodefs.File, off uint64, size uint64, mode uint32, context *fuse.Context) (code fuse.Status) { func (n *pathInode) Fallocate(file nodefs.File, off uint64, size uint64, mode uint32, context *fuse.Context) (code fuse.Status) {
if file != nil { if file != nil {
code = file.Allocate(off, size, mode) code = file.Allocate(off, size, mode, context)
if code.Ok() { if code.Ok() {
return code return code
} }
...@@ -733,8 +729,7 @@ func (n *pathInode) Fallocate(file nodefs.File, off uint64, size uint64, mode ui ...@@ -733,8 +729,7 @@ func (n *pathInode) Fallocate(file nodefs.File, off uint64, size uint64, mode ui
files := n.Inode().Files(fuse.O_ANYWRITE) files := n.Inode().Files(fuse.O_ANYWRITE)
for _, f := range files { for _, f := range files {
// TODO - pass context code = f.Allocate(off, size, mode, context)
code = f.Allocate(off, size, mode)
if code.Ok() { if code.Ok() {
return code return code
} }
...@@ -745,35 +740,35 @@ func (n *pathInode) Fallocate(file nodefs.File, off uint64, size uint64, mode ui ...@@ -745,35 +740,35 @@ func (n *pathInode) Fallocate(file nodefs.File, off uint64, size uint64, mode ui
func (n *pathInode) Read(file nodefs.File, dest []byte, off int64, context *fuse.Context) (fuse.ReadResult, fuse.Status) { func (n *pathInode) Read(file nodefs.File, dest []byte, off int64, context *fuse.Context) (fuse.ReadResult, fuse.Status) {
if file != nil { if file != nil {
return file.Read(dest, off) return file.Read(dest, off, context)
} }
return nil, fuse.ENOSYS return nil, fuse.ENOSYS
} }
func (n *pathInode) Write(file nodefs.File, data []byte, off int64, context *fuse.Context) (written uint32, code fuse.Status) { func (n *pathInode) Write(file nodefs.File, data []byte, off int64, context *fuse.Context) (written uint32, code fuse.Status) {
if file != nil { if file != nil {
return file.Write(data, off) return file.Write(data, off, context)
} }
return 0, fuse.ENOSYS return 0, fuse.ENOSYS
} }
func (n *pathInode) GetLk(file nodefs.File, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock, context *fuse.Context) (code fuse.Status) { func (n *pathInode) GetLk(file nodefs.File, owner uint64, lk *fuse.FileLock, flags uint32, out *fuse.FileLock, context *fuse.Context) (code fuse.Status) {
if file != nil { if file != nil {
return file.GetLk(owner, lk, flags, out) return file.GetLk(owner, lk, flags, out, context)
} }
return fuse.ENOSYS return fuse.ENOSYS
} }
func (n *pathInode) SetLk(file nodefs.File, owner uint64, lk *fuse.FileLock, flags uint32, context *fuse.Context) (code fuse.Status) { func (n *pathInode) SetLk(file nodefs.File, owner uint64, lk *fuse.FileLock, flags uint32, context *fuse.Context) (code fuse.Status) {
if file != nil { if file != nil {
return file.SetLk(owner, lk, flags) return file.SetLk(owner, lk, flags, context)
} }
return fuse.ENOSYS return fuse.ENOSYS
} }
func (n *pathInode) SetLkw(file nodefs.File, owner uint64, lk *fuse.FileLock, flags uint32, context *fuse.Context) (code fuse.Status) { func (n *pathInode) SetLkw(file nodefs.File, owner uint64, lk *fuse.FileLock, flags uint32, context *fuse.Context) (code fuse.Status) {
if file != nil { if file != nil {
return file.SetLkw(owner, lk, flags) return file.SetLkw(owner, lk, flags, context)
} }
return fuse.ENOSYS return fuse.ENOSYS
} }
...@@ -29,7 +29,7 @@ func (f *MutableDataFile) String() string { ...@@ -29,7 +29,7 @@ func (f *MutableDataFile) String() string {
return "MutableDataFile" return "MutableDataFile"
} }
func (f *MutableDataFile) Read(buf []byte, off int64) (fuse.ReadResult, fuse.Status) { func (f *MutableDataFile) Read(buf []byte, off int64, ctx *fuse.Context) (fuse.ReadResult, fuse.Status) {
end := int(off) + len(buf) end := int(off) + len(buf)
if end > len(f.data) { if end > len(f.data) {
end = len(f.data) end = len(f.data)
...@@ -38,7 +38,7 @@ func (f *MutableDataFile) Read(buf []byte, off int64) (fuse.ReadResult, fuse.Sta ...@@ -38,7 +38,7 @@ func (f *MutableDataFile) Read(buf []byte, off int64) (fuse.ReadResult, fuse.Sta
return fuse.ReadResultData(f.data[off:end]), fuse.OK return fuse.ReadResultData(f.data[off:end]), fuse.OK
} }
func (f *MutableDataFile) Write(d []byte, off int64) (uint32, fuse.Status) { func (f *MutableDataFile) Write(d []byte, off int64, ctx *fuse.Context) (uint32, fuse.Status) {
end := int64(len(d)) + off end := int64(len(d)) + off
if int(end) > len(f.data) { if int(end) > len(f.data) {
data := make([]byte, len(f.data), end) data := make([]byte, len(f.data), end)
...@@ -51,7 +51,7 @@ func (f *MutableDataFile) Write(d []byte, off int64) (uint32, fuse.Status) { ...@@ -51,7 +51,7 @@ func (f *MutableDataFile) Write(d []byte, off int64) (uint32, fuse.Status) {
return uint32(end - off), fuse.OK return uint32(end - off), fuse.OK
} }
func (f *MutableDataFile) Flush() fuse.Status { func (f *MutableDataFile) Flush(ctx *fuse.Context) fuse.Status {
return fuse.OK return fuse.OK
} }
...@@ -64,34 +64,34 @@ func (f *MutableDataFile) getAttr(out *fuse.Attr) { ...@@ -64,34 +64,34 @@ func (f *MutableDataFile) getAttr(out *fuse.Attr) {
out.Size = uint64(len(f.data)) out.Size = uint64(len(f.data))
} }
func (f *MutableDataFile) GetAttr(out *fuse.Attr) fuse.Status { func (f *MutableDataFile) GetAttr(out *fuse.Attr, ctx *fuse.Context) fuse.Status {
f.GetAttrCalled = true f.GetAttrCalled = true
f.getAttr(out) f.getAttr(out)
return fuse.OK return fuse.OK
} }
func (f *MutableDataFile) Utimens(atime *time.Time, mtime *time.Time) fuse.Status { func (f *MutableDataFile) Utimens(atime *time.Time, mtime *time.Time, ctx *fuse.Context) fuse.Status {
f.Attr.SetTimes(atime, mtime, nil) f.Attr.SetTimes(atime, mtime, nil)
return fuse.OK return fuse.OK
} }
func (f *MutableDataFile) Truncate(size uint64) fuse.Status { func (f *MutableDataFile) Truncate(size uint64, ctx *fuse.Context) fuse.Status {
f.data = f.data[:size] f.data = f.data[:size]
return fuse.OK return fuse.OK
} }
func (f *MutableDataFile) Chown(uid uint32, gid uint32) fuse.Status { func (f *MutableDataFile) Chown(uid uint32, gid uint32, ctx *fuse.Context) fuse.Status {
f.Attr.Uid = uid f.Attr.Uid = uid
f.Attr.Gid = gid f.Attr.Gid = gid
return fuse.OK return fuse.OK
} }
func (f *MutableDataFile) Chmod(perms uint32) fuse.Status { func (f *MutableDataFile) Chmod(perms uint32, ctx *fuse.Context) fuse.Status {
f.Attr.Mode = (f.Attr.Mode &^ 07777) | perms f.Attr.Mode = (f.Attr.Mode &^ 07777) | perms
return fuse.OK return fuse.OK
} }
func (f *MutableDataFile) Fsync(flags int) fuse.Status { func (f *MutableDataFile) Fsync(flags int, ctx *fuse.Context) fuse.Status {
f.FsyncCalled = true f.FsyncCalled = true
return fuse.OK return fuse.OK
} }
......
...@@ -276,8 +276,9 @@ func (fs *unionFS) putDeletion(name string) (code fuse.Status) { ...@@ -276,8 +276,9 @@ func (fs *unionFS) putDeletion(name string) (code fuse.Status) {
return fuse.EPERM return fuse.EPERM
} }
defer f.Release() defer f.Release()
defer f.Flush() ctx := &fuse.Context{Cancel: nil}
n, code := f.Write([]byte(name), 0) defer f.Flush(ctx)
n, code := f.Write([]byte(name), 0, ctx)
if int(n) != len(name) || !code.Ok() { if int(n) != len(name) || !code.Ok() {
panic(fmt.Sprintf("Error for writing %v: %v, %v (exp %v) %v", name, marker, n, len(name), code)) panic(fmt.Sprintf("Error for writing %v: %v, %v (exp %v) %v", name, marker, n, len(name), code))
} }
...@@ -334,7 +335,7 @@ func (fs *unionFS) Promote(name string, srcResult branchResult, context *fuse.Co ...@@ -334,7 +335,7 @@ func (fs *unionFS) Promote(name string, srcResult branchResult, context *fuse.Co
uf.layer = 0 uf.layer = 0
f := uf.File f := uf.File
uf.File, code = fs.fileSystems[0].Open(name, fileWrapper.OpenFlags, context) uf.File, code = fs.fileSystems[0].Open(name, fileWrapper.OpenFlags, context)
f.Flush() f.Flush(context)
f.Release() f.Release()
} }
} }
...@@ -949,7 +950,7 @@ func (fs *unionFS) DropSubFsCaches() { ...@@ -949,7 +950,7 @@ func (fs *unionFS) DropSubFsCaches() {
if code.Ok() && a.IsRegular() { if code.Ok() && a.IsRegular() {
f, _ := fs.Open(_DROP_CACHE, uint32(os.O_WRONLY), nil) f, _ := fs.Open(_DROP_CACHE, uint32(os.O_WRONLY), nil)
if f != nil { if f != nil {
f.Flush() f.Flush(&fuse.Context{Cancel: nil})
f.Release() f.Release()
} }
} }
...@@ -1028,8 +1029,8 @@ func (fs *unionFsFile) InnerFile() (file nodefs.File) { ...@@ -1028,8 +1029,8 @@ func (fs *unionFsFile) InnerFile() (file nodefs.File) {
// We can't hook on Release. Release has no response, so it is not // We can't hook on Release. Release has no response, so it is not
// ordered wrt any following calls. // ordered wrt any following calls.
func (fs *unionFsFile) Flush() (code fuse.Status) { func (fs *unionFsFile) Flush(ctx *fuse.Context) (code fuse.Status) {
code = fs.File.Flush() code = fs.File.Flush(ctx)
path := fs.ufs.nodeFs.Path(fs.node) path := fs.ufs.nodeFs.Path(fs.node)
fs.ufs.branchCache.GetFresh(path) fs.ufs.branchCache.GetFresh(path)
return code return code
...@@ -1039,8 +1040,8 @@ func (fs *unionFsFile) SetInode(node *nodefs.Inode) { ...@@ -1039,8 +1040,8 @@ func (fs *unionFsFile) SetInode(node *nodefs.Inode) {
fs.node = node fs.node = node
} }
func (fs *unionFsFile) GetAttr(out *fuse.Attr) fuse.Status { func (fs *unionFsFile) GetAttr(out *fuse.Attr, ctx *fuse.Context) fuse.Status {
code := fs.File.GetAttr(out) code := fs.File.GetAttr(out, ctx)
if code.Ok() { if code.Ok() {
out.Mode |= 0200 out.Mode |= 0200
} }
......
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