aboutsummaryrefslogtreecommitdiff
path: root/internal/fusefrontend/node.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2021-07-29 20:39:50 +0200
committerJakob Unterwurzacher2021-07-29 20:39:50 +0200
commit0ca302f12aa8be391d6b8e7081b5c75fbec2e872 (patch)
treebdf36873bb3a7cfc6cc5a3c14f63dede7d33c2a0 /internal/fusefrontend/node.go
parente83b79b4c2e8619f0f9622bbafc39d04eeced3f0 (diff)
fusefrontend: implement fsync on directories
Fixes https://github.com/rfjakob/gocryptfs/issues/587
Diffstat (limited to 'internal/fusefrontend/node.go')
-rw-r--r--internal/fusefrontend/node.go19
1 files changed, 19 insertions, 0 deletions
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))
+}