From 8ab34bc0e4f1feacc860ef3a6b0869a5c4f1e0a5 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Fri, 20 Mar 2015 13:27:27 +1100 Subject: [PATCH] flushFS.FlushFile --- samples/flushfs/flush_fs.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/samples/flushfs/flush_fs.go b/samples/flushfs/flush_fs.go index 2cf3ecf..7d89734 100644 --- a/samples/flushfs/flush_fs.go +++ b/samples/flushfs/flush_fs.go @@ -32,7 +32,11 @@ import ( func NewFileSystem( reportFlush func(string) error, reportFsync func(string) error) (fs fuse.FileSystem, err error) { - fs = &flushFS{} + fs = &flushFS{ + reportFlush: reportFlush, + reportFsync: reportFsync, + } + return } @@ -40,6 +44,8 @@ const fooID = fuse.RootInodeID + 1 type flushFS struct { fuseutil.NotImplementedFileSystem + reportFlush func(string) error + reportFsync func(string) error mu sync.Mutex fooContents []byte // GUARDED_BY(mu) @@ -168,3 +174,16 @@ func (fs *flushFS) WriteFile( return } + +func (fs *flushFS) FlushFile( + ctx context.Context, + req *fuse.FlushFileRequest) ( + resp *fuse.FlushFileResponse, err error) { + resp = &fuse.FlushFileResponse{} + + fs.mu.Lock() + defer fs.mu.Unlock() + + err = fs.reportFlush(string(fs.fooContents)) + return +}