Commit eb06cb23 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Update for weekly.2011-11-02

parent 3881211d
......@@ -7,6 +7,7 @@ import (
"bufio"
"flag"
"github.com/hanwen/go-fuse/benchmark"
"log"
"os"
"runtime"
)
......@@ -24,7 +25,7 @@ func main() {
filename := flag.Args()[0]
f, err := os.Open(filename)
if err != nil {
panic("err" + err.String())
log.Panicf("Open: %v", err)
}
reader := bufio.NewReader(f)
......
......@@ -163,7 +163,7 @@ func TestGetAttrRace(t *testing.T) {
n := 100
wg.Add(n)
var statErr os.Error
var statErr error
for i := 0; i < n; i++ {
go func() {
defer wg.Done()
......
......@@ -2,6 +2,7 @@ package fuse
import (
"fmt"
"io"
"os"
"syscall"
)
......@@ -97,7 +98,7 @@ func (me *LoopbackFile) Read(input *ReadIn, buffers BufferPool) ([]byte, Status)
n, err := me.File.ReadAt(slice, int64(input.Offset))
// TODO - fix Go ndocumentation.
if err == os.EOF {
if err == io.EOF {
err = nil
}
return slice[:n], OsErrorToErrno(err)
......
package fuse
import (
"log"
"os"
)
import "log"
var _ = log.Println
func MountNodeFileSystem(mountpoint string, nodeFs NodeFileSystem, opts *FileSystemOptions) (*MountState, *FileSystemConnector, os.Error) {
func MountNodeFileSystem(mountpoint string, nodeFs NodeFileSystem, opts *FileSystemOptions) (*MountState, *FileSystemConnector, error) {
conn := NewFileSystemConnector(nodeFs, opts)
mountState := NewMountState(conn)
err := mountState.Mount(mountpoint, nil)
......@@ -17,7 +14,7 @@ func MountNodeFileSystem(mountpoint string, nodeFs NodeFileSystem, opts *FileSys
return mountState, conn, nil
}
func MountPathFileSystem(mountpoint string, pathFs FileSystem, opts *FileSystemOptions) (*MountState, *FileSystemConnector, os.Error) {
func MountPathFileSystem(mountpoint string, pathFs FileSystem, opts *FileSystemOptions) (*MountState, *FileSystemConnector, error) {
nfs := NewPathNodeFs(pathFs, nil)
return MountNodeFileSystem(mountpoint, nfs, opts)
}
......@@ -6,6 +6,7 @@ package fuse
import (
"fmt"
"io"
"log"
"os"
"path/filepath"
......@@ -34,7 +35,7 @@ func (me *LoopbackFileSystem) GetPath(relPath string) string {
func (me *LoopbackFileSystem) GetAttr(name string, context *Context) (fi *os.FileInfo, code Status) {
fullPath := me.GetPath(name)
var err os.Error = nil
var err error = nil
if name == "" {
// When GetAttr is called for the toplevel directory, we always want
// to look through symlinks.
......@@ -66,7 +67,7 @@ func (me *LoopbackFileSystem) OpenDir(name string, context *Context) (stream cha
Mode: infos[i].Mode,
}
}
if len(infos) < want || err == os.EOF {
if len(infos) < want || err == io.EOF {
break
}
if err != nil {
......
......@@ -4,6 +4,7 @@ import (
"bytes"
"exec"
"fmt"
"io"
"io/ioutil"
"log"
"os"
......@@ -52,7 +53,7 @@ func NewTestCase(t *testing.T) *testCase {
const name string = "hello.txt"
const subdir string = "subdir"
var err os.Error
var err error
me.tmpDir, err = ioutil.TempDir("", "go-fuse")
CheckSuccess(err)
me.orig = me.tmpDir + "/orig"
......@@ -567,7 +568,7 @@ func TestLargeRead(t *testing.T) {
total := 0
for {
m, err := g.Read(readSlice)
if m == 0 && err == os.EOF {
if m == 0 && err == io.EOF {
break
}
CheckSuccess(err)
......@@ -629,7 +630,7 @@ func TestLargeDirRead(t *testing.T) {
readSet := make(map[string]bool)
for {
namesRead, err := dir.Readdirnames(200)
if len(namesRead) == 0 || err == os.EOF {
if len(namesRead) == 0 || err == io.EOF {
break
}
CheckSuccess(err)
......
......@@ -31,7 +31,7 @@ func (code Status) Ok() bool {
}
// Convert os.Error back to Errno based errors.
func OsErrorToErrno(err os.Error) Status {
func OsErrorToErrno(err error) Status {
if err != nil {
switch t := err.(type) {
case os.Errno:
......@@ -39,9 +39,9 @@ func OsErrorToErrno(err os.Error) Status {
case *os.SyscallError:
return Status(t.Errno)
case *os.PathError:
return OsErrorToErrno(t.Error)
return OsErrorToErrno(t.Err)
case *os.LinkError:
return OsErrorToErrno(t.Error)
return OsErrorToErrno(t.Err)
default:
log.Println("can't convert error type:", err)
return ENOSYS
......@@ -84,7 +84,7 @@ func writev(fd int, iovecs *syscall.Iovec, cnt int) (n int, errno int) {
return int(n1), int(e1)
}
func Writev(fd int, packet [][]byte) (n int, err os.Error) {
func Writev(fd int, packet [][]byte) (n int, err error) {
iovecs := make([]syscall.Iovec, 0, len(packet))
for _, v := range packet {
......@@ -113,7 +113,7 @@ func ModeToType(mode uint32) uint32 {
return (mode & 0170000) >> 12
}
func CheckSuccess(e os.Error) {
func CheckSuccess(e error) {
if e != nil {
panic(fmt.Sprintf("Unexpected error: %v", e))
}
......
......@@ -2,6 +2,7 @@ package fuse
// Written with a look to http://ptspts.blogspot.com/2009/11/fuse-protocol-tutorial-for-linux-26.html
import (
"errors"
"exec"
"fmt"
"log"
......@@ -14,7 +15,7 @@ import (
var fusermountBinary string
var umountBinary string
func Socketpair(network string) (l, r *os.File, err os.Error) {
func Socketpair(network string) (l, r *os.File, err error) {
var domain int
var typ int
switch network {
......@@ -38,7 +39,7 @@ func Socketpair(network string) (l, r *os.File, err os.Error) {
// Create a FUSE FS on the specified mount point. The returned
// mount point is always absolute.
func mount(mountPoint string, options string) (f *os.File, finalMountPoint string, err os.Error) {
func mount(mountPoint string, options string) (f *os.File, finalMountPoint string, err error) {
local, remote, err := Socketpair("unixgram")
if err != nil {
return
......@@ -77,7 +78,7 @@ func mount(mountPoint string, options string) (f *os.File, finalMountPoint strin
return
}
if w.ExitStatus() != 0 {
err = os.NewError(fmt.Sprintf("fusermount exited with code %d\n", w.ExitStatus()))
err = errors.New(fmt.Sprintf("fusermount exited with code %d\n", w.ExitStatus()))
return
}
......@@ -86,7 +87,7 @@ func mount(mountPoint string, options string) (f *os.File, finalMountPoint strin
return
}
func privilegedUnmount(mountPoint string) os.Error {
func privilegedUnmount(mountPoint string) error {
dir, _ := filepath.Split(mountPoint)
proc, err := os.StartProcess(umountBinary,
[]string{umountBinary, mountPoint},
......@@ -96,12 +97,12 @@ func privilegedUnmount(mountPoint string) os.Error {
}
w, err := os.Wait(proc.Pid, 0)
if w.ExitStatus() != 0 {
return os.NewError(fmt.Sprintf("umount exited with code %d\n", w.ExitStatus()))
return errors.New(fmt.Sprintf("umount exited with code %d\n", w.ExitStatus()))
}
return err
}
func unmount(mountPoint string) (err os.Error) {
func unmount(mountPoint string) (err error) {
if os.Geteuid() == 0 {
return privilegedUnmount(mountPoint)
}
......@@ -117,12 +118,12 @@ func unmount(mountPoint string) (err os.Error) {
return
}
if w.ExitStatus() != 0 {
return os.NewError(fmt.Sprintf("fusermount -u exited with code %d\n", w.ExitStatus()))
return errors.New(fmt.Sprintf("fusermount -u exited with code %d\n", w.ExitStatus()))
}
return
}
func getConnection(local *os.File) (f *os.File, err os.Error) {
func getConnection(local *os.File) (f *os.File, err error) {
var data [4]byte
control := make([]byte, 4*256)
......@@ -138,15 +139,15 @@ func getConnection(local *os.File) (f *os.File, err os.Error) {
fd := *(*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&control[0])) + syscall.SizeofCmsghdr))
if message.Type != 1 {
err = os.NewError(fmt.Sprintf("getConnection: recvmsg returned wrong control type: %d", message.Type))
err = errors.New(fmt.Sprintf("getConnection: recvmsg returned wrong control type: %d", message.Type))
return
}
if oobn <= syscall.SizeofCmsghdr {
err = os.NewError(fmt.Sprintf("getConnection: too short control message. Length: %d", oobn))
err = errors.New(fmt.Sprintf("getConnection: too short control message. Length: %d", oobn))
return
}
if fd < 0 {
err = os.NewError(fmt.Sprintf("getConnection: fd < 0: %d", fd))
err = errors.New(fmt.Sprintf("getConnection: fd < 0: %d", fd))
return
}
f = os.NewFile(int(fd), "<fuseConnection>")
......@@ -154,7 +155,7 @@ func getConnection(local *os.File) (f *os.File, err os.Error) {
}
func init() {
var err os.Error
var err error
fusermountBinary, err = exec.LookPath("fusermount")
if err != nil {
log.Fatal("Could not find fusermount binary: %v", err)
......
......@@ -48,7 +48,7 @@ func (me *MountState) MountPoint() string {
}
// Mount filesystem on mountPoint.
func (me *MountState) Mount(mountPoint string, opts *MountOptions) os.Error {
func (me *MountState) Mount(mountPoint string, opts *MountOptions) error {
if opts == nil {
opts = &MountOptions{
MaxBackground: _DEFAULT_BACKGROUND_TASKS,
......@@ -87,7 +87,7 @@ func (me *MountState) SetRecordStatistics(record bool) {
}
}
func (me *MountState) Unmount() os.Error {
func (me *MountState) Unmount() error {
// Todo: flush/release all files/dirs?
err := unmount(me.mountPoint)
if err == nil {
......@@ -125,7 +125,7 @@ func (me *MountState) newRequest() *request {
}
}
func (me *MountState) readRequest(req *request) os.Error {
func (me *MountState) readRequest(req *request) error {
n, err := me.mountFile.Read(req.inputBuf)
// If we start timing before the read, we may take into
// account waiting for input into the timing.
......@@ -246,7 +246,7 @@ func (me *MountState) write(req *request) Status {
return OK
}
var err os.Error
var err error
if req.flatData == nil {
_, err = me.mountFile.Write(req.outHeaderBytes)
} else {
......
......@@ -43,7 +43,7 @@ type NotifyTest struct {
func NewNotifyTest() *NotifyTest {
me := &NotifyTest{}
me.fs = &NotifyFs{}
var err os.Error
var err error
me.dir, err = ioutil.TempDir("", "go-fuse")
CheckSuccess(err)
entryTtl := 0.1
......
......@@ -163,7 +163,7 @@ func (me *AutoUnionFs) getRoots(path string) []string {
return nil
}
func (me *AutoUnionFs) visit(path string, fi *os.FileInfo, err os.Error) os.Error {
func (me *AutoUnionFs) visit(path string, fi *os.FileInfo, err error) error {
if fi.IsDirectory() {
roots := me.getRoots(path)
if roots != nil {
......@@ -185,7 +185,7 @@ func (me *AutoUnionFs) updateKnownFses() {
dir, _ = os.Stat(path)
me.visit(path, dir, nil)
filepath.Walk(path,
func(path string, fi *os.FileInfo, err os.Error) os.Error {
func(path string, fi *os.FileInfo, err error) error {
return me.visit(path, fi, err)
})
}
......
......@@ -5,7 +5,7 @@ import (
"os"
)
func NewUnionFsFromRoots(roots []string, opts *UnionFsOptions, roCaching bool) (*UnionFs, os.Error) {
func NewUnionFsFromRoots(roots []string, opts *UnionFsOptions, roCaching bool) (*UnionFs, error) {
fses := make([]fuse.FileSystem, 0)
for i, r := range roots {
var fs fuse.FileSystem
......
......@@ -30,7 +30,7 @@ var testOpts = UnionFsOptions{
func freezeRo(dir string) {
err := filepath.Walk(
dir,
func(path string, fi *os.FileInfo, err os.Error) os.Error {
func(path string, fi *os.FileInfo, err error) error {
return os.Chmod(path, (fi.Mode&0777)&^0222)
})
CheckSuccess(err)
......@@ -772,7 +772,7 @@ func TestUnionFsRmRf(t *testing.T) {
}
}
func Readdirnames(dir string) ([]string, os.Error) {
func Readdirnames(dir string) ([]string, error) {
f, err := os.Open(dir)
if err != nil {
return nil, err
......
......@@ -51,7 +51,7 @@ func NewTarTree(r io.Reader) map[string]MemFile {
var longName *string
for {
hdr, err := tr.Next()
if err == os.EOF {
if err == io.EOF {
// end of tar archive
break
}
......@@ -87,7 +87,7 @@ func NewTarTree(r io.Reader) map[string]MemFile {
return files
}
func NewTarCompressedTree(name string, format string) (map[string]MemFile, os.Error) {
func NewTarCompressedTree(name string, format string) (map[string]MemFile, error) {
f, err := os.Open(name)
if err != nil {
return nil, err
......
......@@ -3,6 +3,7 @@ package zipfs
import (
"archive/zip"
"bytes"
"errors"
"fmt"
"github.com/hanwen/go-fuse/fuse"
"io"
......@@ -42,7 +43,7 @@ func (me *ZipFile) Data() []byte {
}
// NewZipTree creates a new file-system for the zip file named name.
func NewZipTree(name string) (map[string]MemFile, os.Error) {
func NewZipTree(name string) (map[string]MemFile, error) {
r, err := zip.OpenReader(name)
if err != nil {
return nil, err
......@@ -61,7 +62,7 @@ func NewZipTree(name string) (map[string]MemFile, os.Error) {
return out, nil
}
func NewArchiveFileSystem(name string) (mfs *MemTreeFs, err os.Error) {
func NewArchiveFileSystem(name string) (mfs *MemTreeFs, err error) {
mfs = &MemTreeFs{}
if strings.HasSuffix(name, ".zip") {
mfs.files, err = NewZipTree(name)
......@@ -84,7 +85,7 @@ func NewArchiveFileSystem(name string) (mfs *MemTreeFs, err os.Error) {
}
if mfs.files == nil {
return nil, os.NewError(fmt.Sprintf("Unknown type for %v", name))
return nil, errors.New(fmt.Sprintf("Unknown type for %v", name))
}
return mfs, nil
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment