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

UnionFs: implement Chown.

parent 1f07b43d
......@@ -368,6 +368,33 @@ func (me *UnionFs) Utimens(name string, atime uint64, ctime uint64) (code fuse.S
return code
}
func (me *UnionFs) Chown(name string, uid uint32, gid uint32) (code fuse.Status) {
name = stripSlash(name)
r := me.getBranch(name)
if r.attr == nil || r.code != fuse.OK {
return r.code
}
if os.Geteuid() != 0 {
return fuse.EPERM
}
if r.attr.Owner.Uid != uid || r.attr.Owner.Gid != gid {
if r.branch > 0 {
code := me.Promote(name, r)
if code != fuse.OK {
return code
}
r.branch = 0
}
me.fileSystems[0].Chown(name, uid, gid)
}
r.attr.Owner.Uid = uid
r.attr.Owner.Gid = gid
me.branchCache.Set(name, r)
return fuse.OK
}
func (me *UnionFs) Chmod(name string, mode uint32) (code fuse.Status) {
name = stripSlash(name)
r := me.getBranch(name)
......
......@@ -160,6 +160,12 @@ func TestChmod(t *testing.T) {
err := os.Chmod(m_fn, 07070)
CheckSuccess(err)
err = os.Chown(m_fn, 0, 0)
code := fuse.OsErrorToErrno(err)
if code != fuse.EPERM {
t.Error("Unexpected error code", code, err)
}
fi, err := os.Lstat(m_fn)
CheckSuccess(err)
if fi.Mode&07777 != 07070 {
......
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