Commit adb311bb authored by Ivan Krasin's avatar Ivan Krasin

Eliminated FileSystem.Lookup. Simplifyed FileSystem.GetAttr

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