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

nodefs: set file type automatically in Lookup/GetAttr/etc.

parent a3ed4324
...@@ -65,16 +65,16 @@ func (b *rawBridge) newInode(node Operations, mode uint32, id FileID, persistent ...@@ -65,16 +65,16 @@ func (b *rawBridge) newInode(node Operations, mode uint32, id FileID, persistent
if old != nil { if old != nil {
return old return old
} }
mode = mode &^ 07777
inode := &Inode{ inode := &Inode{
mode: mode ^ 07777, mode: mode,
node: node, node: node,
nodeID: id, nodeID: id,
bridge: b, bridge: b,
persistent: persistent, persistent: persistent,
parents: make(map[parentData]struct{}), parents: make(map[parentData]struct{}),
} }
if mode&fuse.S_IFDIR != 0 { if mode == fuse.S_IFDIR {
inode.children = make(map[string]*Inode) inode.children = make(map[string]*Inode)
} }
...@@ -142,6 +142,8 @@ func (b *rawBridge) Lookup(header *fuse.InHeader, name string, out *fuse.EntryOu ...@@ -142,6 +142,8 @@ func (b *rawBridge) Lookup(header *fuse.InHeader, name string, out *fuse.EntryOu
b.addNewChild(parent, name, child, nil, out) b.addNewChild(parent, name, child, nil, out)
b.setEntryOutTimeout(out) b.setEntryOutTimeout(out)
out.Mode = child.mode | (out.Mode & 07777)
return fuse.OK return fuse.OK
} }
...@@ -251,9 +253,7 @@ func (b *rawBridge) Create(input *fuse.CreateIn, name string, out *fuse.CreateOu ...@@ -251,9 +253,7 @@ func (b *rawBridge) Create(input *fuse.CreateIn, name string, out *fuse.CreateOu
out.NodeId = child.nodeID.Ino out.NodeId = child.nodeID.Ino
b.setEntryOutTimeout(&out.EntryOut) b.setEntryOutTimeout(&out.EntryOut)
if out.Attr.Mode&^07777 != fuse.S_IFREG { out.Mode = (out.Attr.Mode & 07777) | child.mode
log.Panicf("Create: mode must be S_IFREG (%o), got %o", fuse.S_IFREG, out.Attr.Mode)
}
return fuse.OK return fuse.OK
} }
...@@ -275,6 +275,7 @@ func (b *rawBridge) GetAttr(input *fuse.GetAttrIn, out *fuse.AttrOut) fuse.Statu ...@@ -275,6 +275,7 @@ func (b *rawBridge) GetAttr(input *fuse.GetAttrIn, out *fuse.AttrOut) fuse.Statu
code := n.node.GetAttr(context.TODO(), f, out) code := n.node.GetAttr(context.TODO(), f, out)
b.setAttrTimeout(out) b.setAttrTimeout(out)
out.Ino = input.NodeId out.Ino = input.NodeId
out.Mode = (out.Attr.Mode & 07777) | n.mode
return code return code
} }
...@@ -349,6 +350,7 @@ func (b *rawBridge) SetAttr(input *fuse.SetAttrIn, out *fuse.AttrOut) (code fuse ...@@ -349,6 +350,7 @@ func (b *rawBridge) SetAttr(input *fuse.SetAttrIn, out *fuse.AttrOut) (code fuse
code = n.node.GetAttr(ctx, f, out) code = n.node.GetAttr(ctx, f, out)
b.setAttrTimeout(out) b.setAttrTimeout(out)
out.Ino = n.nodeID.Ino out.Ino = n.nodeID.Ino
out.Mode = n.mode | (out.Mode &^ 07777)
return code return code
} }
......
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