Commit aebfed4d authored by Aaron Jacobs's avatar Aaron Jacobs

Fixed a bug in newInode.

parent 26ac0296
......@@ -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)
......
......@@ -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.
......
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