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

Strip W_OK from Access mask.

parent d8568ab6
...@@ -458,11 +458,12 @@ func (me *UnionFs) Chmod(name string, mode uint32) (code fuse.Status) { ...@@ -458,11 +458,12 @@ func (me *UnionFs) Chmod(name string, mode uint32) (code fuse.Status) {
} }
func (me *UnionFs) Access(name string, mode uint32) (code fuse.Status) { func (me *UnionFs) Access(name string, mode uint32) (code fuse.Status) {
// We always allow writing.
mode = mode &^ fuse.W_OK
r := me.getBranch(name) r := me.getBranch(name)
if r.branch >= 0 { if r.branch >= 0 {
return me.fileSystems[r.branch].Access(name, mode) return me.fileSystems[r.branch].Access(name, mode)
} }
return fuse.ENOENT return fuse.ENOENT
} }
......
...@@ -6,6 +6,7 @@ import ( ...@@ -6,6 +6,7 @@ import (
"io/ioutil" "io/ioutil"
"fmt" "fmt"
"log" "log"
"syscall"
"testing" "testing"
"time" "time"
) )
...@@ -420,6 +421,23 @@ func TestWritableDir(t *testing.T) { ...@@ -420,6 +421,23 @@ func TestWritableDir(t *testing.T) {
} }
} }
func TestWriteAccess(t *testing.T) {
t.Log("TestWriteAccess")
wd, clean := setupUfs(t)
defer clean()
fn := wd + "/ro/file"
// No write perms.
err := ioutil.WriteFile(fn, []byte("foo"), 0444)
CheckSuccess(err)
errno := syscall.Access(wd + "/mount/file", fuse.W_OK)
if errno != 0 {
err = os.Errno(errno)
CheckSuccess(err)
}
}
func TestTruncate(t *testing.T) { func TestTruncate(t *testing.T) {
t.Log("TestTruncate") t.Log("TestTruncate")
wd, clean := setupUfs(t) wd, clean := setupUfs(t)
......
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