Fixed a bug in newInode.

geesefs-0-30-9
Aaron Jacobs 2015-03-02 16:03:44 +11:00
parent 26ac02968d
commit aebfed4d03
2 changed files with 12 additions and 4 deletions

View File

@ -5,6 +5,7 @@ package memfs
import (
"fmt"
"os"
"time"
"github.com/jacobsa/fuse"
@ -57,7 +58,7 @@ func NewMemFS(
}
// Set up the root inode.
fs.inodes[fuse.RootInodeID] = newInode(true) // dir
fs.inodes[fuse.RootInodeID] = newInode(os.ModeDir)
// Set up invariant checking.
fs.mu = syncutil.NewInvariantMutex(fs.checkInvariants)

View File

@ -58,9 +58,12 @@ type inode struct {
contents []byte // GUARDED_BY(mu)
}
func newInode(dir bool) (in *inode) {
func newInode(mode os.FileMode) (in *inode) {
in = &inode{
dir: dir,
dir: (mode&os.ModeDir != 0),
attributes: fuse.InodeAttributes{
Mode: mode,
},
}
in.mu = syncutil.NewInvariantMutex(in.checkInvariants)
@ -75,7 +78,11 @@ func (inode *inode) checkInvariants() {
// Check os.ModeDir.
if inode.dir != (inode.attributes.Mode&os.ModeDir == os.ModeDir) {
panic(fmt.Sprintf("Unexpected mode: %v", inode.attributes.Mode))
panic(
fmt.Sprintf(
"Unexpected mode: %v, dir: %v",
inode.attributes.Mode,
inode.dir))
}
// Check directory-specific stuff.