Commit c81ae6d4 authored by Aaron Jacobs's avatar Aaron Jacobs

Fixed permissions for the root.

parent 44901edc
......@@ -57,9 +57,10 @@ func NewMemFS(
inodes: make([]*inode, fuse.RootInodeID+1),
}
// Set up the root inode.
// Set up the root inode. Its ownership information will later be modified in
// Init.
rootAttrs := fuse.InodeAttributes{
Mode: 0777 | os.ModeDir,
Mode: 0700 | os.ModeDir,
}
fs.inodes[fuse.RootInodeID] = newInode(rootAttrs)
......@@ -70,6 +71,10 @@ func NewMemFS(
return fs
}
////////////////////////////////////////////////////////////////////////
// Helpers
////////////////////////////////////////////////////////////////////////
func (fs *memFS) checkInvariants() {
// Check reserved inodes.
for i := 0; i < fuse.RootInodeID; i++ {
......@@ -109,13 +114,6 @@ func (fs *memFS) checkInvariants() {
}
}
func (fs *memFS) Init(
ctx context.Context,
req *fuse.InitRequest) (resp *fuse.InitResponse, err error) {
resp = &fuse.InitResponse{}
return
}
// Find the given inode and return it with its lock held. Panic if it doesn't
// exist.
//
......@@ -171,6 +169,29 @@ func (fs *memFS) allocateInode(
return
}
////////////////////////////////////////////////////////////////////////
// FileSystem methods
////////////////////////////////////////////////////////////////////////
func (fs *memFS) Init(
ctx context.Context,
req *fuse.InitRequest) (resp *fuse.InitResponse, err error) {
resp = &fuse.InitResponse{}
fs.mu.RLock()
defer fs.mu.RUnlock()
// Update the root inode's ownership information to match the credentials of
// the mounting process.
root := fs.getInodeForModifyingOrDie(fuse.RootInodeID)
defer root.mu.Unlock()
root.attributes.Uid = req.Header.Uid
root.attributes.Gid = req.Header.Gid
return
}
func (fs *memFS) LookUpInode(
ctx context.Context,
req *fuse.LookUpInodeRequest) (resp *fuse.LookUpInodeResponse, err error) {
......
......@@ -59,6 +59,10 @@ type inode struct {
contents []byte // GUARDED_BY(mu)
}
////////////////////////////////////////////////////////////////////////
// Helpers
////////////////////////////////////////////////////////////////////////
func newInode(attrs fuse.InodeAttributes) (in *inode) {
in = &inode{
dir: (attrs.Mode&os.ModeDir != 0),
......@@ -112,6 +116,10 @@ func (inode *inode) checkInvariants() {
}
}
////////////////////////////////////////////////////////////////////////
// Public methods
////////////////////////////////////////////////////////////////////////
// Find an entry for the given child name and return its inode ID.
//
// REQUIRES: inode.dir
......
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