From d16a9b0acb14ad217849de2a59d91cd4648ac1a7 Mon Sep 17 00:00:00 2001 From: Justin Braben <32079903+JustinBraben@users.noreply.github.com> Date: Wed, 27 Nov 2024 14:33:29 -0700 Subject: [PATCH] std.os.windows: Map PIPE_NOT_AVAILABLE from OpenFile() to error.NoDevice (#21938) --- lib/std/fs/File.zig | 1 + lib/std/os/windows.zig | 2 ++ lib/std/posix.zig | 2 ++ lib/std/process/Child.zig | 1 + src/Builtin.zig | 1 + src/Zcu/PerThread.zig | 1 + 6 files changed, 8 insertions(+) diff --git a/lib/std/fs/File.zig b/lib/std/fs/File.zig index 68dc6360a87307ca3be21c9e5cf532f8053397cf..69c3553ac3c42ad8437c18229a1ee463976965ae 100644 --- a/lib/std/fs/File.zig +++ b/lib/std/fs/File.zig @@ -39,6 +39,7 @@ pub const OpenError = error{ FileNotFound, AccessDenied, PipeBusy, + NoDevice, NameTooLong, /// WASI-only; file paths must be valid UTF-8. InvalidUtf8, diff --git a/lib/std/os/windows.zig b/lib/std/os/windows.zig index 8cd54409b2eb1ac61893e8dd296f610c9e3a26b5..c56e27d8ec0ce8f648322b83239c395c161dc69f 100644 --- a/lib/std/os/windows.zig +++ b/lib/std/os/windows.zig @@ -132,6 +132,7 @@ pub fn OpenFile(sub_path_w: []const u16, options: OpenFileOptions) OpenError!HAN .SHARING_VIOLATION => return error.AccessDenied, .ACCESS_DENIED => return error.AccessDenied, .PIPE_BUSY => return error.PipeBusy, + .PIPE_NOT_AVAILABLE => return error.NoDevice, .OBJECT_PATH_SYNTAX_BAD => unreachable, .OBJECT_NAME_COLLISION => return error.PathAlreadyExists, .FILE_IS_A_DIRECTORY => return error.IsDir, @@ -801,6 +802,7 @@ pub fn CreateSymbolicLink( error.NotDir => return error.Unexpected, error.WouldBlock => return error.Unexpected, error.PipeBusy => return error.Unexpected, + error.NoDevice => return error.Unexpected, error.AntivirusInterference => return error.Unexpected, else => |e| return e, }; diff --git a/lib/std/posix.zig b/lib/std/posix.zig index 3ca5e1ae590caefa57832a1819d73b1258dcb697..39b29ea76f02384a672c74f114d1b94eae06d5cf 100644 --- a/lib/std/posix.zig +++ b/lib/std/posix.zig @@ -2946,6 +2946,7 @@ pub fn mkdiratW(dir_fd: fd_t, sub_path_w: []const u16, mode: u32) MakeDirError!v }) catch |err| switch (err) { error.IsDir => return error.Unexpected, error.PipeBusy => return error.Unexpected, + error.NoDevice => return error.Unexpected, error.WouldBlock => return error.Unexpected, error.AntivirusInterference => return error.Unexpected, else => |e| return e, @@ -3040,6 +3041,7 @@ pub fn mkdirW(dir_path_w: []const u16, mode: u32) MakeDirError!void { }) catch |err| switch (err) { error.IsDir => return error.Unexpected, error.PipeBusy => return error.Unexpected, + error.NoDevice => return error.Unexpected, error.WouldBlock => return error.Unexpected, error.AntivirusInterference => return error.Unexpected, else => |e| return e, diff --git a/lib/std/process/Child.zig b/lib/std/process/Child.zig index bb2c4c09a8dbacf4ed3be028f75f6e3c2e45b203..72277c2e627b9afb3f608030b3b45ec4fc2e8700 100644 --- a/lib/std/process/Child.zig +++ b/lib/std/process/Child.zig @@ -743,6 +743,7 @@ fn spawnWindows(self: *ChildProcess) SpawnError!void { }) catch |err| switch (err) { error.PathAlreadyExists => return error.Unexpected, // not possible for "NUL" error.PipeBusy => return error.Unexpected, // not possible for "NUL" + error.NoDevice => return error.Unexpected, // not possible for "NUL" error.FileNotFound => return error.Unexpected, // not possible for "NUL" error.AccessDenied => return error.Unexpected, // not possible for "NUL" error.NameTooLong => return error.Unexpected, // not possible for "NUL" diff --git a/src/Builtin.zig b/src/Builtin.zig index f3018d30235fbd52b9f6316b0b4d71554330f225..c6609e3e3972b703e678b9efe1f1e3f31adf6b90 100644 --- a/src/Builtin.zig +++ b/src/Builtin.zig @@ -250,6 +250,7 @@ pub fn populateFile(comp: *Compilation, mod: *Module, file: *File) !void { error.BadPathName => unreachable, // it's always "builtin.zig" error.NameTooLong => unreachable, // it's always "builtin.zig" error.PipeBusy => unreachable, // it's not a pipe + error.NoDevice => unreachable, // it's not a pipe error.WouldBlock => unreachable, // not asking for non-blocking I/O error.FileNotFound => try writeFile(file, mod), diff --git a/src/Zcu/PerThread.zig b/src/Zcu/PerThread.zig index 29b971615259c5482562f9ab581e6c4415433c29..c6a8b58f41a0078510de612ebf1c1523986e23a9 100644 --- a/src/Zcu/PerThread.zig +++ b/src/Zcu/PerThread.zig @@ -133,6 +133,7 @@ pub fn astGenFile( error.BadPathName => unreachable, // it's a hex encoded name error.NameTooLong => unreachable, // it's a fixed size name error.PipeBusy => unreachable, // it's not a pipe + error.NoDevice => unreachable, // it's not a pipe error.WouldBlock => unreachable, // not asking for non-blocking I/O // There are no dir components, so you would think that this was // unreachable, however we have observed on macOS two processes racing -- 2.54.0