From a932a6549e526046199f950d796866db3c217d6d Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Fri, 20 Mar 2015 11:52:54 +1100 Subject: [PATCH] Support flush/fsync errors. --- samples/flushfs/flush_fs.go | 6 +++--- samples/flushfs/flush_fs_test.go | 16 ++++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/samples/flushfs/flush_fs.go b/samples/flushfs/flush_fs.go index 223012c..2cf3ecf 100644 --- a/samples/flushfs/flush_fs.go +++ b/samples/flushfs/flush_fs.go @@ -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 } diff --git a/samples/flushfs/flush_fs_test.go b/samples/flushfs/flush_fs_test.go index 4b961e9..aec7f56 100644 --- a/samples/flushfs/flush_fs_test.go +++ b/samples/flushfs/flush_fs_test.go @@ -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)