Commit 4c504db8 authored by Ivan Krasin's avatar Ivan Krasin

Fixed GetAttr: it need to look at NodeId, not Fh. Also, tested that 0755 mode works

parent 38bf7a6f
...@@ -179,7 +179,7 @@ func getAttr(fs FileSystem, h *InHeader, ing interface{}, c *managerClient) (int ...@@ -179,7 +179,7 @@ func getAttr(fs FileSystem, h *InHeader, ing interface{}, c *managerClient) (int
in := ing.(*GetAttrIn) in := ing.(*GetAttrIn)
fmt.Printf("FUSE_GETATTR: %v, Fh: %d\n", in, in.Fh) fmt.Printf("FUSE_GETATTR: %v, Fh: %d\n", in, in.Fh)
out := new(AttrOut) out := new(AttrOut)
resp := c.getPath(in.Fh) resp := c.getPath(h.NodeId)
if resp.status != OK { if resp.status != OK {
return nil, resp.status return nil, resp.status
} }
...@@ -359,6 +359,7 @@ func startManager(fs FileSystem, requests chan *managerRequest) { ...@@ -359,6 +359,7 @@ func startManager(fs FileSystem, requests chan *managerRequest) {
m.client = &managerClient{requests} m.client = &managerClient{requests}
m.dirHandles = make(map[uint64]*dirHandle) m.dirHandles = make(map[uint64]*dirHandle)
m.nodes = make(map[uint64]string) m.nodes = make(map[uint64]string)
m.nodes[0] = ""
m.nodes[1] = "" // Root m.nodes[1] = "" // Root
m.nodeMax = 1 m.nodeMax = 1
m.nodesByPath = make(map[string]uint64) m.nodesByPath = make(map[string]uint64)
...@@ -391,8 +392,8 @@ func (c *managerClient) getDirReader(nodeId, fh uint64) (resp *managerResponse) ...@@ -391,8 +392,8 @@ func (c *managerClient) getDirReader(nodeId, fh uint64) (resp *managerResponse)
return c.makeManagerRequest(nodeId, fh, getHandleOp, "") return c.makeManagerRequest(nodeId, fh, getHandleOp, "")
} }
func (c *managerClient) getPath(fh uint64) (resp *managerResponse) { func (c *managerClient) getPath(nodeId uint64) (resp *managerResponse) {
return c.makeManagerRequest(0, fh, getPathOp, "") return c.makeManagerRequest(nodeId, 0, getPathOp, "")
} }
func (c *managerClient) closeDir(nodeId, fh uint64) (resp *managerResponse) { func (c *managerClient) closeDir(nodeId, fh uint64) (resp *managerResponse) {
...@@ -490,12 +491,7 @@ func (m *manager) lookup(req *managerRequest) (resp *managerResponse) { ...@@ -490,12 +491,7 @@ func (m *manager) lookup(req *managerRequest) (resp *managerResponse) {
func (m *manager) getPath(req *managerRequest) (resp *managerResponse) { func (m *manager) getPath(req *managerRequest) (resp *managerResponse) {
resp = new(managerResponse) resp = new(managerResponse)
h, ok := m.dirHandles[req.fh] path, ok := m.nodes[req.nodeId]
if !ok {
resp.status = ENOENT
return
}
path, ok := m.nodes[h.nodeId]
if !ok { if !ok {
resp.status = ENOENT resp.status = ENOENT
return return
......
...@@ -19,7 +19,7 @@ var ( ...@@ -19,7 +19,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.Mode = S_IFDIR out.Mode = S_IFDIR + 0755
out.Mtime = uint64(time.Seconds()) out.Mtime = uint64(time.Seconds())
return return
} }
...@@ -41,12 +41,6 @@ func errorHandler(errors chan os.Error) { ...@@ -41,12 +41,6 @@ func errorHandler(errors chan os.Error) {
func TestMount(t *testing.T) { func TestMount(t *testing.T) {
fs := new(testFuse) fs := new(testFuse)
// toW := make(chan [][]byte, 100)
// errors := make(chan os.Error, 100)
// in_data := []byte { 56, 0, 0, 0, 26, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 13, 0, 0, 0, 0, 0, 2, 0, 123, 0, 0, 0, }
// handle(fs, in_data, toW, errors)
// return
err := os.Mkdir(tempMountDir, 0777) err := os.Mkdir(tempMountDir, 0777)
if err != nil { if err != nil {
......
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