Commit adb311bb authored by Ivan Krasin's avatar Ivan Krasin

Eliminated FileSystem.Lookup. Simplifyed FileSystem.GetAttr

parent 3a403f14
......@@ -15,8 +15,7 @@ const (
type FileSystem interface {
List(parent string) (names []string, code Status)
Lookup(parent, filename string) (out *Attr, code Status)
GetAttr(path string, id *Identity) (out *AttrOut, code Status)
GetAttr(path string) (out *Attr, code Status)
}
type Mounted interface {
......@@ -165,7 +164,7 @@ func getAttr(fs FileSystem, h *InHeader, r io.Reader, c *managerClient) (data []
return
}
fmt.Printf("FUSE_GETATTR: %v, Fh: %d\n", in, in.Fh)
var out *AttrOut
out := new(AttrOut)
resp := c.getPath(in.Fh)
if resp.err != nil {
err = resp.err
......@@ -174,13 +173,17 @@ func getAttr(fs FileSystem, h *InHeader, r io.Reader, c *managerClient) (data []
if resp.code != OK {
return serialize(h, resp.code, nil)
}
out, res := fs.GetAttr(resp.path, &h.Identity)
attr, res := fs.GetAttr(resp.path)
if res != OK {
return serialize(h, res, nil)
}
if out != nil {
out.Ino = h.NodeId
if attr != nil {
out.Attr = *attr
} else {
err = os.NewError("fs.GetAttr returned nil as an Attr")
return
}
out.Ino = h.NodeId
data, err = serialize(h, res, out)
return
}
......@@ -503,7 +506,7 @@ 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 := m.fs.Lookup(parent, req.filename)
attr, code := m.fs.GetAttr(path.Join(parent, req.filename))
if code != OK {
resp.code = code
}
......
package fuse
import (
"fmt"
"log"
"os"
"path"
"strings"
"testing"
"time"
......@@ -20,14 +18,7 @@ var (
type testFuse struct{}
func (fs *testFuse) GetAttr(path string, id *Identity) (out *AttrOut, code Status) {
out = new(AttrOut)
out.Mode = S_IFDIR
return
}
func (fs *testFuse) Lookup(parent, filename string) (out *Attr, code Status) {
fmt.Printf("testFuse.Lookup: %s\n", path.Join(parent, filename))
func (fs *testFuse) GetAttr(path string) (out *Attr, code Status) {
out = new(Attr)
out.Mode = S_IFDIR
out.Mtime = uint64(time.Seconds())
......
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