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

Add 0222 implicitly in Chmod as well.

parent 397fa2e1
...@@ -391,11 +391,11 @@ func (me *UnionFs) Chmod(name string, mode uint32) (code fuse.Status) { ...@@ -391,11 +391,11 @@ func (me *UnionFs) Chmod(name string, mode uint32) (code fuse.Status) {
if r.code != fuse.OK { if r.code != fuse.OK {
return r.code return r.code
} }
if r.attr.Mode&fuse.S_IFREG == 0 {
return fuse.EPERM
}
permMask := uint32(07777) permMask := uint32(07777)
// Always be writable.
mode |= 0222
oldMode := r.attr.Mode & permMask oldMode := r.attr.Mode & permMask
if oldMode != mode { if oldMode != mode {
...@@ -408,7 +408,7 @@ func (me *UnionFs) Chmod(name string, mode uint32) (code fuse.Status) { ...@@ -408,7 +408,7 @@ func (me *UnionFs) Chmod(name string, mode uint32) (code fuse.Status) {
} }
me.fileSystems[0].Chmod(name, mode) me.fileSystems[0].Chmod(name, mode)
} }
r.attr.Mode = (r.attr.Mode &^ 07777) | mode r.attr.Mode = (r.attr.Mode &^ permMask) | mode
r.attr.Ctime_ns = time.Nanoseconds() r.attr.Ctime_ns = time.Nanoseconds()
me.branchCache.Set(name, r) me.branchCache.Set(name, r)
return fuse.OK return fuse.OK
......
...@@ -170,7 +170,7 @@ func TestChmod(t *testing.T) { ...@@ -170,7 +170,7 @@ func TestChmod(t *testing.T) {
fi, err := os.Lstat(m_fn) fi, err := os.Lstat(m_fn)
CheckSuccess(err) CheckSuccess(err)
if fi.Mode&07777 != 07070 { if fi.Mode&07777 != 07272 {
t.Errorf("Unexpected mode found: %o", fi.Mode) t.Errorf("Unexpected mode found: %o", fi.Mode)
} }
_, err = os.Lstat(wd + "/rw/file") _, err = os.Lstat(wd + "/rw/file")
......
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