Added an invariant for inode size.
parent
163b303731
commit
7bb6fe37d2
|
@ -54,6 +54,7 @@ type inode struct {
|
||||||
// INVARIANT: No non-permission mode bits are set besides os.ModeDir
|
// 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 set
|
||||||
// INVARIANT: If !dir, then os.ModeDir is not set
|
// INVARIANT: If !dir, then os.ModeDir is not set
|
||||||
|
// INVARIANT: attributes.Size == len(contents)
|
||||||
attributes fuse.InodeAttributes // GUARDED_BY(mu)
|
attributes fuse.InodeAttributes // GUARDED_BY(mu)
|
||||||
|
|
||||||
// For directories, entries describing the children of the directory. Unused
|
// 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.")
|
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.
|
// Return the index of the child within inode.entries, if it exists.
|
||||||
|
|
Loading…
Reference in New Issue