Commit 3076da56 authored by Aaron Jacobs's avatar Aaron Jacobs

Fixed an inode invariants bug.

parent 27731334
...@@ -179,23 +179,31 @@ func (inode *inode) AddChild( ...@@ -179,23 +179,31 @@ func (inode *inode) AddChild(
id fuse.InodeID, id fuse.InodeID,
name string, name string,
dt fuseutil.DirentType) { dt fuseutil.DirentType) {
var index int
// No matter where we place the entry, make sure it has the correct Offset
// field.
defer func() {
inode.entries[index].Offset = fuse.DirOffset(index + 1)
}()
// Set up the entry. // Set up the entry.
e := fuseutil.Dirent{ e := fuseutil.Dirent{
Offset: fuse.DirOffset(len(inode.entries) + 1), Inode: id,
Inode: id, Name: name,
Name: name, Type: dt,
Type: dt,
} }
// Look for a gap in which we can insert it. // Look for a gap in which we can insert it.
for i := range inode.entries { for index = range inode.entries {
if inode.entries[i].Type == fuseutil.DT_Unknown { if inode.entries[index].Type == fuseutil.DT_Unknown {
inode.entries[i] = e inode.entries[index] = e
return return
} }
} }
// Append it to the end. // Append it to the end.
index = len(inode.entries)
inode.entries = append(inode.entries, e) inode.entries = append(inode.entries, e)
} }
......
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