From 5fafa815542eb2f6f187fd36c96a856621e82115 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Mar 2026 03:31:17 +0000 Subject: [PATCH 1/3] Initial plan From 72704ab2e54032b6284d0fc3b6161ee84f2817fe Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Mar 2026 03:49:58 +0000 Subject: [PATCH 2/3] Fix: remove ActiveIssue for #92624 and update comment in Preallocate Co-authored-by: danmoseley <6385855+danmoseley@users.noreply.github.com> --- .../Microsoft/Win32/SafeHandles/SafeFileHandle.Windows.cs | 7 ++++--- .../System.IO.FileSystem.Tests/FileStream/ctor_options.cs | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Windows.cs b/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Windows.cs index 3d5f8d22db02ba..1f494309b419cb 100644 --- a/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Windows.cs @@ -203,9 +203,10 @@ private static unsafe void Preallocate(string fullPath, long preallocationSize, { int errorCode = Marshal.GetLastPInvokeError(); - // Only throw for errors that indicate there is not enough space. - // SetFileInformationByHandle fails with ERROR_DISK_FULL in certain cases when the size is disallowed by filesystem, - // such as >4GB on FAT32 volume. We cannot distinguish them currently. + // Only throw for errors that indicate there is not enough space or the file is too large. + // SetFileInformationByHandle fails with ERROR_DISK_FULL when the size is disallowed by filesystem, + // such as >4GB on FAT32 volume, and with ERROR_INVALID_PARAMETER on NTFS when the requested + // allocation size exceeds the maximum file size supported by the volume's cluster size. if (errorCode is Interop.Errors.ERROR_DISK_FULL or Interop.Errors.ERROR_FILE_TOO_LARGE or Interop.Errors.ERROR_INVALID_PARAMETER) diff --git a/src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/FileStream/ctor_options.cs b/src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/FileStream/ctor_options.cs index 29b2ba714060a8..1af6421d86c0ab 100644 --- a/src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/FileStream/ctor_options.cs +++ b/src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/FileStream/ctor_options.cs @@ -152,7 +152,6 @@ public void PreallocationSize(FileAccess access, FileMode mode) } } - [ActiveIssue("https://github.com/dotnet/runtime/issues/92624", TestPlatforms.Windows)] // macOS fcntl doc does not mention ENOSPC error: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/fcntl.2.html // But depending on the OS version, it might actually return it. // Since we don't want to have unstable tests, it's better to not run it on macOS at all. From 48bfd4bb0774e166dac1c9a800d599328bc1f62e Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Wed, 18 Mar 2026 11:59:28 +0100 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../src/Microsoft/Win32/SafeHandles/SafeFileHandle.Windows.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Windows.cs b/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Windows.cs index 1f494309b419cb..d28602161b8f05 100644 --- a/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Windows.cs @@ -205,8 +205,8 @@ private static unsafe void Preallocate(string fullPath, long preallocationSize, // Only throw for errors that indicate there is not enough space or the file is too large. // SetFileInformationByHandle fails with ERROR_DISK_FULL when the size is disallowed by filesystem, - // such as >4GB on FAT32 volume, and with ERROR_INVALID_PARAMETER on NTFS when the requested - // allocation size exceeds the maximum file size supported by the volume's cluster size. + // such as >4GB on a FAT32 volume, and with ERROR_INVALID_PARAMETER on NTFS when the requested + // allocation size exceeds the maximum file size supported by the filesystem or volume configuration. if (errorCode is Interop.Errors.ERROR_DISK_FULL or Interop.Errors.ERROR_FILE_TOO_LARGE or Interop.Errors.ERROR_INVALID_PARAMETER)