Fixed permissions for the root.
parent
44901edc6b
commit
c81ae6d4b3
|
@ -57,9 +57,10 @@ func NewMemFS(
|
||||||
inodes: make([]*inode, fuse.RootInodeID+1),
|
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{
|
rootAttrs := fuse.InodeAttributes{
|
||||||
Mode: 0777 | os.ModeDir,
|
Mode: 0700 | os.ModeDir,
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.inodes[fuse.RootInodeID] = newInode(rootAttrs)
|
fs.inodes[fuse.RootInodeID] = newInode(rootAttrs)
|
||||||
|
@ -70,6 +71,10 @@ func NewMemFS(
|
||||||
return fs
|
return fs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
// Helpers
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
func (fs *memFS) checkInvariants() {
|
func (fs *memFS) checkInvariants() {
|
||||||
// Check reserved inodes.
|
// Check reserved inodes.
|
||||||
for i := 0; i < fuse.RootInodeID; i++ {
|
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
|
// Find the given inode and return it with its lock held. Panic if it doesn't
|
||||||
// exist.
|
// exist.
|
||||||
//
|
//
|
||||||
|
@ -171,6 +169,29 @@ func (fs *memFS) allocateInode(
|
||||||
return
|
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(
|
func (fs *memFS) LookUpInode(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *fuse.LookUpInodeRequest) (resp *fuse.LookUpInodeResponse, err error) {
|
req *fuse.LookUpInodeRequest) (resp *fuse.LookUpInodeResponse, err error) {
|
||||||
|
|
|
@ -59,6 +59,10 @@ type inode struct {
|
||||||
contents []byte // GUARDED_BY(mu)
|
contents []byte // GUARDED_BY(mu)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
// Helpers
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
func newInode(attrs fuse.InodeAttributes) (in *inode) {
|
func newInode(attrs fuse.InodeAttributes) (in *inode) {
|
||||||
in = &inode{
|
in = &inode{
|
||||||
dir: (attrs.Mode&os.ModeDir != 0),
|
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.
|
// Find an entry for the given child name and return its inode ID.
|
||||||
//
|
//
|
||||||
// REQUIRES: inode.dir
|
// REQUIRES: inode.dir
|
||||||
|
|
Loading…
Reference in New Issue