From 978399a2685e32c0aa8a8c97234407d00687e1d0 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Tue, 4 Aug 2015 08:35:59 +1000 Subject: [PATCH] errorFS.SetError --- samples/errorfs/error_fs.go | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/samples/errorfs/error_fs.go b/samples/errorfs/error_fs.go index 8fe401c..e2f32f5 100644 --- a/samples/errorfs/error_fs.go +++ b/samples/errorfs/error_fs.go @@ -15,8 +15,8 @@ package errorfs import ( - "errors" "reflect" + "sync" "syscall" "github.com/jacobsa/fuse/fuseutil" @@ -38,6 +38,28 @@ type FS interface { } func New() (fs FS, err error) { - err = errors.New("TODO") + fs = &errorFS{ + errors: make(map[string]syscall.Errno), + } + return } + +type errorFS struct { + fuseutil.NotImplementedFileSystem + + mu sync.Mutex + + // Keys are reflect.Type.Name strings. + // + // GUARDED_BY(mu) + errors map[string]syscall.Errno +} + +// LOCKS_EXCLUDED(fs.mu) +func (fs *errorFS) SetError(t reflect.Type, err syscall.Errno) { + fs.mu.Lock() + defer fs.mu.Unlock() + + fs.errors[t.Name()] = err +}