diff --git a/fuse/fuse.go b/fuse/fuse.go index 8b95eccfdab1aacf7b18761dcd8b21d28ca1da20..a13c90ff764517f095a4e0e82b1c206f7d7a6960 100644 --- a/fuse/fuse.go +++ b/fuse/fuse.go @@ -240,7 +240,7 @@ func (me *MountState) loop() { err := me.readRequest(req) if err != nil { - errNo := OsErrorToFuseError(err) + errNo := OsErrorToErrno(err) // Retry. if errNo == syscall.ENOENT { diff --git a/fuse/loopback.go b/fuse/loopback.go index a5199b06a6a443efa913d9c632fcd0e0148e1c26..77a66580408dd8df32cd0dc4c60fe8edaeb21f75 100644 --- a/fuse/loopback.go +++ b/fuse/loopback.go @@ -49,7 +49,7 @@ func (me *LoopbackFileSystem) OpenDir(name string) (stream chan DirEntry, status // directories? f, err := os.Open(me.GetPath(name)) if err != nil { - return nil, OsErrorToFuseError(err) + return nil, OsErrorToErrno(err) } output := make(chan DirEntry, 500) go func() { @@ -80,31 +80,31 @@ func (me *LoopbackFileSystem) OpenDir(name string) (stream chan DirEntry, status func (me *LoopbackFileSystem) Open(name string, flags uint32) (fuseFile FuseFile, status Status) { f, err := os.OpenFile(me.GetPath(name), int(flags), 0) if err != nil { - return nil, OsErrorToFuseError(err) + return nil, OsErrorToErrno(err) } return &LoopbackFile{file: f}, OK } func (me *LoopbackFileSystem) Chmod(path string, mode uint32) (code Status) { err := os.Chmod(me.GetPath(path), mode) - return OsErrorToFuseError(err) + return OsErrorToErrno(err) } func (me *LoopbackFileSystem) Chown(path string, uid uint32, gid uint32) (code Status) { - return OsErrorToFuseError(os.Chown(me.GetPath(path), int(uid), int(gid))) + return OsErrorToErrno(os.Chown(me.GetPath(path), int(uid), int(gid))) } func (me *LoopbackFileSystem) Truncate(path string, offset uint64) (code Status) { - return OsErrorToFuseError(os.Truncate(me.GetPath(path), int64(offset))) + return OsErrorToErrno(os.Truncate(me.GetPath(path), int64(offset))) } func (me *LoopbackFileSystem) Utimens(path string, AtimeNs uint64, MtimeNs uint64) (code Status) { - return OsErrorToFuseError(os.Chtimes(me.GetPath(path), int64(AtimeNs), int64(MtimeNs))) + return OsErrorToErrno(os.Chtimes(me.GetPath(path), int64(AtimeNs), int64(MtimeNs))) } func (me *LoopbackFileSystem) Readlink(name string) (out string, code Status) { f, err := os.Readlink(me.GetPath(name)) - return f, OsErrorToFuseError(err) + return f, OsErrorToErrno(err) } func (me *LoopbackFileSystem) Mknod(name string, mode uint32, dev uint32) (code Status) { @@ -112,7 +112,7 @@ func (me *LoopbackFileSystem) Mknod(name string, mode uint32, dev uint32) (code } func (me *LoopbackFileSystem) Mkdir(path string, mode uint32) (code Status) { - return OsErrorToFuseError(os.Mkdir(me.GetPath(path), mode)) + return OsErrorToErrno(os.Mkdir(me.GetPath(path), mode)) } // Don't use os.Remove, it removes twice (unlink followed by rmdir). @@ -125,16 +125,16 @@ func (me *LoopbackFileSystem) Rmdir(name string) (code Status) { } func (me *LoopbackFileSystem) Symlink(pointedTo string, linkName string) (code Status) { - return OsErrorToFuseError(os.Symlink(pointedTo, me.GetPath(linkName))) + return OsErrorToErrno(os.Symlink(pointedTo, me.GetPath(linkName))) } func (me *LoopbackFileSystem) Rename(oldPath string, newPath string) (code Status) { err := os.Rename(me.GetPath(oldPath), me.GetPath(newPath)) - return OsErrorToFuseError(err) + return OsErrorToErrno(err) } func (me *LoopbackFileSystem) Link(orig string, newName string) (code Status) { - return OsErrorToFuseError(os.Link(me.GetPath(orig), me.GetPath(newName))) + return OsErrorToErrno(os.Link(me.GetPath(orig), me.GetPath(newName))) } func (me *LoopbackFileSystem) Access(name string, mode uint32) (code Status) { @@ -143,7 +143,7 @@ func (me *LoopbackFileSystem) Access(name string, mode uint32) (code Status) { func (me *LoopbackFileSystem) Create(path string, flags uint32, mode uint32) (fuseFile FuseFile, code Status) { f, err := os.OpenFile(me.GetPath(path), int(flags)|os.O_CREATE, mode) - return &LoopbackFile{file: f}, OsErrorToFuseError(err) + return &LoopbackFile{file: f}, OsErrorToErrno(err) } func (me *LoopbackFileSystem) GetXAttr(name string, attr string) ([]byte, Status) { @@ -185,12 +185,12 @@ func (me *LoopbackFile) Read(input *ReadIn, buffers *BufferPool) ([]byte, Status if err == os.EOF { return slice[:n], OK } - return slice[:n], OsErrorToFuseError(err) + return slice[:n], OsErrorToErrno(err) } func (me *LoopbackFile) Write(input *WriteIn, data []byte) (uint32, Status) { n, err := me.file.WriteAt(data, int64(input.Offset)) - return uint32(n), OsErrorToFuseError(err) + return uint32(n), OsErrorToErrno(err) } func (me *LoopbackFile) Release() { diff --git a/fuse/misc.go b/fuse/misc.go index 96061c6cb8557918b40f17bbafd67fb9c57ac9f9..af161dc92c99e71f4b2a72085da938f5a4373366 100644 --- a/fuse/misc.go +++ b/fuse/misc.go @@ -24,7 +24,7 @@ func MakeTempDir() string { } // Convert os.Error back to Errno based errors. -func OsErrorToFuseError(err os.Error) Status { +func OsErrorToErrno(err os.Error) Status { if err != nil { switch t := err.(type) { case os.Errno: @@ -32,9 +32,9 @@ func OsErrorToFuseError(err os.Error) Status { case *os.SyscallError: return Status(t.Errno) case *os.PathError: - return OsErrorToFuseError(t.Error) + return OsErrorToErrno(t.Error) case *os.LinkError: - return OsErrorToFuseError(t.Error) + return OsErrorToErrno(t.Error) default: log.Println("can't convert error type:", err) return ENOSYS diff --git a/fuse/misc_test.go b/fuse/misc_test.go index f300ff2d235c484d4da78803593ddd97d04a52ab..786561dfc5bc376fcf504afa95467cd8771298ae 100644 --- a/fuse/misc_test.go +++ b/fuse/misc_test.go @@ -7,20 +7,20 @@ import ( ) -func TestOsErrorToFuseError(t *testing.T) { - errNo := OsErrorToFuseError(os.EPERM) +func TestOsErrorToErrno(t *testing.T) { + errNo := OsErrorToErrno(os.EPERM) if errNo != syscall.EPERM { t.Errorf("Wrong conversion %v != %v", errNo, syscall.EPERM) } e := os.NewSyscallError("syscall", syscall.EPERM) - errNo = OsErrorToFuseError(e) + errNo = OsErrorToErrno(e) if errNo != syscall.EPERM { t.Errorf("Wrong conversion %v != %v", errNo, syscall.EPERM) } e = os.Remove("this-file-surely-does-not-exist") - errNo = OsErrorToFuseError(e) + errNo = OsErrorToErrno(e) if errNo != syscall.ENOENT { t.Errorf("Wrong conversion %v != %v", errNo, syscall.ENOENT) }