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(
id fuse.InodeID,
name string,
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.
e := fuseutil.Dirent{
Offset: fuse.DirOffset(len(inode.entries) + 1),
Inode: id,
Name: name,
Type: dt,
}
// Look for a gap in which we can insert it.
for i := range inode.entries {
if inode.entries[i].Type == fuseutil.DT_Unknown {
inode.entries[i] = e
for index = range inode.entries {
if inode.entries[index].Type == fuseutil.DT_Unknown {
inode.entries[index] = e
return
}
}
// Append it to the end.
index = len(inode.entries)
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