Commit b72bba42 authored by Ivan Krasin's avatar Ivan Krasin

FileSystem members do not return os.Error, just fuse.Error (like OK/EIO/ENOSYS)

parent 5610b3e4
......@@ -14,9 +14,9 @@ const (
)
type FileSystem interface {
List(parent string) (names []string, code Error, err os.Error)
Lookup(parent, filename string) (out *Attr, code Error, err os.Error)
GetAttr(path string, id *Identity, flags uint32) (out *AttrOut, code Error, err os.Error)
List(parent string) (names []string, code Error)
Lookup(parent, filename string) (out *Attr, code Error)
GetAttr(path string, id *Identity, flags uint32) (out *AttrOut, code Error)
}
type Mounted interface {
......@@ -174,9 +174,9 @@ func getAttr(fs FileSystem, h *InHeader, r io.Reader, c *managerClient) (data []
if resp.code != OK {
return serialize(h, resp.code, nil)
}
out, res, err := fs.GetAttr(resp.path, &h.Identity, in.GetAttrFlags)
if err != nil {
return
out, res := fs.GetAttr(resp.path, &h.Identity, in.GetAttrFlags)
if res != OK {
return serialize(h, res, nil)
}
if out != nil {
out.Ino = h.NodeId
......@@ -503,14 +503,11 @@ func (m *manager) lookup(req *managerRequest) (resp *managerResponse) {
resp.err = os.NewError(fmt.Sprintf("lookup: can't lookup parent node with id: %d", req.nodeId))
return
}
attr, code, err := m.fs.Lookup(parent, req.filename)
if err != nil {
resp.err = err
return
}
attr, code := m.fs.Lookup(parent, req.filename)
if code != OK {
resp.code = code
}
// TODO: sanitize return values, like checking attr != nil
resp.attr = attr
fullPath := path.Clean(path.Join(parent, req.filename))
nodeId, ok := m.nodesByPath[fullPath]
......@@ -544,13 +541,9 @@ func (m *manager) getPath(req *managerRequest) (resp *managerResponse) {
func readDirRoutine(dir string, fs FileSystem, c *managerClient, requests chan *dirRequest) {
defer close(requests)
dir = path.Clean(dir)
names, code, err := fs.List(dir)
names, code := fs.List(dir)
i := uint64(0)
for req := range requests {
if err != nil {
req.resp <- &dirResponse{nil, err}
return
}
if code != OK {
req.resp <- &dirResponse{nil, os.NewError(fmt.Sprintf("fs.List returned code: %d", code))}
return
......
......@@ -11,7 +11,7 @@ import (
)
const (
tempMountDir = "./.testMountDir"
tempMountDir = "testMountDir"
)
var (
......@@ -20,13 +20,13 @@ var (
type testFuse struct{}
func (fs *testFuse) GetAttr(path string, id *Identity, flags uint32) (out *AttrOut, code Error, err os.Error) {
func (fs *testFuse) GetAttr(path string, id *Identity, flags uint32) (out *AttrOut, code Error) {
out = new(AttrOut)
out.Mode = S_IFDIR
return
}
func (fs *testFuse) Lookup(parent, filename string) (out *Attr, code Error, err os.Error) {
func (fs *testFuse) Lookup(parent, filename string) (out *Attr, code Error) {
fmt.Printf("testFuse.Lookup: %s\n", path.Join(parent, filename))
out = new(Attr)
out.Mode = S_IFDIR
......@@ -34,7 +34,7 @@ func (fs *testFuse) Lookup(parent, filename string) (out *Attr, code Error, err
return
}
func (fs *testFuse) List(dir string) (names []string, code Error, err os.Error) {
func (fs *testFuse) List(dir string) (names []string, code Error) {
names = testFileNames
return
}
......
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