flushFS.FlushFile

geesefs-0-30-9
Aaron Jacobs 2015-03-20 13:27:27 +11:00
parent b0cb3df8c1
commit 8ab34bc0e4
1 changed files with 20 additions and 1 deletions

View File

@ -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
}