Fixed permissions behavior in hellofs.

The tests were recently broken on Linux when default_permissions was set
when mounting. On Linux (but not on OS X), the uid sending the Init
request is root, so all of the files appear to be owned by root. This
was fine until we told the kernel to check permissions.
geesefs-0-30-9
Aaron Jacobs 2015-03-17 16:35:31 +11:00
parent 92569b4f77
commit e85990c143
2 changed files with 10 additions and 18 deletions

View File

@ -35,10 +35,6 @@ import (
type HelloFS struct {
fuseutil.NotImplementedFileSystem
Clock timeutil.Clock
// Set by Init.
Uid uint32
Gid uint32
}
var _ fuse.FileSystem = &HelloFS{}
@ -65,7 +61,7 @@ var gInodeInfo = map[fuse.InodeID]inodeInfo{
// root
rootInode: inodeInfo{
attributes: fuse.InodeAttributes{
Mode: 0500 | os.ModeDir,
Mode: 0555 | os.ModeDir,
},
dir: true,
children: []fuseutil.Dirent{
@ -87,7 +83,7 @@ var gInodeInfo = map[fuse.InodeID]inodeInfo{
// hello
helloInode: inodeInfo{
attributes: fuse.InodeAttributes{
Mode: 0400,
Mode: 0444,
Size: uint64(len("Hello, world!")),
},
},
@ -95,7 +91,7 @@ var gInodeInfo = map[fuse.InodeID]inodeInfo{
// dir
dirInode: inodeInfo{
attributes: fuse.InodeAttributes{
Mode: 0500 | os.ModeDir,
Mode: 0555 | os.ModeDir,
},
dir: true,
children: []fuseutil.Dirent{
@ -111,7 +107,7 @@ var gInodeInfo = map[fuse.InodeID]inodeInfo{
// world
worldInode: inodeInfo{
attributes: fuse.InodeAttributes{
Mode: 0400,
Mode: 0444,
Size: uint64(len("Hello, world!")),
},
},
@ -134,8 +130,6 @@ func findChildInode(
func (fs *HelloFS) patchAttributes(
attr *fuse.InodeAttributes) {
now := fs.Clock.Now()
attr.Uid = fs.Uid
attr.Gid = fs.Gid
attr.Atime = now
attr.Mtime = now
attr.Crtime = now
@ -146,8 +140,6 @@ func (fs *HelloFS) Init(
req *fuse.InitRequest) (
resp *fuse.InitResponse, err error) {
resp = &fuse.InitResponse{}
fs.Uid = req.Header.Uid
fs.Gid = req.Header.Gid
return
}

View File

@ -113,7 +113,7 @@ func (t *HelloFSTest) ReadDir_Root() {
fi = entries[0]
ExpectEq("dir", fi.Name())
ExpectEq(0, fi.Size())
ExpectEq(os.ModeDir|0500, fi.Mode())
ExpectEq(os.ModeDir|0555, fi.Mode())
ExpectEq(0, t.clock.Now().Sub(fi.ModTime()), "ModTime: %v", fi.ModTime())
ExpectTrue(fi.IsDir())
@ -121,7 +121,7 @@ func (t *HelloFSTest) ReadDir_Root() {
fi = entries[1]
ExpectEq("hello", fi.Name())
ExpectEq(len("Hello, world!"), fi.Size())
ExpectEq(0400, fi.Mode())
ExpectEq(0444, fi.Mode())
ExpectEq(0, t.clock.Now().Sub(fi.ModTime()), "ModTime: %v", fi.ModTime())
ExpectFalse(fi.IsDir())
}
@ -137,7 +137,7 @@ func (t *HelloFSTest) ReadDir_Dir() {
fi = entries[0]
ExpectEq("world", fi.Name())
ExpectEq(len("Hello, world!"), fi.Size())
ExpectEq(0400, fi.Mode())
ExpectEq(0444, fi.Mode())
ExpectEq(0, t.clock.Now().Sub(fi.ModTime()), "ModTime: %v", fi.ModTime())
ExpectFalse(fi.IsDir())
}
@ -155,7 +155,7 @@ func (t *HelloFSTest) Stat_Hello() {
ExpectEq("hello", fi.Name())
ExpectEq(len("Hello, world!"), fi.Size())
ExpectEq(0400, fi.Mode())
ExpectEq(0444, fi.Mode())
ExpectEq(0, t.clock.Now().Sub(fi.ModTime()), "ModTime: %v", fi.ModTime())
ExpectFalse(fi.IsDir())
}
@ -166,7 +166,7 @@ func (t *HelloFSTest) Stat_Dir() {
ExpectEq("dir", fi.Name())
ExpectEq(0, fi.Size())
ExpectEq(0500|os.ModeDir, fi.Mode())
ExpectEq(0555|os.ModeDir, fi.Mode())
ExpectEq(0, t.clock.Now().Sub(fi.ModTime()), "ModTime: %v", fi.ModTime())
ExpectTrue(fi.IsDir())
}
@ -177,7 +177,7 @@ func (t *HelloFSTest) Stat_World() {
ExpectEq("world", fi.Name())
ExpectEq(len("Hello, world!"), fi.Size())
ExpectEq(0400, fi.Mode())
ExpectEq(0444, fi.Mode())
ExpectEq(0, t.clock.Now().Sub(fi.ModTime()), "ModTime: %v", fi.ModTime())
ExpectFalse(fi.IsDir())
}