aboutsummaryrefslogtreecommitdiff
path: root/src/os
AgeCommit message (Collapse)Author
2025-07-18os: revert the use of AddCleanup to close files and rootsCarlos Amedee
This reverts commit fdaac84480b02e600660d0ca7c15339138807107. Updates #70907 Updates #74574 Updates #74642 Reason for revert: Issue #74574 Change-Id: I7b55b85736e4210d9b6f3fd7a24050ac7bdefef9 Reviewed-on: https://go-review.googlesource.com/c/go/+/688435 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-07-15os: remove useless error checkguoguangwu
Change-Id: Ifeb5fecc6e28b79ac03e7dc2ce9531fe5eed3097 GitHub-Last-Rev: 087cf95965920c96befad5adb9e481bdf913d50a GitHub-Pull-Request: golang/go#66260 Reviewed-on: https://go-review.googlesource.com/c/go/+/570895 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Sean Liao <sean@liao.dev> Auto-Submit: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Florian Lehner <lehner.florian86@gmail.com> Reviewed-by: Rob Pike <r@golang.org>
2025-07-10os: trivial comment fixJakob Borg
"Geese" here looks like an autocorrect-o of "oses", I think writing it out makes more sense. Change-Id: Iba89a6c0b94657e2e93937cc153f07aea1d04e04 GitHub-Last-Rev: 4f3a780f327d6c807e9b154d781ee69a10d391e4 GitHub-Pull-Request: golang/go#74332 Reviewed-on: https://go-review.googlesource.com/c/go/+/682776 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-06-27os: use minimal file permissions when opening parent directory in RemoveAllqmuntal
On Windows, the process might not have read permission on the parent directory, but still can delete files in it. This change allows RemoveAll to open the parent directory with minimal permissions, which is sufficient for deleting child files. Fixes #74134. Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest,gotip-windows-arm64 Change-Id: I5d5c5977caaebf6e0f93fb2313b0ceb346f70e05 Reviewed-on: https://go-review.googlesource.com/c/go/+/684515 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com>
2025-06-12all: replace a few user-visible mentions of golang.org and godoc.orgAlberto Donizetti
This change replaces a few user-visible mentions of golang.org and godoc.org with go.dev and pkg.go.dev, respectively. Non-user-visible mentions (e.g. in test scripts) were left untouched. Change-Id: I5d828edcd618b6c55243d0dfcadc6fa1ce9422ce Reviewed-on: https://go-review.googlesource.com/c/go/+/681255 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-06-10os: disallow Root.Remove(".") on Plan 9, js, and WindowsDamien Neil
Windows already forbids this, since removing the root causes a sharing violation (can't delete the directory while the os.Root has a handle open to it), but add a more explicit check for attempts to delete "." and return EINVAL. Note that this change to Windows doesn't affect operations like Root.Remove("dir/."), since the path is cleaned into just "dir" before attempting the deletion. Fixes #73863 Change-Id: I0f45ccb6c9f171d3a52831632c134150388d77b6 Reviewed-on: https://go-review.googlesource.com/c/go/+/679377 Auto-Submit: 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>
2025-06-10os: do not follow dangling symlinks in Root when O_CREATE|O_EXCL on AIXDamien Neil
OpenFile with O_CREATE|O_EXCL should not follow dangling symlinks. On AIX it does, because AIX's openat(2) apparently returns ELOOP in this case. Most Unices return EEXIST. Ensure that we never follow symlinks in the final component of the path when opening a file with O_CREATE|O_EXCL. Fixes #73924 Change-Id: I869afb7faefccb0bb29d155553a7d7e5be80467d Reviewed-on: https://go-review.googlesource.com/c/go/+/677735 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Alan Donovan <adonovan@google.com>
2025-06-06os/signal: doc link to syscall.EPIPEOlivier Mengué
Add godoc link for EPIPE error. Change-Id: I5df35f700684510328f92bb5d4946c5123ba5f2c Reviewed-on: https://go-review.googlesource.com/c/go/+/667757 Auto-Submit: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-05-30os: add implementation of fs.ReadLinkFS to *rootFSRoxy Light
Fixes #73887 Change-Id: I43f3f4324d740b5381615bce864b7ec31415a635 Reviewed-on: https://go-review.googlesource.com/c/go/+/676135 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-05-27os: don't follow symlinks on Windows when O_CREATE|O_EXCL and read-onlyDamien Neil
Fix a bug in CL 672396, where we add FILE_FLAG_OPEN_REPARSE_POINT to the attributes passed to CreateFile, but then overwrite the attributes with FILE_ATTRIBUTE_READONLY when opening a file with a read-only permissions mode. For #73702 Change-Id: I6c10bf470054592bafa031732585fc3155c61341 Reviewed-on: https://go-review.googlesource.com/c/go/+/676655 Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
2025-05-21os: add Root.ReadFile and Root.WriteFileDamien Neil
For #73126 Change-Id: Ie69cc274e7b59f958c239520318b89ff0141e26b Reviewed-on: https://go-review.googlesource.com/c/go/+/674315 Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com>
2025-05-21os: add Root.MkdirAllDamien Neil
For #67002 Change-Id: Idd74b5b59e787e89bdfad82171b6a7719465f501 Reviewed-on: https://go-review.googlesource.com/c/go/+/674116 Reviewed-by: Alan Donovan <adonovan@google.com> Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-05-21runtime: add valgrind instrumentationRoland Shoemaker
Add build tag gated Valgrind annotations to the runtime which let it understand how the runtime manages memory. This allows for Go binaries to be run under Valgrind without emitting spurious errors. Instead of adding the Valgrind headers to the tree, and using cgo to call the various Valgrind client request macros, we just add an assembly function which emits the necessary instructions to trigger client requests. In particular we add instrumentation of the memory allocator, using a two-level mempool structure (as described in the Valgrind manual [0]). We also add annotations which allow Valgrind to track which memory we use for stacks, which seems necessary to let it properly function. We describe the memory model to Valgrind as follows: we treat heap arenas as a "pool" created with VALGRIND_CREATE_MEMPOOL_EXT (so that we can use VALGRIND_MEMPOOL_METAPOOL and VALGRIND_MEMPOOL_AUTO_FREE). Within the pool we treat spans as "superblocks", annotated with VALGRIND_MEMPOOL_ALLOC. We then allocate individual objects within spans with VALGRIND_MALLOCLIKE_BLOCK. It should be noted that running binaries under Valgrind can be _quite slow_, and certain operations, such as running the GC, can be _very slow_. It is recommended to run programs with GOGC=off. Additionally, async preemption should be turned off, since it'll cause strange behavior (GODEBUG=asyncpreemptoff=1). Running Valgrind with --leak-check=yes will result in some errors resulting from some things not being marked fully free'd. These likely need more annotations to rectify, but for now it is recommended to run with --leak-check=off. Updates #73602 [0] https://valgrind.org/docs/manual/mc-manual.html#mc-manual.mempools Change-Id: I71b26c47d7084de71ef1e03947ef6b1cc6d38301 Reviewed-on: https://go-review.googlesource.com/c/go/+/674077 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-05-21os: add Root.RemoveAllDamien Neil
For #67002 Change-Id: If59dab4fd934a115d8ff383826525330de750b54 Reviewed-on: https://go-review.googlesource.com/c/go/+/661595 Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com>
2025-05-21os: skip TestOpenFileCreateExclDanglingSymlink when no symlinksDamien Neil
Skip this test on plan9, and any other platform that doesn't have symlinks. Fixes #73729 Change-Id: I8052db24ed54c3361530bd4f54c96c9d10c4714c Reviewed-on: https://go-review.googlesource.com/c/go/+/674697 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Alan Donovan <adonovan@google.com> Commit-Queue: Alan Donovan <adonovan@google.com> Reviewed-by: Richard Miller <millerresearch@gmail.com> Reviewed-by: Alan Donovan <adonovan@google.com>
2025-05-19runtime: pass through -asan/-msan/-race to testprog testsMichael Pratt
The tests using testprog / testprogcgo are currently not covered on the asan/msan/race builders because they don't build testprog with the sanitizer flag. Explicitly pass the flag if the test itself is built with the sanitizer. There were a few tests that explicitly passed -race (even on non-race builders). These tests will now only run on race builders. For #71395. Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-asan-clang15,gotip-linux-amd64-msan-clang15,gotip-linux-amd64-race Change-Id: I6a6a636ce8271246316a80d426c0e4e2f6ab99c5 Reviewed-on: https://go-review.googlesource.com/c/go/+/643897 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Michael Pratt <mpratt@google.com>
2025-05-14os: don't fallback to the Stat slow path if file doesn't exist on Windowsqmuntal
os.Stat and os.Lstat first try stating the file without opening it. If that fails, then they open the file and try again, operations that tends to be slow. There is no point in trying the slow path if the file doesn't exist, we should just return an error immediately. This CL makes stating a non-existent file on Windows 50% faster: 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 │ StatNotExist-12 43.65µ ± 15% 20.02µ ± 10% -54.14% (p=0.000 n=10+7) │ old.txt │ new.txt │ │ B/op │ B/op vs base │ StatNotExist-12 224.0 ± 0% 224.0 ± 0% ~ (p=1.000 n=10+7) ¹ ¹ all samples are equal │ old.txt │ new.txt │ │ allocs/op │ allocs/op vs base │ StatNotExist-12 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10+7) ¹ Updates #72992. Change-Id: Iaeb9596d0d18e5a5a1bd1970e296a3480501af78 Reviewed-on: https://go-review.googlesource.com/c/go/+/671458 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jake Bailey <jacob.b.bailey@gmail.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-05-14net: use closesocket when closing socket os.File's on Windowsqmuntal
The WSASocket documentation states that the returned socket must be closed by calling closesocket instead of CloseHandle. The different File methods on the net package return an os.File that is not aware that it should use closesocket. Ideally, os.NewFile should detect that the passed handle is a socket and use the appropriate close function, but there is no reliable way to detect that a handle is a socket on Windows (see CL 671455). To work around this, we add a hidden function to the os package that can be used to return an os.File that uses closesocket. This approach is the same as used on Unix, which also uses a hidden function for other purposes. While here, fix a potential issue with FileConn, which was using File.Fd rather than File.SyscallConn to get the handle. This could result in the File being closed and garbage collected before the syscall was made. Fixes #73683. Change-Id: I179405f34c63cbbd555d8119e0f77157c670eb3e Reviewed-on: https://go-review.googlesource.com/c/go/+/672195 Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-05-14os: don't follow symlinks on Windows when O_CREATE|O_EXCLDamien Neil
Match standard Unix behavior: Symlinks are not followed when O_CREATE|O_EXCL is passed to open. Thanks to Junyoung Park and Dong-uk Kim of KAIST Hacking Lab for discovering this issue. Fixes #73702 Fixes CVE-2025-0913 Change-Id: Ieb46a6780c5e9a6090b09cd34290f04a8e3b0ca5 Reviewed-on: https://go-review.googlesource.com/c/go/+/672396 Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
2025-05-12os: remove NewFile socket detection on Windowsqmuntal
NewFile was recently updated (in CL 668195) to detect whether the handle is a socket or not. This special case is not really necessary, given that socket handles can be used as if they were normal file handles on all functions supported by os.File (see https://learn.microsoft.com/en-us/windows/win32/winsock/socket-handles-2). Not only is not necessary, but is can also be problematic, as there is no way to reliably detect whether a handle is a socket or not. For example, the test failure reported in #73630 is caused by a named pipe wrongly detected as a socket. This aligns with the Unix NewFile behavior of returning an os.File that identifies itself as a file handle even if it is a socket. This makes os.File.Close to always return os.ErrClosed in case of multiple calls rather than sometimes returning "use of closed network connection". Updates #10350. Fixes #73630. Change-Id: Ia8329783d5c8ef6dac34ef69ed1ce9d2a9862e11 Reviewed-on: https://go-review.googlesource.com/c/go/+/671455 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2025-05-06os: avoid escape from Root via paths ending in ../Damien Neil
The doInRoot function operates on a path split into components. The final path component retained any trailing path separator characters, to permit operations in a Root to retain the trailing-separator behavior of non-Root operations. However, doInRoot failed to take trailing separators into account when checking for .. path components. This could permit opening the parent directory of the Root with a path ending in "../". Change the split path to never include path separators in components, and handle trailing separators independently of the split path. Thanks to Dan Sebastian Thrane of SDU eScience Center for reporting this issue. Fixes #73555 Fixes CVE-2025-22873 Change-Id: I9a33a145c22f5eb1dd4e4cafae5fcc61a8d4f0d4 Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2160 Reviewed-by: Neal Patel <nealpatel@google.com> Reviewed-by: Roland Shoemaker <bracewell@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/670036 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-05-05net,os: support converting between *os.File and net.Conn on Windowsqmuntal
The runtime poller and os.NewFile recently gained support for disassociating the handle from the runtime poller IOCP (see CL 664455). This was the main blocker for allowing the conversion between *os.File and net.Conn. Implementing the conversion is now trivial. The only remaining work, implemented in this CL, is improving os.NewFile to also support socket handles and updating some build tags so that Windows can share almost the same net's File implementation as Unix. There is one important limitation, though: the duplicated socket handle returned by the various File methods in the net package is not usable on other process. If someone needs to pass a socket handle to another process, they should manually call the WSADuplicateSocket Windows API passing the process ID of the target process. Fixes #9503. Fixes #10350. Updates #19098. Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-race,gotip-windows-amd64-longtest,gotip-windows-arm64 Change-Id: Ic43cadaac2662b925d57a9d362ddc7ae21d1b56e Reviewed-on: https://go-review.googlesource.com/c/go/+/668195 Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-05-01os: fix Root.Mkdir permission bits on OpenBSDJosh Rickmar
Pass missing mode bits in the mkdirat() syscall wrapper. Fixes #73559 Change-Id: I54b1985bd77b1fe5d1a48acab9f2597f8c931854 GitHub-Last-Rev: 669c17361d86bc9065bb6b47a2d60aa86bcfa12d GitHub-Pull-Request: golang/go#73565 Reviewed-on: https://go-review.googlesource.com/c/go/+/669375 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2025-04-30os: test overlapped pipes deadlines on Windowsqmuntal
NewFile recently added support for overlapped I/O on Windows, which allows us to set deadlines on them, but the test coverage for this new feature is not exhaustive. Modify the existing pipe deadline tests to also exercise named overlapped pipes. Updates #19098. Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-race,gotip-windows-amd64-longtest,gotip-windows-arm64 Change-Id: I86d284d9fb054c24959045a922cf84feeda5b5f0 Reviewed-on: https://go-review.googlesource.com/c/go/+/668095 Reviewed-by: Alex Brainman <alex.brainman@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Junyang Shao <shaojunyang@google.com>
2025-04-24os,internal/poll: disassociate handle from IOCP in File.Fdqmuntal
Go 1.25 will gain support for overlapped IO on handles passed to os.NewFile thanks to CL 662236. It was previously not possible to add an overlapped handle to the Go runtime's IO completion port (IOCP), and now happens on the first call the an IO method. This means that there is code that relies on the fact that File.Fd returns a handle that can always be associated with a custom IOCP. That wouldn't be the case anymore, as a handle can only be associated with one IOCP at a time and it must be explicitly disassociated. To fix this breaking change, File.Fd will disassociate the handle from the Go runtime IOCP before returning it. It is then not necessary to defer the association until the first IO method is called, which was recently added in CL 661955 to support this same use case, but in a more complex and unreliable way. Updates #19098. Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-race,gotip-windows-amd64-longtest,gotip-windows-arm64 Change-Id: Id8a7e04d35057047c61d1733bad5bf45494b2c28 Reviewed-on: https://go-review.googlesource.com/c/go/+/664455 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-15os: handle trailing slashes in os.RemoveDir on WindowsDamien Neil
CL 661575 inadvertently caused os.RemoveDir on Windows to fail when given a path with a trailing / or \, due to the splitPath function not correctly stripping trailing separators. Fixes #73317 Change-Id: I21977b94bb08ff1e563de6f5f16a4bdf5024a15e Reviewed-on: https://go-review.googlesource.com/c/go/+/664715 Auto-Submit: Damien Neil <dneil@google.com> TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Alan Donovan <adonovan@google.com>
2025-04-14os,internal/poll: support I/O on overlapped files not added to the pollerqmuntal
This fixes the support for I/O on overlapped files that are not added to the poller. Note that CL 661795 already added support for that, but it really only worked for pipes, not for plain files. Additionally, this CL also makes this kind of I/O operations to not notify the external poller to avoid confusing it. Updates #15388. Change-Id: I15c6ea74f3a87960aef0986598077b6eab9b9c99 Reviewed-on: https://go-review.googlesource.com/c/go/+/664415 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
2025-04-11all: use built-in min, max functionsMarcel Meyer
Change-Id: Ie76ebb556d635068342747f3f91dd7dc423df531 GitHub-Last-Rev: aea61fb3a054e6bd24f4684f90fb353d5682cd0b GitHub-Pull-Request: golang/go#73340 Reviewed-on: https://go-review.googlesource.com/c/go/+/664677 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com>
2025-04-11os: fix TestRootChtimes on illumosTobias Klauser
TestRootChtimes currently fails on illumos [1] because the times returned by os.Stat have only microsecond precision on that builder. Truncate them to make the test pass again. [1] https://build.golang.org/log/9780af24c3b3073dae1d827b2b9f9e3a48912c30 Change-Id: I8cf895d0b60c854c27cb4faf57c3b44bd40bfdd4 Reviewed-on: https://go-review.googlesource.com/c/go/+/664915 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> TryBot-Bypass: Damien Neil <dneil@google.com>
2025-04-10net: deduplicate sendfile filesqmuntal
The sendfile implementation for platforms supporting it is now in net/sendfile.go, rather than being duplicated in separate files for each platform. The only difference between the implementations was the poll.SendFile parameters, which have been harmonized, and also linux strictly asserting for os.File, which now have been relaxed to allow any type implementing syscall.Conn. Change-Id: Ia1a2d5ee7380710a36fc555dbf681f7e996ea2ec Reviewed-on: https://go-review.googlesource.com/c/go/+/664075 Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
2025-04-09os: clean-up NewFile testsqmuntal
This CL removes some unnecessary code and duplicated NewFile tests cases. It also simplifies TestPipeCanceled by removing the need for using SetReadDeadline. Using CancelIoEx instead of CancelIo makes the cancel operations to finish almost instantly. The latter could take more than 20s to finish if called from a thread different from the one that called ReadFile. Change-Id: I9033cbcad277666bc2aec89b3e5a3ef529da2cd8 Reviewed-on: https://go-review.googlesource.com/c/go/+/663755 Reviewed-by: Alex Brainman <alex.brainman@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-04-07all: use built-in max/min to simplify the codecuishuang
Change-Id: I309d93d6ebf0feb462217a344d5f02c190220752 Reviewed-on: https://go-review.googlesource.com/c/go/+/661737 Reviewed-by: Sean Liao <sean@liao.dev> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-04os: support overlapped IO with NewFileqmuntal
The runtime/poll package has just gained support for overlapped IO, see CL 660595 and CL 661955. The only remaining piece was making it visible to user code via os.NewFile. Some of the poll.FD.Init responsibility has been moved to os.NewFile to avoid unnecessary syscalls for the common case of using os.Open, os.Create, os.OpenFile, and os.Pipe, where we know that the file is not opened for overlapped IO. Some internal/poll tests have been moved to the os package to exercise public APIs rather than internal ones. The os.NewFile function definition has been moved into an OS-agnostic file to avoid having duplicated documentation and ensure that the caller is aware of its behavior across all platforms. Closes #19098. Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest,gotip-windows-amd64-race,gotip-windows-arm64 Change-Id: If043f8b34d588cd4b481777203107ed92d660fd9 Reviewed-on: https://go-review.googlesource.com/c/go/+/662236 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Auto-Submit: Damien Neil <dneil@google.com>
2025-04-04internal/syscall/windows: use unsafe.Pointer instead of uintptrqmuntal
Some functions accept a uintptr when they should accept an unsafe.Pointer, else the compiler won't know that the pointer should be kept alive across the call, potentially causing undefined behavior. Fixes #73156 (potentially) Change-Id: I29c847eb8ffbb785fabf217e9f3718d10cfb5047 Reviewed-on: https://go-review.googlesource.com/c/go/+/662855 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2025-03-31os: avoid symlink races in RemoveAll on WindowsDamien Neil
Make the openat-using version of RemoveAll use the appropriate Windows equivalent, via new portable (but internal) functions added for os.Root. We could reimplement everything in terms of os.Root, but this is a bit simpler and keeps the existing code structure. Fixes #52745 Change-Id: I0eba0286398b351f2ee9abaa60e1675173988787 Reviewed-on: https://go-review.googlesource.com/c/go/+/661575 Reviewed-by: Alan Donovan <adonovan@google.com> Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-31os,internal/poll: support I/O on overlapped handles not added to the pollerqmuntal
Calling syscall.ReadFile and syscall.WriteFile on overlapped handles always need to be passed a valid *syscall.Overlapped structure, even if the handle is not added to a IOCP (like the Go runtime poller). Else, the syscall will fail with ERROR_INVALID_PARAMETER. We also need to handle ERROR_IO_PENDING errors when the overlapped handle is not added to the poller, in which case we need to block until the operation completes. Previous CLs already added support for overlapped handles to the poller, mostly to keep track of the file offset independently of the file pointer (which is not supported for overlapped handles). Fixed #15388. Updates #19098. Change-Id: I2103ab892a37d0e326752ae8c2771a43c13ba42e Reviewed-on: https://go-review.googlesource.com/c/go/+/661795 Auto-Submit: Quim Muntal <quimmuntal@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2025-03-28os: add Root.SymlinkDamien Neil
For #67002 Change-Id: Ia1637b61eae49e97e1d07f058ad2390e74cd3403 Reviewed-on: https://go-review.googlesource.com/c/go/+/660635 Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com> Auto-Submit: Damien Neil <dneil@google.com>
2025-03-27os: avoid panic in Root when symlink references the rootDamien Neil
We would panic when opening a symlink ending in .., where the symlink references the root itself. Fixes #73081 Change-Id: I7dc3f041ca79df7942feec58c197fde6881ecae5 Reviewed-on: https://go-review.googlesource.com/c/go/+/661416 Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-24os: add Root.LinkDamien Neil
For #67002 Change-Id: I223f3f2dbc8b02726f4ce5a017c628c4a20f109a Reviewed-on: https://go-review.googlesource.com/c/go/+/659757 Reviewed-by: Quim Muntal <quimmuntal@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-03-20os: add Root.RenameDamien Neil
For #67002 Change-Id: Ifb1042bc5ceaeea64296763319b24634bbcb0bf0 Reviewed-on: https://go-review.googlesource.com/c/go/+/659416 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com>
2025-03-20os: skip atime checks in TestRootChtimes on plan9Damien Neil
Plan 9 doesn't permit setting arbitrary atimes. Fixes #72957 Change-Id: Ia4e14c75ed7dcdefd4669c0c21884d5ead9ab2fb Reviewed-on: https://go-review.googlesource.com/c/go/+/659615 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-20all: use exec.Command.String in test logsqmuntal
There is no need to manually construct a human-friendly string for a exec.Command. The String method does that for us. Change-Id: Iff1033478000bade9cbdc079f6143a7690374258 Reviewed-on: https://go-review.googlesource.com/c/go/+/659475 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-20os: don't wrap os.Getgroups error in testsKir Kolyshkin
The error returned is an os.PathError which already provides enough context. Change-Id: Ib9391c00afc56bca673b8086d5dc19cf9b99b285 Reviewed-on: https://go-review.googlesource.com/c/go/+/658957 Reviewed-by: Cherry Mui <cherryyz@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>
2025-03-20os: fix typos in commentsKir Kolyshkin
* peformed -> performed * reprots -> reports Found when reviewing Change-Id: I9474074199f6a610f40b4bcf798c6d77948f3d3c Reviewed-on: https://go-review.googlesource.com/c/go/+/658956 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> Auto-Submit: Ian Lance Taylor <iant@google.com>
2025-03-19os: skip Root.Chtimes atime check on netbsd, truncate a/mtime on plan9Damien Neil
The NetBSD builder has noatime set on its filesystem. Skip testing the atime on this builder. Plan9 has second precision on its atime and mtimes. Truncate the values passed to Chtimes. For #72957 Change-Id: I963e2dd34075a9ba025e80641f0b675d5d912188 Reviewed-on: https://go-review.googlesource.com/c/go/+/659356 Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-03-19os: add Root.ReadlinkDamien Neil
For #67002 Change-Id: I532a5ffc02c7457796540db54fa2f5ddad86e4b2 Reviewed-on: https://go-review.googlesource.com/c/go/+/658995 Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-19os: add Root.LchownDamien Neil
For #67002 Change-Id: I1bbf18838a1dd2281a2b6e56fc8a58ef70007adc Reviewed-on: https://go-review.googlesource.com/c/go/+/649536 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-03-18os: add Root.ChtimesDamien Neil
For #67002 Change-Id: I9b10ac30f852052c85d6d21eb1752a9de5474346 Reviewed-on: https://go-review.googlesource.com/c/go/+/649515 Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Kirill Kolyshkin <kolyshkin@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-03-15os: use slices.CloneTobias Klauser
Change-Id: I5a3de1b2fe2ebbb6437df5e7cc55e0d8d69c9cd7 Reviewed-on: https://go-review.googlesource.com/c/go/+/657915 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: David Chase <drchase@google.com>
2025-03-11os: add more File.WriteAt testsqmuntal
The File.WriteAt doesn't verify that the file offset is not changed when calling WriteAt, although it is what users expect. Add some new tests to verify that this behavior doesn't regress. Change-Id: Ib1e048c7333d6efec71bd8f75a4fa745775306f9 Reviewed-on: https://go-review.googlesource.com/c/go/+/656355 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>