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

fuse/nodefs: Set all fields in memNode before making it available.

This fixes the data race in TestDeleteNotify.
parent cb68d31a
......@@ -75,12 +75,6 @@ type memNode struct {
info fuse.Attr
}
func (n *memNode) newNode(name string, isDir bool) *memNode {
newNode := n.fs.newNode()
n.Inode().NewChild(name, isDir, newNode)
return newNode
}
func (n *memNode) filename() string {
return fmt.Sprintf("%s%d", n.fs.backingStorePrefix, n.id)
}
......@@ -98,8 +92,9 @@ func (n *memNode) StatFs() *fuse.StatfsOut {
}
func (n *memNode) Mkdir(name string, mode uint32, context *fuse.Context) (newNode *Inode, code fuse.Status) {
ch := n.newNode(name, true)
ch := n.fs.newNode()
ch.info.Mode = mode | fuse.S_IFDIR
n.Inode().NewChild(name, true, ch)
return ch.Inode(), fuse.OK
}
......@@ -116,10 +111,10 @@ func (n *memNode) Rmdir(name string, context *fuse.Context) (code fuse.Status) {
}
func (n *memNode) Symlink(name string, content string, context *fuse.Context) (newNode *Inode, code fuse.Status) {
ch := n.newNode(name, false)
ch := n.fs.newNode()
ch.info.Mode = fuse.S_IFLNK | 0777
ch.link = content
n.Inode().NewChild(name, false, ch)
return ch.Inode(), fuse.OK
}
......@@ -136,13 +131,14 @@ func (n *memNode) Link(name string, existing Node, context *fuse.Context) (*Inod
}
func (n *memNode) Create(name string, flags uint32, mode uint32, context *fuse.Context) (file File, node *Inode, code fuse.Status) {
ch := n.newNode(name, false)
ch := n.fs.newNode()
ch.info.Mode = mode | fuse.S_IFREG
f, err := os.Create(ch.filename())
if err != nil {
return nil, nil, fuse.ToStatus(err)
}
n.Inode().NewChild(name, false, ch)
return ch.newFile(f), ch.Inode(), fuse.OK
}
......
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