diff options
Diffstat (limited to 'internal')
-rw-r--r-- | internal/fusefrontend/file.go | 5 | ||||
-rw-r--r-- | internal/fusefrontend/node.go | 19 |
2 files changed, 23 insertions, 1 deletions
diff --git a/internal/fusefrontend/file.go b/internal/fusefrontend/file.go index cbf78e9..4866e65 100644 --- a/internal/fusefrontend/file.go +++ b/internal/fusefrontend/file.go @@ -427,7 +427,10 @@ func (f *File) Flush(ctx context.Context) syscall.Errno { return fs.ToErrno(err) } -// Fsync FUSE call +// Fsync: handles FUSE opcode FSYNC +// +// Unfortunately, as Node.Fsync is also defined and takes precedence, +// File.Fsync is never called at the moment. func (f *File) Fsync(ctx context.Context, flags uint32) (errno syscall.Errno) { f.fdLock.RLock() defer f.fdLock.RUnlock() diff --git a/internal/fusefrontend/node.go b/internal/fusefrontend/node.go index dd446a3..5d3c178 100644 --- a/internal/fusefrontend/node.go +++ b/internal/fusefrontend/node.go @@ -447,3 +447,22 @@ func (n *Node) Rename(ctx context.Context, name string, newParent fs.InodeEmbedd } return 0 } + +// Fsync: handles FUSE opcodes FSYNC & FDIRSYNC +// +// Note: f is always set to nil by go-fuse +func (n *Node) Fsync(ctx context.Context, f fs.FileHandle, flags uint32) syscall.Errno { + dirfd, cName, errno := n.prepareAtSyscallMyself() + if errno != 0 { + return errno + } + defer syscall.Close(dirfd) + + fd, err := syscallcompat.Openat(dirfd, cName, syscall.O_RDONLY|syscall.O_NOFOLLOW, 0) + if err != nil { + return fs.ToErrno(err) + } + defer syscall.Close(fd) + + return fs.ToErrno(syscall.Fsync(fd)) +} |