diff --git a/src/os/file_unix.go b/src/os/file_unix.go
index 37bfaa1a72dfaebbd5a97454e46538ced9c7dd49..73069faa56796d102c98a329a3c706b89ea71fca 100644
--- a/src/os/file_unix.go
+++ b/src/os/file_unix.go
@@ -306,7 +306,7 @@ func openDirNolog(name string) (*File, error) {
 		e error
 	)
 	ignoringEINTR(func() error {
-		r, s, e = open(name, O_RDONLY|syscall.O_CLOEXEC, 0)
+		r, s, e = open(name, O_RDONLY|syscall.O_CLOEXEC|syscall.O_DIRECTORY, 0)
 		return e
 	})
 	if e != nil {