diff --git a/fs/bench/bench_test.go b/fs/bench/bench_test.go index d26f82c1..7b7efb1e 100644 --- a/fs/bench/bench_test.go +++ b/fs/bench/bench_test.go @@ -62,8 +62,8 @@ type benchFile struct { var _ = fs.Node(benchFile{}) var _ = fs.NodeOpener(benchFile{}) -var _ = fs.NodeFsyncer(benchFile{}) var _ = fs.Handle(benchFile{}) +var _ = fs.HandleFsyncer(benchFile{}) var _ = fs.HandleReader(benchFile{}) var _ = fs.HandleWriter(benchFile{}) diff --git a/fs/fstestutil/record/record.go b/fs/fstestutil/record/record.go index 13654dee..1131b506 100644 --- a/fs/fstestutil/record/record.go +++ b/fs/fstestutil/record/record.go @@ -139,7 +139,7 @@ type Fsyncs struct { rec RequestRecorder } -var _ = fs.NodeFsyncer(&Fsyncs{}) +var _ = fs.HandleFsyncer(&Fsyncs{}) func (r *Fsyncs) Fsync(ctx context.Context, req *fuse.FsyncRequest) error { tmp := *req diff --git a/fs/serve.go b/fs/serve.go index 96ee82dc..71315044 100644 --- a/fs/serve.go +++ b/fs/serve.go @@ -210,11 +210,6 @@ type NodeMknoder interface { Mknod(ctx context.Context, req *fuse.MknodRequest) (Node, error) } -// TODO this should be on Handle not Node -type NodeFsyncer interface { - Fsync(ctx context.Context, req *fuse.FsyncRequest) error -} - type NodeGetxattrer interface { // Getxattr gets an extended attribute by the given name from the // node. @@ -275,6 +270,10 @@ type HandleFlusher interface { Flush(ctx context.Context, req *fuse.FlushRequest) error } +type HandleFsyncer interface { + Fsync(ctx context.Context, req *fuse.FsyncRequest) error +} + type HandleReadAller interface { ReadAll(ctx context.Context) ([]byte, error) } @@ -1379,13 +1378,21 @@ func (c *Server) serve(r fuse.Request) { r.Respond(s) case *fuse.FsyncRequest: - n, ok := node.(NodeFsyncer) + shandle := c.getHandle(r.Handle) + if shandle == nil { + done(fuse.ESTALE) + r.RespondError(fuse.ESTALE) + return + } + handle := shandle.handle + + h, ok := handle.(HandleFsyncer) if !ok { done(fuse.EIO) r.RespondError(fuse.EIO) break } - err := n.Fsync(ctx, r) + err := h.Fsync(ctx, r) if err != nil { done(err) r.RespondError(err)