From: Kir Kolyshkin Date: Wed, 29 May 2024 00:23:15 +0000 (-0700) Subject: os: openDir: add O_DIRECTORY flag for unix X-Git-Tag: go1.24rc1~1129 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=400e6b68b55e20f49f10aaf69df5e3b298b02ad7;p=gostls13.git os: openDir: add O_DIRECTORY flag for unix With this, ReadDir will fail a tad earlier (on open rather than on readdir syscall). This should be the only effect of this change. Change-Id: Icf2870f47ea6c19aad29670e78ba9bfcc13c0ac3 Reviewed-on: https://go-review.googlesource.com/c/go/+/588915 LUCI-TryBot-Result: Go LUCI Reviewed-by: Tobias Klauser Reviewed-by: Cherry Mui Reviewed-by: Ian Lance Taylor Auto-Submit: Ian Lance Taylor --- diff --git a/src/os/file_unix.go b/src/os/file_unix.go index 37bfaa1a72..73069faa56 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 {