flushFS.FlushFile
parent
b0cb3df8c1
commit
8ab34bc0e4
|
@ -32,7 +32,11 @@ import (
|
||||||
func NewFileSystem(
|
func NewFileSystem(
|
||||||
reportFlush func(string) error,
|
reportFlush func(string) error,
|
||||||
reportFsync func(string) error) (fs fuse.FileSystem, err error) {
|
reportFsync func(string) error) (fs fuse.FileSystem, err error) {
|
||||||
fs = &flushFS{}
|
fs = &flushFS{
|
||||||
|
reportFlush: reportFlush,
|
||||||
|
reportFsync: reportFsync,
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +44,8 @@ const fooID = fuse.RootInodeID + 1
|
||||||
|
|
||||||
type flushFS struct {
|
type flushFS struct {
|
||||||
fuseutil.NotImplementedFileSystem
|
fuseutil.NotImplementedFileSystem
|
||||||
|
reportFlush func(string) error
|
||||||
|
reportFsync func(string) error
|
||||||
|
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
fooContents []byte // GUARDED_BY(mu)
|
fooContents []byte // GUARDED_BY(mu)
|
||||||
|
@ -168,3 +174,16 @@ func (fs *flushFS) WriteFile(
|
||||||
|
|
||||||
return
|
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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue