Commit dd442b25 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Implement Chmod in UnionFs.

parent 92c27574
...@@ -254,6 +254,31 @@ func (me *UnionFs) Symlink(pointedTo string, linkName string) (code fuse.Status) ...@@ -254,6 +254,31 @@ func (me *UnionFs) Symlink(pointedTo string, linkName string) (code fuse.Status)
return code return code
} }
func (me *UnionFs) Chmod(name string, mode uint32) (code fuse.Status) {
r := me.branchCache.Get(name).(getBranchResult)
if r.attr == nil || r.code != fuse.OK {
return r.code
}
if r.attr.Mode & fuse.S_IFREG == 0 {
return fuse.EPERM
}
permMask := uint32(07777)
oldMode := r.attr.Mode & permMask
if oldMode != mode {
if r.branch > 0 {
err := me.Promote(name, me.branches[r.branch])
if err != nil {
panic("copy: " + err.String())
}
}
me.fileSystems[0].Chmod(name, mode)
}
return fuse.OK
}
func (me *UnionFs) Access(name string, mode uint32) (code fuse.Status) { func (me *UnionFs) Access(name string, mode uint32) (code fuse.Status) {
i := me.getBranch(name) i := me.getBranch(name)
if i >= 0 { if i >= 0 {
......
...@@ -145,6 +145,27 @@ func TestSymlink(t *testing.T) { ...@@ -145,6 +145,27 @@ func TestSymlink(t *testing.T) {
} }
} }
func TestChmod(t *testing.T) {
wd, state := setup(t)
defer state.Unmount()
ro_fn := wd+"/ro/file"
m_fn := wd+"/mount/file"
writeToFile(ro_fn, "a", true)
err := os.Chmod(m_fn, 07070)
CheckSuccess(err)
fi, err := os.Lstat(m_fn)
CheckSuccess(err)
if fi.Mode & 07777 != 07070 {
t.Errorf("Unexpected mode found: %v", fi.Mode)
}
_, err = os.Lstat(wd+"/rw/file")
if err != nil {
t.Errorf("File not promoted")
}
}
func TestBasic(t *testing.T) { func TestBasic(t *testing.T) {
wd, state := setup(t) wd, state := setup(t)
defer state.Unmount() defer state.Unmount()
......
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