prevent changes when O_RDONLY is set

This commit is contained in:
Hanno Hecker 2016-01-02 17:16:33 +01:00
parent e7cb826c1f
commit 8064ebdcd1
1 changed files with 3 additions and 0 deletions

View File

@ -207,6 +207,9 @@ func (m *MemMapFs) lockfreeOpen(name string) (File, error) {
func (m *MemMapFs) OpenFile(name string, flag int, perm os.FileMode) (File, error) {
file, err := m.Open(name)
if flag&os.O_RDONLY > 0 {
return file, err
}
if os.IsNotExist(err) && (flag&os.O_CREATE > 0) {
file, err = m.Create(name)
}