Fixed a panic.

geesefs-0-30-9
Aaron Jacobs 2015-03-31 09:48:50 +11:00
parent d0a8174ec0
commit 50cda17355
1 changed files with 19 additions and 5 deletions

View File

@ -129,11 +129,27 @@ type fsImpl struct {
nextInodeID fuseops.InodeID nextInodeID fuseops.InodeID
} }
////////////////////////////////////////////////////////////////////////
// inode
////////////////////////////////////////////////////////////////////////
type inode struct { type inode struct {
attributes fuseops.InodeAttributes attributes fuseops.InodeAttributes
// The current lookup count. // The current lookup count.
lookupCount int lookupCount int
// true if lookupCount has ever been positive.
lookedUp bool
}
func (in *inode) Forgotten() bool {
return in.lookedUp && in.lookupCount <= 0
}
func (in *inode) IncrementLookupCount() {
in.lookupCount++
in.lookedUp = true
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@ -178,7 +194,7 @@ func (fs *fsImpl) findInodeByID(id fuseops.InodeID) (in *inode) {
panic(fmt.Sprintf("Unknown inode: %v", id)) panic(fmt.Sprintf("Unknown inode: %v", id))
} }
if in.lookupCount <= 0 { if in.Forgotten() {
panic(fmt.Sprintf("Forgotten inode: %v", id)) panic(fmt.Sprintf("Forgotten inode: %v", id))
} }
@ -222,11 +238,9 @@ func (fs *fsImpl) LookUpInode(
return return
} }
// Find the child. // Look up the child.
child := fs.findInodeByID(childID) child := fs.findInodeByID(childID)
child.IncrementLookupCount()
// Increment the child's lookup count.
child.lookupCount++
// Return an appropriate entry. // Return an appropriate entry.
op.Entry = fuseops.ChildInodeEntry{ op.Entry = fuseops.ChildInodeEntry{