Commit 7bb6fe37 authored by Aaron Jacobs's avatar Aaron Jacobs

Added an invariant for inode size.

parent 163b3037
......@@ -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.
......
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