Support flush/fsync errors.

geesefs-0-30-9
Aaron Jacobs 2015-03-20 11:52:54 +11:00
parent 4eda8330e8
commit a932a6549e
2 changed files with 13 additions and 9 deletions

View File

@ -28,10 +28,10 @@ import (
//
// The file may be opened for reading and/or writing. Its initial contents are
// empty. Whenever a flush or fsync is received, the supplied function will be
// called with the current contents of the file.
// called with the current contents of the file and its status returned.
func NewFileSystem(
reportFlush func(string),
reportFsync func(string)) (fs fuse.FileSystem, err error) {
reportFlush func(string) error,
reportFsync func(string) error) (fs fuse.FileSystem, err error) {
fs = &flushFS{}
return
}

View File

@ -41,10 +41,12 @@ type FlushFSTest struct {
mu sync.Mutex
// GUARDED_BY(mu)
flushes []string
flushes []string
flushErr error
// GUARDED_BY(mu)
fsyncs []string
fsyncs []string
fsyncErr error
}
func init() { RegisterTestSuite(&FlushFSTest{}) }
@ -53,17 +55,19 @@ func (t *FlushFSTest) SetUp(ti *TestInfo) {
var err error
// Set up a file system.
reportTo := func(slice *[]string) func(string) {
return func(s string) {
reportTo := func(slice *[]string, err *error) func(string) error {
return func(s string) error {
t.mu.Lock()
defer t.mu.Unlock()
*slice = append(*slice, s)
return *err
}
}
t.FileSystem, err = flushfs.NewFileSystem(
reportTo(&t.flushes),
reportTo(&t.fsyncs))
reportTo(&t.flushes, &t.flushErr),
reportTo(&t.fsyncs, &t.fsyncErr))
if err != nil {
panic(err)