Don't rely on fuseshim for errors.
parent
3720ab2963
commit
964ae1b4e5
20
errors.go
20
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
|
||||
)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue