Added an invariant for inode size.

geesefs-0-30-9
Aaron Jacobs 2015-03-05 19:35:32 +11:00
parent 163b303731
commit 7bb6fe37d2
1 changed files with 10 additions and 0 deletions

View File

@ -54,6 +54,7 @@ type inode struct {
// INVARIANT: No non-permission mode bits are set besides os.ModeDir
// INVARIANT: If dir, then os.ModeDir is set
// INVARIANT: If !dir, then os.ModeDir is not set
// INVARIANT: attributes.Size == len(contents)
attributes fuse.InodeAttributes // GUARDED_BY(mu)
// For directories, entries describing the children of the directory. Unused
@ -142,6 +143,15 @@ func (inode *inode) checkInvariants() {
panic("Non-nil entries in a file.")
}
}
// Check the size.
if inode.attributes.Size != uint64(len(inode.contents)) {
panic(
fmt.Sprintf(
"Unexpected size: %v vs. %v",
inode.attributes.Size,
len(inode.contents)))
}
}
// Return the index of the child within inode.entries, if it exists.