aboutsummaryrefslogtreecommitdiff
path: root/src/os
diff options
context:
space:
mode:
authorqmuntal <quimmuntal@gmail.com>2025-08-19 13:00:02 +0200
committerQuim Muntal <quimmuntal@gmail.com>2025-08-20 10:33:51 -0700
commit509d5f647ffc413bd874c2e2bf6d1b33f9bc0ac2 (patch)
treec566db74cd33acb90133e0d2021da41b06f18c39 /src/os
parent853fc1273912b020e428c77d35e525c9225fd51e (diff)
downloadgo-509d5f647ffc413bd874c2e2bf6d1b33f9bc0ac2.tar.xz
internal/poll: don't call Seek for overlapped Windows handles
Overlapped handles don't have the file pointer updated when performing I/O operations, so there is no need to call FD.Seek to reset the file pointer. Also, some overlapped file handles don't support seeking. See #74951. Fixes #74951. Change-Id: I0edd53beed7d3862730f3b2ed5fe9ba490e66c06 Reviewed-on: https://go-review.googlesource.com/c/go/+/697295 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>
Diffstat (limited to 'src/os')
-rw-r--r--src/os/os_windows_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/os/os_windows_test.go b/src/os/os_windows_test.go
index 3cdaad32c7..7c5e8ac4a4 100644
--- a/src/os/os_windows_test.go
+++ b/src/os/os_windows_test.go
@@ -1883,6 +1883,34 @@ func TestFileOverlappedSeek(t *testing.T) {
}
}
+func TestFileOverlappedReadAtVolume(t *testing.T) {
+ // Test that we can use File.ReadAt with an overlapped volume handle.
+ // See https://go.dev/issues/74951.
+ t.Parallel()
+ name := `\\.\` + filepath.VolumeName(t.TempDir())
+ namep, err := syscall.UTF16PtrFromString(name)
+ if err != nil {
+ t.Fatal(err)
+ }
+ h, err := syscall.CreateFile(namep,
+ syscall.GENERIC_READ|syscall.GENERIC_WRITE,
+ syscall.FILE_SHARE_WRITE|syscall.FILE_SHARE_READ,
+ nil, syscall.OPEN_ALWAYS, syscall.FILE_FLAG_OVERLAPPED, 0)
+ if err != nil {
+ if errors.Is(err, syscall.ERROR_ACCESS_DENIED) {
+ t.Skip("skipping test: access denied")
+ }
+ t.Fatal(err)
+ }
+ f := os.NewFile(uintptr(h), name)
+ defer f.Close()
+
+ var buf [0]byte
+ if _, err := f.ReadAt(buf[:], 0); err != nil {
+ t.Fatal(err)
+ }
+}
+
func TestPipe(t *testing.T) {
t.Parallel()
r, w, err := os.Pipe()