]> Cypherpunks repositories - gostls13.git/commitdiff
os: openDir: add O_DIRECTORY flag for unix
authorKir Kolyshkin <kolyshkin@gmail.com>
Wed, 29 May 2024 00:23:15 +0000 (17:23 -0700)
committerGopher Robot <gobot@golang.org>
Thu, 22 Aug 2024 15:01:14 +0000 (15:01 +0000)
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 <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

src/os/file_unix.go

index 37bfaa1a72dfaebbd5a97454e46538ced9c7dd49..73069faa56796d102c98a329a3c706b89ea71fca 100644 (file)
@@ -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 {