Commit aebfed4d authored by Aaron Jacobs's avatar Aaron Jacobs

Fixed a bug in newInode.

parent 26ac0296
...@@ -5,6 +5,7 @@ package memfs ...@@ -5,6 +5,7 @@ package memfs
import ( import (
"fmt" "fmt"
"os"
"time" "time"
"github.com/jacobsa/fuse" "github.com/jacobsa/fuse"
...@@ -57,7 +58,7 @@ func NewMemFS( ...@@ -57,7 +58,7 @@ func NewMemFS(
} }
// Set up the root inode. // Set up the root inode.
fs.inodes[fuse.RootInodeID] = newInode(true) // dir fs.inodes[fuse.RootInodeID] = newInode(os.ModeDir)
// Set up invariant checking. // Set up invariant checking.
fs.mu = syncutil.NewInvariantMutex(fs.checkInvariants) fs.mu = syncutil.NewInvariantMutex(fs.checkInvariants)
......
...@@ -58,9 +58,12 @@ type inode struct { ...@@ -58,9 +58,12 @@ type inode struct {
contents []byte // GUARDED_BY(mu) contents []byte // GUARDED_BY(mu)
} }
func newInode(dir bool) (in *inode) { func newInode(mode os.FileMode) (in *inode) {
in = &inode{ in = &inode{
dir: dir, dir: (mode&os.ModeDir != 0),
attributes: fuse.InodeAttributes{
Mode: mode,
},
} }
in.mu = syncutil.NewInvariantMutex(in.checkInvariants) in.mu = syncutil.NewInvariantMutex(in.checkInvariants)
...@@ -75,7 +78,11 @@ func (inode *inode) checkInvariants() { ...@@ -75,7 +78,11 @@ func (inode *inode) checkInvariants() {
// Check os.ModeDir. // Check os.ModeDir.
if inode.dir != (inode.attributes.Mode&os.ModeDir == 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. // 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