Commit b5f69ec8 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Return the right mode for GetAttr on the root directory.

Change-Id: I8eeddc02b1793fb546aa35f50c99b9e912d19123
parent 98e77584
...@@ -9,14 +9,16 @@ import ( ...@@ -9,14 +9,16 @@ import (
type nodeReadNode struct { type nodeReadNode struct {
Node Node
dir bool
noOpen bool noOpen bool
data []byte data []byte
} }
func newNodeReadNode(noOpen bool, d []byte) *nodeReadNode { func newNodeReadNode(noOpen, dir bool, d []byte) *nodeReadNode {
return &nodeReadNode{ return &nodeReadNode{
Node: NewDefaultNode(), Node: NewDefaultNode(),
noOpen: noOpen, noOpen: noOpen,
dir: dir,
data: d, data: d,
} }
} }
...@@ -37,16 +39,18 @@ func (n *nodeReadNode) Read(file File, dest []byte, off int64, context *fuse.Con ...@@ -37,16 +39,18 @@ func (n *nodeReadNode) Read(file File, dest []byte, off int64, context *fuse.Con
} }
func (n *nodeReadNode) GetAttr(out *fuse.Attr, file File, context *fuse.Context) (code fuse.Status) { func (n *nodeReadNode) GetAttr(out *fuse.Attr, file File, context *fuse.Context) (code fuse.Status) {
out.Mode = fuse.S_IFREG | 0644 if n.dir {
out.Mode = fuse.S_IFDIR | 0755
} else {
out.Mode = fuse.S_IFREG | 0644
}
out.Size = uint64(len(n.data)) out.Size = uint64(len(n.data))
return fuse.OK return fuse.OK
} }
func (n *nodeReadNode) Lookup(out *fuse.Attr, name string, context *fuse.Context) (*Inode, fuse.Status) { func (n *nodeReadNode) Lookup(out *fuse.Attr, name string, context *fuse.Context) (*Inode, fuse.Status) {
out.Mode = fuse.S_IFREG | 0644 ch := n.Inode().NewChild(name, false, newNodeReadNode(n.noOpen, false, []byte(name)))
out.Size = uint64(len(name)) return ch, ch.Node().GetAttr(out, nil, context)
ch := n.Inode().NewChild(name, false, newNodeReadNode(n.noOpen, []byte(name)))
return ch, fuse.OK
} }
func TestNoOpen(t *testing.T) { func TestNoOpen(t *testing.T) {
...@@ -55,7 +59,7 @@ func TestNoOpen(t *testing.T) { ...@@ -55,7 +59,7 @@ func TestNoOpen(t *testing.T) {
t.Fatalf("TempDir: %v", err) t.Fatalf("TempDir: %v", err)
} }
root := newNodeReadNode(true, nil) root := newNodeReadNode(true, true, nil)
root.noOpen = true root.noOpen = true
s, _, err := MountRoot(dir, root, &Options{Debug: VerboseTest()}) s, _, err := MountRoot(dir, root, &Options{Debug: VerboseTest()})
...@@ -96,7 +100,7 @@ func TestNodeRead(t *testing.T) { ...@@ -96,7 +100,7 @@ func TestNodeRead(t *testing.T) {
t.Fatalf("TempDir: %v", err) t.Fatalf("TempDir: %v", err)
} }
root := newNodeReadNode(false, nil) root := newNodeReadNode(false, true, nil)
opts := NewOptions() opts := NewOptions()
opts.Debug = true opts.Debug = true
s, _, err := MountRoot(dir, root, opts) s, _, err := MountRoot(dir, root, opts)
......
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