From 964ae1b4e511327cdb38c109336407b65e6f7655 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Fri, 24 Jul 2015 14:02:55 +1000 Subject: [PATCH] Don't rely on fuseshim for errors. --- errors.go | 20 ++++++++------------ fuseops/common_op.go | 13 +++++++------ samples/flushfs/flush_fs_test.go | 9 ++++----- samples/mount_sample/mount.go | 6 +++--- 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/errors.go b/errors.go index d3dea3e..bc9f902 100644 --- a/errors.go +++ b/errors.go @@ -14,20 +14,16 @@ package fuse -import ( - "syscall" - - "github.com/jacobsa/fuse/internal/fuseshim" -) +import "syscall" const ( // Errors corresponding to kernel error numbers. These may be treated // specially by fuseops.Op.Respond methods. - EEXIST = fuseshim.EEXIST - EINVAL = fuseshim.Errno(syscall.EINVAL) - EIO = fuseshim.EIO - ENOENT = fuseshim.ENOENT - ENOSYS = fuseshim.ENOSYS - ENOTDIR = fuseshim.Errno(syscall.ENOTDIR) - ENOTEMPTY = fuseshim.Errno(syscall.ENOTEMPTY) + EEXIST = syscall.EEXIST + EINVAL = syscall.EINVAL + EIO = syscall.EIO + ENOENT = syscall.ENOENT + ENOSYS = syscall.ENOSYS + ENOTDIR = syscall.ENOTDIR + ENOTEMPTY = syscall.ENOTEMPTY ) diff --git a/fuseops/common_op.go b/fuseops/common_op.go index 939d16e..203793c 100644 --- a/fuseops/common_op.go +++ b/fuseops/common_op.go @@ -19,9 +19,9 @@ import ( "log" "reflect" "strings" + "syscall" "github.com/jacobsa/fuse/internal/buffer" - "github.com/jacobsa/fuse/internal/fuseshim" "github.com/jacobsa/reqtrace" "golang.org/x/net/context" ) @@ -156,12 +156,13 @@ func (o *commonOp) Respond(err error) { h.Unique = o.fuseID h.Len = uint32(len(msg)) if err != nil { - errno := fuseshim.EIO - if ferr, ok := err.(fuseshim.ErrorNumber); ok { - errno = ferr.Errno() + // If the user gave us a syscall.Errno, use that value in the reply. + // Otherwise use the generic EIO. + if errno, ok := err.(syscall.Errno); ok { + h.Error = -int32(errno) + } else { + h.Error = -int32(syscall.EIO) } - - h.Error = -int32(errno) } } diff --git a/samples/flushfs/flush_fs_test.go b/samples/flushfs/flush_fs_test.go index 60d8d11..278f0ba 100644 --- a/samples/flushfs/flush_fs_test.go +++ b/samples/flushfs/flush_fs_test.go @@ -32,7 +32,6 @@ import ( "github.com/jacobsa/fuse/fsutil" "github.com/jacobsa/fuse/fusetesting" - "github.com/jacobsa/fuse/internal/fuseshim" "github.com/jacobsa/fuse/samples" . "github.com/jacobsa/oglematchers" . "github.com/jacobsa/ogletest" @@ -58,8 +57,8 @@ type flushFSTest struct { func (t *flushFSTest) setUp( ti *TestInfo, - flushErr fuseshim.Errno, - fsyncErr fuseshim.Errno, + flushErr syscall.Errno, + fsyncErr syscall.Errno, readOnly bool) { var err error @@ -810,7 +809,7 @@ func init() { RegisterTestSuite(&FlushErrorTest{}) } func (t *FlushErrorTest) SetUp(ti *TestInfo) { const noErr = 0 - t.flushFSTest.setUp(ti, fuseshim.ENOENT, noErr, false) + t.flushFSTest.setUp(ti, syscall.ENOENT, noErr, false) } func (t *FlushErrorTest) Close() { @@ -890,7 +889,7 @@ func init() { RegisterTestSuite(&FsyncErrorTest{}) } func (t *FsyncErrorTest) SetUp(ti *TestInfo) { const noErr = 0 - t.flushFSTest.setUp(ti, noErr, fuseshim.ENOENT, false) + t.flushFSTest.setUp(ti, noErr, syscall.ENOENT, false) } func (t *FsyncErrorTest) Fsync() { diff --git a/samples/mount_sample/mount.go b/samples/mount_sample/mount.go index 71707bf..5a25e12 100644 --- a/samples/mount_sample/mount.go +++ b/samples/mount_sample/mount.go @@ -23,9 +23,9 @@ import ( "log" "os" "runtime" + "syscall" "github.com/jacobsa/fuse" - "github.com/jacobsa/fuse/internal/fuseshim" "github.com/jacobsa/fuse/samples/flushfs" "golang.org/x/net/context" ) @@ -58,11 +58,11 @@ func makeFlushFS() (server fuse.Server, err error) { var fsyncErr error if *fFlushError != 0 { - flushErr = fuseshim.Errno(*fFlushError) + flushErr = syscall.Errno(*fFlushError) } if *fFsyncError != 0 { - fsyncErr = fuseshim.Errno(*fFsyncError) + fsyncErr = syscall.Errno(*fFsyncError) } // Report flushes and fsyncs by writing the contents followed by a newline.