Commit 38bf7a6f authored by Ivan Krasin's avatar Ivan Krasin

Simplified FileSystem: *Attr -> Attr

parent 2409b436
...@@ -14,7 +14,7 @@ const ( ...@@ -14,7 +14,7 @@ const (
type FileSystem interface { type FileSystem interface {
List(parent string) (names []string, status Status) List(parent string) (names []string, status Status)
GetAttr(path string) (out *Attr, status Status) GetAttr(path string) (out Attr, status Status)
} }
type Mounted interface { type Mounted interface {
...@@ -187,11 +187,7 @@ func getAttr(fs FileSystem, h *InHeader, ing interface{}, c *managerClient) (int ...@@ -187,11 +187,7 @@ func getAttr(fs FileSystem, h *InHeader, ing interface{}, c *managerClient) (int
if res != OK { if res != OK {
return nil, res return nil, res
} }
if attr != nil { out.Attr = attr
out.Attr = *attr
} else {
return nil, EIO
}
out.Ino = h.NodeId out.Ino = h.NodeId
return out, OK return out, OK
} }
...@@ -266,7 +262,7 @@ func lookup(h *InHeader, r *bytes.Buffer, c *managerClient) (interface{}, Status ...@@ -266,7 +262,7 @@ func lookup(h *InHeader, r *bytes.Buffer, c *managerClient) (interface{}, Status
} }
out := new(EntryOut) out := new(EntryOut)
out.NodeId = resp.nodeId out.NodeId = resp.nodeId
out.Attr = *resp.attr out.Attr = resp.attr
out.AttrValid = 60 out.AttrValid = 60
out.EntryValid = 60 out.EntryValid = 60
return out, OK return out, OK
...@@ -319,7 +315,7 @@ type managerResponse struct { ...@@ -319,7 +315,7 @@ type managerResponse struct {
fh uint64 fh uint64
dirReq chan *dirRequest dirReq chan *dirRequest
status Status status Status
attr *Attr attr Attr
path string path string
} }
...@@ -478,7 +474,6 @@ func (m *manager) lookup(req *managerRequest) (resp *managerResponse) { ...@@ -478,7 +474,6 @@ func (m *manager) lookup(req *managerRequest) (resp *managerResponse) {
if status != OK { if status != OK {
resp.status = status resp.status = status
} }
// 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]
......
...@@ -18,8 +18,7 @@ var ( ...@@ -18,8 +18,7 @@ var (
type testFuse struct{} type testFuse struct{}
func (fs *testFuse) GetAttr(path string) (out *Attr, code Status) { func (fs *testFuse) GetAttr(path string) (out Attr, code Status) {
out = new(Attr)
out.Mode = S_IFDIR out.Mode = S_IFDIR
out.Mtime = uint64(time.Seconds()) out.Mtime = uint64(time.Seconds())
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