diff --git a/copyOnWriteFs.go b/copyOnWriteFs.go index ed692ae..f2ebcd2 100644 --- a/copyOnWriteFs.go +++ b/copyOnWriteFs.go @@ -80,7 +80,7 @@ func (u *CopyOnWriteFs) Stat(name string) (os.FileInfo, error) { if e, ok := err.(*os.PathError); ok { err = e.Err } - if err == syscall.ENOENT || err == syscall.ENOTDIR { + if err == os.ErrNotExist || err == syscall.ENOENT || err == syscall.ENOTDIR { return u.base.Stat(name) } return nil, origErr diff --git a/copyOnWriteFs_test.go b/copyOnWriteFs_test.go index 2a00fab..c6f2c6d 100644 --- a/copyOnWriteFs_test.go +++ b/copyOnWriteFs_test.go @@ -21,3 +21,19 @@ func TestCopyOnWrite(t *testing.T) { } } + +func TestCopyOnWriteFileInMemMapBase(t *testing.T) { + base := &MemMapFs{} + layer := &MemMapFs{} + + if err := WriteFile(base, "base.txt", []byte("base"), 0755); err != nil { + t.Fatalf("Failed to write file: %s", err) + } + + ufs := NewCopyOnWriteFs(base, layer) + + _, err := ufs.Stat("base.txt") + if err != nil { + t.Fatal(err) + } +}