diff --git a/src/io/fs/readdir_test.go b/src/io/fs/readdir_test.go
index a2b2c121ffadbd32280630a75df42d6b2e12e581..4c409ae7a010e2cb9c202a2431674de39a235f3a 100644
--- a/src/io/fs/readdir_test.go
+++ b/src/io/fs/readdir_test.go
@@ -5,6 +5,7 @@
 package fs_test
 
 import (
+	"errors"
 	. "io/fs"
 	"os"
 	"testing"
@@ -91,3 +92,20 @@ func TestFileInfoToDirEntry(t *testing.T) {
 		})
 	}
 }
+
+func errorPath(err error) string {
+	var perr *PathError
+	if !errors.As(err, &perr) {
+		return ""
+	}
+	return perr.Path
+}
+
+func TestReadDirPath(t *testing.T) {
+	fsys := os.DirFS(t.TempDir())
+	_, err1 := ReadDir(fsys, "non-existent")
+	_, err2 := ReadDir(struct{ FS }{fsys}, "non-existent")
+	if s1, s2 := errorPath(err1), errorPath(err2); s1 != s2 {
+		t.Fatalf("s1: %s != s2: %s", s1, s2)
+	}
+}
diff --git a/src/io/fs/readfile_test.go b/src/io/fs/readfile_test.go
index 07219c14458fe80c33d8d11cb302ed310b9087a2..3c521f61427c2ba1796d314925c1699fc5e4baf3 100644
--- a/src/io/fs/readfile_test.go
+++ b/src/io/fs/readfile_test.go
@@ -6,6 +6,7 @@ package fs_test
 
 import (
 	. "io/fs"
+	"os"
 	"testing"
 	"testing/fstest"
 	"time"
@@ -57,3 +58,12 @@ func TestReadFile(t *testing.T) {
 		t.Fatalf(`ReadFile(sub(.), "hello.txt") = %q, %v, want %q, nil`, data, err, "hello, world")
 	}
 }
+
+func TestReadFilePath(t *testing.T) {
+	fsys := os.DirFS(t.TempDir())
+	_, err1 := ReadFile(fsys, "non-existent")
+	_, err2 := ReadFile(struct{ FS }{fsys}, "non-existent")
+	if s1, s2 := errorPath(err1), errorPath(err2); s1 != s2 {
+		t.Fatalf("s1: %s != s2: %s", s1, s2)
+	}
+}
diff --git a/src/os/file.go b/src/os/file.go
index 37a30ccf041919e6493181a9dcb83bc708eb2abf..6fd0550eeb06b855f5d90b8a3d8e049c45211a01 100644
--- a/src/os/file.go
+++ b/src/os/file.go
@@ -690,7 +690,15 @@ func (dir dirFS) ReadFile(name string) ([]byte, error) {
 	if err != nil {
 		return nil, &PathError{Op: "readfile", Path: name, Err: err}
 	}
-	return ReadFile(fullname)
+	b, err := ReadFile(fullname)
+	if err != nil {
+		if e, ok := err.(*PathError); ok {
+			// See comment in dirFS.Open.
+			e.Path = name
+		}
+		return nil, err
+	}
+	return b, nil
 }
 
 // ReadDir reads the named directory, returning all its directory entries sorted
@@ -700,7 +708,15 @@ func (dir dirFS) ReadDir(name string) ([]DirEntry, error) {
 	if err != nil {
 		return nil, &PathError{Op: "readdir", Path: name, Err: err}
 	}
-	return ReadDir(fullname)
+	entries, err := ReadDir(fullname)
+	if err != nil {
+		if e, ok := err.(*PathError); ok {
+			// See comment in dirFS.Open.
+			e.Path = name
+		}
+		return nil, err
+	}
+	return entries, nil
 }
 
 func (dir dirFS) Stat(name string) (fs.FileInfo, error) {