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