aboutsummaryrefslogtreecommitdiff
path: root/src/os
AgeCommit message (Collapse)Author
2 daysos/exec: on Windows look for extensions in Run if not already doneqiulaidongfeng
CL 512155 fixed #36768, but introduced #62596. CL 527820 fixed #62596, but meant that the code failed to look up file extensions on Windows for a relative path. This CL fixes that problem by recording whether it has already looked up file extensions. This does mean that if Path is set manually then we do not update it with file extensions, as doing that would be racy. Fixes #66586 Change-Id: I9a0305d1e466c5e07bfbe442566ea12f5255a96e GitHub-Last-Rev: dc3169f2350f61acac5ef7842b7514013abacbe1 GitHub-Pull-Request: golang/go#67035 Reviewed-on: https://go-review.googlesource.com/c/go/+/581695 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2 daysos/signal: remove SIGSYS from list of signals that take no actionIan Lance Taylor
It actually causes the program to throw. Fixes #67729 Change-Id: Id970baff631616a4dc4e434827e622e1b16f2724 Reviewed-on: https://go-review.googlesource.com/c/go/+/590915 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
5 daysos/signal: clarify that non-Go thread may change signal maskIan Lance Taylor
Fixes #67773 Change-Id: I05c9934a5b2719d22884c8546f4fadaa9978ac67 Reviewed-on: https://go-review.googlesource.com/c/go/+/589755 Auto-Submit: Ian Lance Taylor <iant@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
11 daysos: RemoveAll: fix symlink race for unixKir Kolyshkin
Since all the platforms now support O_DIRECTORY flag for open, it can be used to (together with O_NOFOLLOW) to ensure we open a directory, thus eliminating the need to call stat before open. This fixes the symlink race, when a directory is replaced by a symlink in between stat and open calls. While at it, rename openFdAt to openDirAt, because this function is (and was) meant for directories only. NOTE Solaris supports O_DIRECTORY since before Solaris 11 (which is the only version Go supports since supported version now), and Illumos always had it. The only missing piece was O_DIRECTORY flag value, which is taken from golang.org/x/sys/unix. Updates #52745. Change-Id: Ic1111d688eebc8804a87d39d3261c2a6eb33f176 Reviewed-on: https://go-review.googlesource.com/c/go/+/588495 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Aleksa Sarai <cyphar@cyphar.com> Reviewed-by: Than McIntosh <thanm@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-05-23all: change from sort functions to slices functions where feasibleIan Lance Taylor
Doing this because the slices functions are slightly faster and slightly easier to use. It also removes one dependency layer. This CL does not change packages that are used during bootstrap, as the bootstrap compiler does not have the required slices functions. It does not change the go/scanner package because the ErrorList Len, Swap, and Less methods are part of the Go 1 API. Change-Id: If52899be791c829198e11d2408727720b91ebe8a Reviewed-on: https://go-review.googlesource.com/c/go/+/587655 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2024-05-21os: make FindProcess use pidfd on LinuxKir Kolyshkin
This is a continuation of CL 570036. Amend FindProcess to use pidfdFind, and make it return a special Process with Pid of pidDone (-2) if the process is not found. Amend Wait and Signal to return ErrProcessDone if pid == pidDone. The alternative to the above would be to make FindProcess return ErrProcessDone, but this is unexpected and incompatible API change, as discussed in #65866 and #51246. For #62654. Rework of CL 542699 (which got reverted in CL 566476). Change-Id: Ifb4cd3ad1433152fd72ee685d0b85d20377f8723 Reviewed-on: https://go-review.googlesource.com/c/go/+/570681 TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-05-17os: make use of pidfd on linuxKir Kolyshkin
Use Process.handle field to store pidfd, and make use of it. Only use pidfd functionality if all the needed syscalls are available. 1. Add/use pidfdWorks, which checks that all needed pidfd-related functionality works. 2. os.StartProcess: obtain the pidfd from the kernel, if possible, using the functionality added by CL 520266. Note we could not modify syscall.StartProcess to return pidfd directly because it is a public API and its callers do not expect it, so we have to use ensurePidfd and getPidfd. 3. (*Process).Kill: use pidfdSendSignal, if available and the pidfd is known. Otherwise, fall back to the old implementation. 4. (*Process).Wait: use pidfdWait, if available, otherwise fall back to using waitid/wait4. This is more complicated than expected due to struct siginfo_t idiosyncrasy. NOTE pidfdSendSignal and pidfdWait are used without a race workaround (blockUntilWaitable and sigMu, added by CL 23967) because with pidfd, PID recycle issue doesn't exist (IOW, pidfd, unlike PID, is guaranteed to refer to one particular process) and thus the race doesn't exist either. Rework of CL 528438 (reverted in CL 566477 because of #65857). For #62654. Updates #13987. Change-Id: If5ef8920bd8619dc428b6282ffe4fb8c258ca224 Reviewed-on: https://go-review.googlesource.com/c/go/+/570036 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Cherry Mui <cherryyz@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2024-05-15cmd/link: disallow pull-only linknamesCherry Mui
As mentioned in CL 584598, linkname is a mechanism that, when abused, can break API integrity and even safety of Go programs. CL 584598 is a first step to restrict the use of linknames, by implementing a blocklist. This CL takes a step further, tightening up the restriction by allowing linkname references ("pull") only when the definition side explicitly opts into it, by having a linkname on the definition (possibly to itself). This way, it is at least clear on the definition side that the symbol, despite being unexported, is accessed outside of the package. Unexported symbols without linkname can now be actually private. This is similar to the symbol visibility rule used by gccgo for years (which defines unexported non-linknamed symbols as C static symbols). As there can be pull-only linknames in the wild that may be broken by this change, we currently only enforce this rule for symbols defined in the standard library. Push linknames are added in the standard library to allow things build. Linkname references to external (non-Go) symbols are still allowed, as their visibility is controlled by the C symbol visibility rules and enforced by the C (static or dynamic) linker. Assembly symbols are treated similar to linknamed symbols. This is controlled by -checklinkname linker flag, currently not enabled by default. A follow-up CL will enable it by default. Change-Id: I07344f5c7a02124dbbef0fbc8fec3b666a4b2b0e Reviewed-on: https://go-review.googlesource.com/c/go/+/585358 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Russ Cox <rsc@golang.org>
2024-05-14os: use internal/byteorderTobias Klauser
Change-Id: Ic88535f05a55966e35e5da7abb499aa5fadb5cc7 Reviewed-on: https://go-review.googlesource.com/c/go/+/585116 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2024-05-10os: change ioutil-test to os-test in testguoguangwu
Change-Id: I8c5c0831b94261c5880ca22b7ea52cce034d88f1 GitHub-Last-Rev: 5fd119d4e8e5f98690afb2d966c07aea19415db0 GitHub-Pull-Request: golang/go#67248 Reviewed-on: https://go-review.googlesource.com/c/go/+/583876 Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-05-07os: use filepathlite.Baseaimuz
Replace custom basename implementations with filepathlite.Base across all relevant os/stat files to unify path processing across platforms. Change-Id: I7c4795661926949bae71e66d8b4f9363e7caef15 GitHub-Last-Rev: 1236e93ebcd4137f9cbbbab2163cadf4e4d02674 GitHub-Pull-Request: golang/go#67195 Reviewed-on: https://go-review.googlesource.com/c/go/+/583415 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-05-05os: use stringslite.TrimSuffixapocelipes
Change-Id: Ie51a1550181c9478455c757fc82a88bc549ad687 GitHub-Last-Rev: 4b6ffd043b0f2acebb8d2477da17a4d1dfe708ed GitHub-Pull-Request: golang/go#67153 Reviewed-on: https://go-review.googlesource.com/c/go/+/583095 Auto-Submit: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-30os: use filepathlite.FromSlashqmuntal
Change-Id: Id15ebd9e97a8626e64665f6830a662e62432a619 Reviewed-on: https://go-review.googlesource.com/c/go/+/582500 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-30os: use filepathlite.VolumeNameqmuntal
It is better to have a single implementation of VolumeName, which is quite tricky to get right on Windows. Change-Id: Ibba82dd71fe10b594cb6f782582430aa422e7078 Reviewed-on: https://go-review.googlesource.com/c/go/+/582499 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-30os: use filepathlite.IsAbsqmuntal
It is better to have a single implementation of IsAbs, which is quite tricky to get right on Windows. Change-Id: I45933b0ceff2920d9eddb61e62aacb2602c3dc8c Reviewed-on: https://go-review.googlesource.com/c/go/+/582498 Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-30os: use stringslite.HasPrefixTobias Klauser
Change-Id: I791bdfecc6c94ee9dac592d60d95e97182bf0120 Reviewed-on: https://go-review.googlesource.com/c/go/+/582496 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Damien Neil <dneil@google.com>
2024-04-30os: remove ineffective else branchqmuntal
Change-Id: Ic9cf871d862aec54ab8f491b8bc8d2820aecc875 Reviewed-on: https://go-review.googlesource.com/c/go/+/582497 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-26all: rename internal/safefilepath to internal/filepathliteDamien Neil
The safefilepath package was originally added to contain the FromFS function. We subsequently added FromFS to path/filepath as Localize. The safefilepath package now exists only to permit the os package to import Localize. Rename safefilepath to filepathlite to better indicate that it's a low-dependency version of filepath. Change-Id: I4c5f9b28e8581f841947b48c5cac9954cd0c9535 Reviewed-on: https://go-review.googlesource.com/c/go/+/581517 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-26net, os, internal/poll: test for use of sendfileDamien Neil
The net package's sendfile tests exercise various paths where we expect sendfile to be used, but don't verify that sendfile was in fact used. Add a hook to internal/poll.SendFile to let us verify that sendfile was called when expected. Update os package tests (which use their own hook mechanism) to use this hook as well. For #66988 Change-Id: I7afb130dcfe0063d60c6ea0f8560cf8665ad5a81 Reviewed-on: https://go-review.googlesource.com/c/go/+/581778 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-23all: fix some typos in commentsracequite
This change fixes some typographic errors that I found in various packages. Change-Id: Ie2d0316f0137d6521496d389a9777659ae22128b GitHub-Last-Rev: 0307b03d50f664a00a4afa5afa08a35efb7f3045 GitHub-Pull-Request: golang/go#66917 Reviewed-on: https://go-review.googlesource.com/c/go/+/580077 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Commit-Queue: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org>
2024-04-16os: remove unused issueNo fieldTobias Klauser
It's no longer set since CL 31118. Change-Id: Ibe77b1454b5e7fd02eaed432f04cf993f53791fc Reviewed-on: https://go-review.googlesource.com/c/go/+/579135 Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
2024-04-15os: make File.Readdir et al concurrency-safeAlan Donovan
Before, all methods of File (including Close) were safe for concurrent use (I checked), except the three variants of ReadDir. This change makes the ReadDir operations atomic too, and documents explicitly that all methods of File have this property, which was already implied by the package documentation. Fixes #66498 Change-Id: I05c88b4e60b44c702062e99ed8f4a32e7945927a Reviewed-on: https://go-review.googlesource.com/c/go/+/578322 Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-12os: document file mode of temporary filesIan Lance Taylor
Fixes #66784 Change-Id: Ifd17e0830e04e7028d8a876c6c12c496f5167887 Reviewed-on: https://go-review.googlesource.com/c/go/+/578395 Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-03os: convert poll.ErrFileClosed to ErrClosed for StatIan Lance Taylor
Fixes #66665 Change-Id: I3e3b7433d245daa997d7d502c2ef8978af6664fb Reviewed-on: https://go-review.googlesource.com/c/go/+/576119 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
2024-04-02internal/poll, net, os: remove poll.Splice syscall name return valueTobias Klauser
The sc return value of internal/poll.Splice is always set to the same value "splice" in the error case and then passed to wrapSyscallError. Move that value to the wrapSyscallError calls to simplify the code a bit. Change-Id: I98104d755da68ff9f301fabc43c2618fda21a175 Reviewed-on: https://go-review.googlesource.com/c/go/+/575655 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2024-04-02os: define wrapSyscallError only on linuxTobias Klauser
wrapSyscallError by now is only used on linux in the methods defined in os/zero_copy_linux.go. Move the definition there. Change-Id: I0ca5749adaac44e8d095b8452458b647f595d3c8 Reviewed-on: https://go-review.googlesource.com/c/go/+/575595 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2024-04-01os: support relative paths in fixLongPathqmuntal
(This CL takes the tests and some ideas from the abandoned CL 263538). fixLongPath is used on Windows to process all path names before syscalls to switch them to extended-length format (with prefix \\?\) to workaround a historical limit of 260-ish characters. This CL updates fixLongPath to convert relative paths to absolute paths if the working directory plus the relative path exceeds MAX_PATH. This is necessary because the Windows API does not support extended-length paths for relative paths. This CL also adds support for fixing device paths (\\.\-prefixed), which were not previously normalized. Fixes #41734 Fixes #21782 Fixes #36375 Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest,gotip-windows-amd64-race,gotip-windows-arm64 Co-authored-by: Giovanni Bajo <rasky@develer.com> Change-Id: I63cfb79f3ae6b9d42e07deac435b730d97a6f492 Reviewed-on: https://go-review.googlesource.com/c/go/+/574695 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2024-03-27os: make readdir more robust on Windowsqmuntal
On Windows, File.readdir currently fails if the volume information can't be retrieved via GetVolumeInformationByHandle and if the directory path is relative and can't be converted to an absolute path. This change makes readdir more robust by not failing in these cases, as these steps are just necessary to support a potential call to os.SameFile, but not for the actual readdir operation. os.SameFile will still fail in these cases, but that's a separate issue tracked in #62042. Change-Id: I8d98d8379bdac4b2832fa433432a5f027756abaa Reviewed-on: https://go-review.googlesource.com/c/go/+/574155 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2024-03-26all: fix a large number of commentscui fliter
Partial typo corrections, following https://go.dev/wiki/Spelling Change-Id: I2357906ff2ea04305c6357418e4e9556e20375d1 Reviewed-on: https://go-review.googlesource.com/c/go/+/573776 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: shuang cui <imcusg@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-03-25os: reuse buffer pool more aggressively in readdirqmuntal
We can reuse the buffer pool more aggressively when reading a directory by returning the buffer to the pool as soon as we get to the end of the directory, rather than waiting until the the os.File is closed. This yields a significant memory usage reduction when traversing nested directories recursively via os.File#ReadDir (and friends), as the file pointers tends to be closed only after the entire traversal is done. For example, this pattern is used in os.RemoveAll. These are the improvements observed in BenchmarkRemoveAll: goos: linux goarch: amd64 pkg: os cpu: AMD EPYC 7763 64-Core Processor │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ RemoveAll-4 3.847m ± 2% 3.823m ± 1% ~ (p=0.143 n=10) │ old.txt │ new.txt │ │ B/op │ B/op vs base │ RemoveAll-4 39.77Ki ± 2% 17.63Ki ± 1% -55.68% (p=0.000 n=10) │ old.txt │ new.txt │ │ allocs/op │ allocs/op vs base │ RemoveAll-4 510.0 ± 0% 503.0 ± 0% -1.37% (p=0.000 n=10) Change-Id: I70e1037378a02f1d670ccb7b275ee55f0caa6d0b Reviewed-on: https://go-review.googlesource.com/c/go/+/573358 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
2024-03-25os: fix typo in testguoguangwu
Change-Id: Ib445940f0f24385dde1b62277c8083e6369d0645 GitHub-Last-Rev: 02c18c27773e966145e379933e4e01d4531e7ec3 GitHub-Pull-Request: golang/go#66503 Reviewed-on: https://go-review.googlesource.com/c/go/+/574016 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2024-03-20os/signal: avoid calling ioctl via syscall.Syscall on BSDsJoel Sing
Provide appropriate implementations of internal/syscall/unix.Tcsetpgrp and use this for runSessionLeader in os/signal/signal_cgo_test.go. This avoids calling syscall.Syscall with SYS_IOCTL on BSDs. Updates #59667 Updates #63900 Change-Id: Ifa4696bba9f1eb68e81e7103f030bc254adaf0af Reviewed-on: https://go-review.googlesource.com/c/go/+/540020 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Joel Sing <joel@sing.id.au>
2024-03-19os: kick FIFOs with O_NONBLOCK out of the kqueue on Darwin/iOSAndy Pan
Fixes #66239 Change-Id: I8210682c0cf4285b950e9fabe687b7ad2369835c Reviewed-on: https://go-review.googlesource.com/c/go/+/570397 Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Run-TryBot: Andy Pan <panjf2000@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2024-03-19os: use ignoringEINTR in openFileNolog and openDirNologAndy Pan
Change-Id: Ie8fa25d5e326efd7d3c9b72203783110d9e22ce8 Reviewed-on: https://go-review.googlesource.com/c/go/+/572215 Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-18os: support UNC paths and .. segments in fixLongPathqmuntal
This CL reimplements fixLongPath using syscall.GetFullPathName instead of a custom implementation that was not handling UNC paths and .. segments correctly. It also fixes a bug here multiple trailing \ were removed instead of replaced by a single one. The new implementation is slower than the previous one, as it does a syscall and needs to convert UTF-8 to UTF-16 (and back), but it is correct and should be fast enough for most use cases. goos: windows goarch: amd64 pkg: os cpu: Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ LongPath-12 1.007µ ± 53% 4.093µ ± 109% +306.41% (p=0.000 n=10) │ old.txt │ new.txt │ │ B/op │ B/op vs base │ LongPath-12 576.0 ± 0% 1376.0 ± 0% +138.89% (p=0.000 n=10) │ old.txt │ new.txt │ │ allocs/op │ allocs/op vs base │ LongPath-12 2.000 ± 0% 3.000 ± 0% +50.00% (p=0.000 n=10) Fixes #41734. Change-Id: Iced5cf47f56f6ab0ca74a6e2374c31a75100902d Reviewed-on: https://go-review.googlesource.com/c/go/+/570995 Reviewed-by: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-16os: don't try to make the directory FD non-blocking in os.ReadDirPeter Collingbourne
This will fail because epoll_ctl() fails on directory FDs, so we end up issuing unnecessary syscalls. My test program that calls filepath.WalkDir on a large directory tree runs 1.23 ± 0.04 times faster than with the original implementation. Change-Id: Ie33d798c48057a7b2d0bacac80fcdde5b5a8bb1b Reviewed-on: https://go-review.googlesource.com/c/go/+/570877 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-03-13os,internal/godebugs: add missing IncNonDefault callsqmuntal
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>
2024-03-11os: close pipe in testguoguangwu
Change-Id: Ic8b06c6fd9fc6a30b26f4e4614aa40b5cad3a5e7 GitHub-Last-Rev: 8397a8b30cf11c00e53b35e528f82a8534a00e01 GitHub-Pull-Request: golang/go#66240 Reviewed-on: https://go-review.googlesource.com/c/go/+/570515 Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-03-08os: use goarch.BigEndianTobias Klauser
Change-Id: I83c23ae0933f6abe4c07144f69c3d9c18aece6e8 Reviewed-on: https://go-review.googlesource.com/c/go/+/569175 Auto-Submit: Ian Lance Taylor <iant@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-03-05os: fix 63703.md release notesqmuntal
63703.md contains a paragraph that shouldn't be there, remove it. While here, fix a test error message related to the #63703 implementation. Updates #63703. Change-Id: I82a8b0b7dfa8f96530fb9a3a3aa971e03970f168 Reviewed-on: https://go-review.googlesource.com/c/go/+/569195 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-04os: don't normalize volumes to drive letters in os.Readlinkqmuntal
This CL updates os.Readlink so it no longer tries to normalize volumes to drive letters, which was not always even possible. This behavior is controlled by the `winreadlinkvolume` setting. For Go 1.23, it defaults to `winreadlinkvolume=1`. Previous versions default to `winreadlinkvolume=0`. Fixes #63703. Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest,gotip-windows-arm64 Change-Id: Icd6fabbc8f0b78e23a82eef8db89940e89e9222d Reviewed-on: https://go-review.googlesource.com/c/go/+/567735 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-04os: don't treat mount points as symbolic linksqmuntal
This CL changes the behavior of os.Lstat to stop setting the os.ModeSymlink type mode bit for mount points on Windows. As a result, filepath.EvalSymlinks no longer evaluates mount points, which was the cause of many inconsistencies and bugs. Additionally, os.Lstat starts setting the os.ModeIrregular type mode bit for all reparse tags on Windows, except for those that are explicitly supported by the os package, which, since this CL, doesn't include mount points. This helps to identify files that need special handling outside of the os package. This behavior is controlled by the `winsymlink` GODEBUG setting. For Go 1.23, it defaults to `winsymlink=1`. Previous versions default to `winsymlink=0`. Fixes #39786 Fixes #40176 Fixes #61893 Updates #63703 Updates #40180 Updates #63429 Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest,gotip-windows-arm64 Change-Id: I2e7372ab8862f5062667d30db6958d972bce5407 Reviewed-on: https://go-review.googlesource.com/c/go/+/565136 Reviewed-by: Bryan Mills <bcmills@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-03-04os/exec: remove unnecessary fmt.Sprintf callguoguangwu
Change-Id: Ic0ac97a15dadd756d727fd8abe23359b0347af19 GitHub-Last-Rev: a96a3f5fe7fbfb41f38acadab3c03c4a76c89b78 GitHub-Pull-Request: golang/go#66052 Reviewed-on: https://go-review.googlesource.com/c/go/+/568317 Reviewed-by: Bryan Mills <bcmills@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Jorropo <jorropo.pgm@gmail.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-03-04os: remove if nil!=nil in openFileNologqiulaidongfeng
Change-Id: I21cecc13570f3b61f3d6c4fede18dc63ddca1b69 GitHub-Last-Rev: 3c351e4aa84780d682fd7595ac2091defdcdfc62 GitHub-Pull-Request: golang/go#65958 Reviewed-on: https://go-review.googlesource.com/c/go/+/567355 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
2024-02-28os: factor out newFileStatFromWin32FileAttributeDataqmuntal
The stat function is quite long on Windows. Simplify it a bit by factoring out the creation of a fileStat from a Win32FileAttributeData. This also makes it more consistent with the creation of fileStats from other sources, which all have their own dedicated functions. Change-Id: I0443f96d892b70ce7f3b5e92c5049e4e4a240c6c Reviewed-on: https://go-review.googlesource.com/c/go/+/566435 Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-27os: avoid GetFileInformationByHandleEx call when stat'ing files on Windowsqmuntal
os.Stat and os.Lstat on Windows use GetFileInformationByHandleEx to retrieve file information for reparse points and files that GetFileAttributesEx does not handle. However, GetFileInformationByHandleEx is only necessary for reparse points, so we can avoid the call for regular files. With this change we can drop the FAT hack that was added in CL 154377, as files won't have the FILE_ATTRIBUTE_REPARSE_POINT attribute set on that file system. Change-Id: Id18639067a6c3fa1bb2c6706d5b79358c224fe37 Reviewed-on: https://go-review.googlesource.com/c/go/+/566397 Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Bryan Mills <bcmills@google.com>
2024-02-26std: fix more nilness findingsAlan Donovan
(found with x/tools/go/analysis/passes/nilness) Change-Id: I1bdc7811efbecea95608e634f894cb6c656e3a5b Reviewed-on: https://go-review.googlesource.com/c/go/+/564221 Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-26os: add available godoc linkcui fliter
Change-Id: I430c9a7c4936d7a8c8c787aa63de9a796d20fdf3 Reviewed-on: https://go-review.googlesource.com/c/go/+/539597 Reviewed-by: Carlos Amedee <carlos@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: shuang cui <imcusg@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-02-26path/filepath: add LocalizeDamien Neil
Add the Localize function, which takes an io/fs slash-separated path and returns an operating system path. Localize returns an error if the path cannot be represented on the current platform. Replace internal/safefile.FromFS with Localize, which serves the same purpose as this function. The internal/safefile package remains separate from path/filepath to avoid a dependency cycle with the os package. Fixes #57151 Change-Id: I75c88047ddea17808276761da07bf79172c4f6fc Reviewed-on: https://go-review.googlesource.com/c/go/+/531677 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-02-23Revert "os: make use of pidfd on linux"Michael Pratt
This reverts CL 528438. Reason for revert: Implicated in "bad FD" test failures. Full extent of issue still unclear. For #62654. Fixes #65857. Change-Id: I066e38040544c506917e90255bd0e330964a0276 Reviewed-on: https://go-review.googlesource.com/c/go/+/566477 Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>