Skip to content

Commit

Permalink
os,internal/godebugs: add missing IncNonDefault calls
Browse files Browse the repository at this point in the history
Fixes #66215

Change-Id: Id7de15feabe08f66c048dc114c09494813c9febc
Reviewed-on: https://go-review.googlesource.com/c/go/+/570695
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
  • Loading branch information
qmuntal committed Mar 13, 2024
1 parent 381ba9f commit 418e6d5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/internal/godebugs/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ var All = []Info{
{Name: "tlsmaxrsasize", Package: "crypto/tls"},
{Name: "tlsrsakex", Package: "crypto/tls", Changed: 22, Old: "1"},
{Name: "tlsunsafeekm", Package: "crypto/tls", Changed: 22, Old: "1"},
{Name: "winreadlinkvolume", Package: "os", Changed: 22, Old: "0", Opaque: true}, // bug #66215: remove Opaque
{Name: "winsymlink", Package: "os", Changed: 22, Old: "0", Opaque: true}, // bug #66215: remove Opaque
{Name: "winreadlinkvolume", Package: "os", Changed: 22, Old: "0"},
{Name: "winsymlink", Package: "os", Changed: 22, Old: "0"},
{Name: "x509sha1", Package: "crypto/x509"},
{Name: "x509usefallbackroots", Package: "crypto/x509"},
{Name: "x509usepolicies", Package: "crypto/x509"},
Expand Down
1 change: 1 addition & 0 deletions src/os/file_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ func normaliseLinkPath(path string) (string, error) {
if winreadlinkvolume.Value() != "0" {
return `\\?\` + path[4:], nil
}
winreadlinkvolume.IncNonDefault()

h, err := openSymlink(path)
if err != nil {
Expand Down
13 changes: 11 additions & 2 deletions src/os/types_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,19 @@ func (fs *fileStat) Size() int64 {

var winsymlink = godebug.New("winsymlink")

func (fs *fileStat) Mode() (m FileMode) {
func (fs *fileStat) Mode() FileMode {
m := fs.mode()
if winsymlink.Value() == "0" {
return fs.modePreGo1_23()
old := fs.modePreGo1_23()
if old != m {
winsymlink.IncNonDefault()
m = old
}
}
return m
}

func (fs *fileStat) mode() (m FileMode) {
if fs.FileAttributes&syscall.FILE_ATTRIBUTE_READONLY != 0 {
m |= 0444
} else {
Expand Down
8 changes: 8 additions & 0 deletions src/runtime/metrics/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,14 @@ Below is the full list of supported metrics, ordered lexicographically.
The number of non-default behaviors executed by the crypto/tls
package due to a non-default GODEBUG=tlsunsafeekm=... setting.
/godebug/non-default-behavior/winreadlinkvolume:events
The number of non-default behaviors executed by the os package
due to a non-default GODEBUG=winreadlinkvolume=... setting.
/godebug/non-default-behavior/winsymlink:events
The number of non-default behaviors executed by the os package
due to a non-default GODEBUG=winsymlink=... setting.
/godebug/non-default-behavior/x509sha1:events
The number of non-default behaviors executed by the crypto/x509
package due to a non-default GODEBUG=x509sha1=... setting.
Expand Down

0 comments on commit 418e6d5

Please sign in to comment.