Don't rely on fuseshim for errors.
parent
3720ab2963
commit
964ae1b4e5
20
errors.go
20
errors.go
|
@ -14,20 +14,16 @@
|
||||||
|
|
||||||
package fuse
|
package fuse
|
||||||
|
|
||||||
import (
|
import "syscall"
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"github.com/jacobsa/fuse/internal/fuseshim"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Errors corresponding to kernel error numbers. These may be treated
|
// Errors corresponding to kernel error numbers. These may be treated
|
||||||
// specially by fuseops.Op.Respond methods.
|
// specially by fuseops.Op.Respond methods.
|
||||||
EEXIST = fuseshim.EEXIST
|
EEXIST = syscall.EEXIST
|
||||||
EINVAL = fuseshim.Errno(syscall.EINVAL)
|
EINVAL = syscall.EINVAL
|
||||||
EIO = fuseshim.EIO
|
EIO = syscall.EIO
|
||||||
ENOENT = fuseshim.ENOENT
|
ENOENT = syscall.ENOENT
|
||||||
ENOSYS = fuseshim.ENOSYS
|
ENOSYS = syscall.ENOSYS
|
||||||
ENOTDIR = fuseshim.Errno(syscall.ENOTDIR)
|
ENOTDIR = syscall.ENOTDIR
|
||||||
ENOTEMPTY = fuseshim.Errno(syscall.ENOTEMPTY)
|
ENOTEMPTY = syscall.ENOTEMPTY
|
||||||
)
|
)
|
||||||
|
|
|
@ -19,9 +19,9 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"github.com/jacobsa/fuse/internal/buffer"
|
"github.com/jacobsa/fuse/internal/buffer"
|
||||||
"github.com/jacobsa/fuse/internal/fuseshim"
|
|
||||||
"github.com/jacobsa/reqtrace"
|
"github.com/jacobsa/reqtrace"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
@ -156,12 +156,13 @@ func (o *commonOp) Respond(err error) {
|
||||||
h.Unique = o.fuseID
|
h.Unique = o.fuseID
|
||||||
h.Len = uint32(len(msg))
|
h.Len = uint32(len(msg))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errno := fuseshim.EIO
|
// If the user gave us a syscall.Errno, use that value in the reply.
|
||||||
if ferr, ok := err.(fuseshim.ErrorNumber); ok {
|
// Otherwise use the generic EIO.
|
||||||
errno = ferr.Errno()
|
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/fsutil"
|
||||||
"github.com/jacobsa/fuse/fusetesting"
|
"github.com/jacobsa/fuse/fusetesting"
|
||||||
"github.com/jacobsa/fuse/internal/fuseshim"
|
|
||||||
"github.com/jacobsa/fuse/samples"
|
"github.com/jacobsa/fuse/samples"
|
||||||
. "github.com/jacobsa/oglematchers"
|
. "github.com/jacobsa/oglematchers"
|
||||||
. "github.com/jacobsa/ogletest"
|
. "github.com/jacobsa/ogletest"
|
||||||
|
@ -58,8 +57,8 @@ type flushFSTest struct {
|
||||||
|
|
||||||
func (t *flushFSTest) setUp(
|
func (t *flushFSTest) setUp(
|
||||||
ti *TestInfo,
|
ti *TestInfo,
|
||||||
flushErr fuseshim.Errno,
|
flushErr syscall.Errno,
|
||||||
fsyncErr fuseshim.Errno,
|
fsyncErr syscall.Errno,
|
||||||
readOnly bool) {
|
readOnly bool) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
@ -810,7 +809,7 @@ func init() { RegisterTestSuite(&FlushErrorTest{}) }
|
||||||
|
|
||||||
func (t *FlushErrorTest) SetUp(ti *TestInfo) {
|
func (t *FlushErrorTest) SetUp(ti *TestInfo) {
|
||||||
const noErr = 0
|
const noErr = 0
|
||||||
t.flushFSTest.setUp(ti, fuseshim.ENOENT, noErr, false)
|
t.flushFSTest.setUp(ti, syscall.ENOENT, noErr, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *FlushErrorTest) Close() {
|
func (t *FlushErrorTest) Close() {
|
||||||
|
@ -890,7 +889,7 @@ func init() { RegisterTestSuite(&FsyncErrorTest{}) }
|
||||||
|
|
||||||
func (t *FsyncErrorTest) SetUp(ti *TestInfo) {
|
func (t *FsyncErrorTest) SetUp(ti *TestInfo) {
|
||||||
const noErr = 0
|
const noErr = 0
|
||||||
t.flushFSTest.setUp(ti, noErr, fuseshim.ENOENT, false)
|
t.flushFSTest.setUp(ti, noErr, syscall.ENOENT, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *FsyncErrorTest) Fsync() {
|
func (t *FsyncErrorTest) Fsync() {
|
||||||
|
|
|
@ -23,9 +23,9 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"github.com/jacobsa/fuse"
|
"github.com/jacobsa/fuse"
|
||||||
"github.com/jacobsa/fuse/internal/fuseshim"
|
|
||||||
"github.com/jacobsa/fuse/samples/flushfs"
|
"github.com/jacobsa/fuse/samples/flushfs"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
@ -58,11 +58,11 @@ func makeFlushFS() (server fuse.Server, err error) {
|
||||||
var fsyncErr error
|
var fsyncErr error
|
||||||
|
|
||||||
if *fFlushError != 0 {
|
if *fFlushError != 0 {
|
||||||
flushErr = fuseshim.Errno(*fFlushError)
|
flushErr = syscall.Errno(*fFlushError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if *fFsyncError != 0 {
|
if *fFsyncError != 0 {
|
||||||
fsyncErr = fuseshim.Errno(*fFsyncError)
|
fsyncErr = syscall.Errno(*fFsyncError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Report flushes and fsyncs by writing the contents followed by a newline.
|
// Report flushes and fsyncs by writing the contents followed by a newline.
|
||||||
|
|
Loading…
Reference in New Issue