mirror of
https://github.com/golang/go
synced 2024-11-16 22:44:49 -07:00
testing/fstest: MapFS: set perm 0555 on synthetized dirs
As MapFS ignores filemodes and always grant read and traverse access on directories, let's make synthetized directory entries to expose filemode 0555 instead of 0000. Fixes #63468. Change-Id: I5d64a6bf2f2ac6082ca5dde55b3062669fb50b8d Reviewed-on: https://go-review.googlesource.com/c/go/+/534075 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
7241fee9b0
commit
09aada24aa
@ -98,14 +98,14 @@ func (fsys MapFS) Open(name string) (fs.File, error) {
|
|||||||
delete(need, fi.name)
|
delete(need, fi.name)
|
||||||
}
|
}
|
||||||
for name := range need {
|
for name := range need {
|
||||||
list = append(list, mapFileInfo{name, &MapFile{Mode: fs.ModeDir}})
|
list = append(list, mapFileInfo{name, &MapFile{Mode: fs.ModeDir | 0555}})
|
||||||
}
|
}
|
||||||
sort.Slice(list, func(i, j int) bool {
|
sort.Slice(list, func(i, j int) bool {
|
||||||
return list[i].name < list[j].name
|
return list[i].name < list[j].name
|
||||||
})
|
})
|
||||||
|
|
||||||
if file == nil {
|
if file == nil {
|
||||||
file = &MapFile{Mode: fs.ModeDir}
|
file = &MapFile{Mode: fs.ModeDir | 0555}
|
||||||
}
|
}
|
||||||
return &mapDir{name, mapFileInfo{elem, file}, list, 0}, nil
|
return &mapDir{name, mapFileInfo{elem, file}, list, 0}, nil
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ func TestMapFS(t *testing.T) {
|
|||||||
"hello": {Data: []byte("hello, world\n")},
|
"hello": {Data: []byte("hello, world\n")},
|
||||||
"fortune/k/ken.txt": {Data: []byte("If a program is too slow, it must have a loop.\n")},
|
"fortune/k/ken.txt": {Data: []byte("If a program is too slow, it must have a loop.\n")},
|
||||||
}
|
}
|
||||||
if err := TestFS(m, "hello", "fortune/k/ken.txt"); err != nil {
|
if err := TestFS(m, "hello", "fortune", "fortune/k", "fortune/k/ken.txt"); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -37,7 +37,7 @@ func TestMapFSChmodDot(t *testing.T) {
|
|||||||
})
|
})
|
||||||
want := `
|
want := `
|
||||||
.: drwxrwxrwx
|
.: drwxrwxrwx
|
||||||
a: d---------
|
a: dr-xr-xr-x
|
||||||
a/b.txt: -rw-rw-rw-
|
a/b.txt: -rw-rw-rw-
|
||||||
`[1:]
|
`[1:]
|
||||||
got := buf.String()
|
got := buf.String()
|
||||||
|
Loading…
Reference in New Issue
Block a user