authorgravatar for johnnymarler@gmail.comJonathan Marler <johnnymarler@gmail.com> 2026-03-21 09:57:05-06:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-04-02 15:05:31+02:00
logf4eecf8d7d4026a9e0ab8986b1c049ad2a0e01fc
tree15bd373d3ed8ca5c036b2ab18b84f07f1db0c679
parent6cdd576d4176c2581f796c2066ca0f92bda03c9e

handle EROFS in create/open file

I hit an unexpected errno 30 on macos attempting to call createFile on a directory in PATH. errno 30 is EROFS, this change propagates that error as error.ReadOnlyFileSystem.

6 files changed, 9 insertions(+), 0 deletions(-)

lib/std/Io/Dispatch.zig+2
...@@ -2512,6 +2512,7 @@ fn dirCreateFile(...@@ -2512,6 +2512,7 @@ fn dirCreateFile(
2512 .OPNOTSUPP => return error.FileLocksUnsupported,2512 .OPNOTSUPP => return error.FileLocksUnsupported,
2513 .AGAIN => return error.WouldBlock,2513 .AGAIN => return error.WouldBlock,
2514 .TXTBSY => return error.FileBusy,2514 .TXTBSY => return error.FileBusy,
2515 .ROFS => return error.ReadOnlyFileSystem,
2515 .NXIO => return error.NoDevice,2516 .NXIO => return error.NoDevice,
2516 .ILSEQ => return error.BadPathName,2517 .ILSEQ => return error.BadPathName,
2517 else => |err| return unexpectedErrno(err),2518 else => |err| return unexpectedErrno(err),
...@@ -2647,6 +2648,7 @@ fn dirOpenFile(...@@ -2647,6 +2648,7 @@ fn dirOpenFile(
2647 .AGAIN => return error.WouldBlock,2648 .AGAIN => return error.WouldBlock,
2648 .TXTBSY => return error.FileBusy,2649 .TXTBSY => return error.FileBusy,
2649 .NXIO => return error.NoDevice,2650 .NXIO => return error.NoDevice,
2651 .ROFS => return error.ReadOnlyFileSystem,
2650 .ILSEQ => return error.BadPathName,2652 .ILSEQ => return error.BadPathName,
2651 else => |err| return unexpectedErrno(err),2653 else => |err| return unexpectedErrno(err),
2652 }2654 }
lib/std/Io/File.zig+1
...@@ -202,6 +202,7 @@ pub const OpenError = error{...@@ -202,6 +202,7 @@ pub const OpenError = error{
202 NotDir,202 NotDir,
203 /// The path already exists and the `CREAT` and `EXCL` flags were provided.203 /// The path already exists and the `CREAT` and `EXCL` flags were provided.
204 PathAlreadyExists,204 PathAlreadyExists,
205 ReadOnlyFileSystem,
205 DeviceBusy,206 DeviceBusy,
206 FileLocksUnsupported,207 FileLocksUnsupported,
207 /// One of these three things:208 /// One of these three things:
lib/std/Io/Threaded.zig+2
...@@ -4290,6 +4290,7 @@ fn dirCreateFilePosix(...@@ -4290,6 +4290,7 @@ fn dirCreateFilePosix(
4290 .AGAIN => return error.WouldBlock,4290 .AGAIN => return error.WouldBlock,
4291 .TXTBSY => return error.FileBusy,4291 .TXTBSY => return error.FileBusy,
4292 .NXIO => return error.NoDevice,4292 .NXIO => return error.NoDevice,
4293 .ROFS => return error.ReadOnlyFileSystem,
4293 .ILSEQ => return error.BadPathName,4294 .ILSEQ => return error.BadPathName,
4294 else => |err| return posix.unexpectedErrno(err),4295 else => |err| return posix.unexpectedErrno(err),
4295 }4296 }
...@@ -4871,6 +4872,7 @@ fn dirOpenFilePosix(...@@ -4871,6 +4872,7 @@ fn dirOpenFilePosix(
4871 .AGAIN => return error.WouldBlock,4872 .AGAIN => return error.WouldBlock,
4872 .TXTBSY => return error.FileBusy,4873 .TXTBSY => return error.FileBusy,
4873 .NXIO => return error.NoDevice,4874 .NXIO => return error.NoDevice,
4875 .ROFS => return error.ReadOnlyFileSystem,
4874 .ILSEQ => return error.BadPathName,4876 .ILSEQ => return error.BadPathName,
4875 else => |err| return posix.unexpectedErrno(err),4877 else => |err| return posix.unexpectedErrno(err),
4876 }4878 }
lib/std/Io/Uring.zig+1
...@@ -5673,6 +5673,7 @@ fn openat(...@@ -5673,6 +5673,7 @@ fn openat(
5673 .AGAIN => return error.WouldBlock,5673 .AGAIN => return error.WouldBlock,
5674 .TXTBSY => return error.FileBusy,5674 .TXTBSY => return error.FileBusy,
5675 .NXIO => return error.NoDevice,5675 .NXIO => return error.NoDevice,
5676 .ROFS => return error.ReadOnlyFileSystem,
5676 .ILSEQ => return error.BadPathName,5677 .ILSEQ => return error.BadPathName,
5677 else => |err| return unexpectedErrno(err),5678 else => |err| return unexpectedErrno(err),
5678 }5679 }
lib/std/debug/SelfInfo/Windows.zig+1
...@@ -360,6 +360,7 @@ const Module = struct {...@@ -360,6 +360,7 @@ const Module = struct {
360 error.SystemFdQuotaExceeded,360 error.SystemFdQuotaExceeded,
361 error.FileLocksUnsupported,361 error.FileLocksUnsupported,
362 error.FileBusy,362 error.FileBusy,
363 error.ReadOnlyFileSystem,
363 => return error.ReadFailed,364 => return error.ReadFailed,
364 };365 };
365 errdefer coff_file.close(io);366 errdefer coff_file.close(io);
lib/std/zig/system.zig+2
...@@ -423,6 +423,7 @@ pub fn resolveTargetQuery(io: Io, query: Target.Query) DetectError!Target {...@@ -423,6 +423,7 @@ pub fn resolveTargetQuery(io: Io, query: Target.Query) DetectError!Target {
423 error.ConnectionResetByPeer => return error.Unexpected,423 error.ConnectionResetByPeer => return error.Unexpected,
424 error.NotOpenForReading => return error.Unexpected,424 error.NotOpenForReading => return error.Unexpected,
425 error.SocketUnconnected => return error.Unexpected,425 error.SocketUnconnected => return error.Unexpected,
426 error.ReadOnlyFileSystem => return error.Unexpected,
426427
427 error.AccessDenied,428 error.AccessDenied,
428 error.SymLinkLoop,429 error.SymLinkLoop,
...@@ -853,6 +854,7 @@ fn glibcVerFromRPath(io: Io, rpath: []const u8) !std.SemanticVersion {...@@ -853,6 +854,7 @@ fn glibcVerFromRPath(io: Io, rpath: []const u8) !std.SemanticVersion {
853 error.PathAlreadyExists => return error.Unexpected, // read-only854 error.PathAlreadyExists => return error.Unexpected, // read-only
854 error.DeviceBusy => return error.Unexpected, // read-only855 error.DeviceBusy => return error.Unexpected, // read-only
855 error.FileBusy => return error.Unexpected, // read-only856 error.FileBusy => return error.Unexpected, // read-only
857 error.ReadOnlyFileSystem => return error.Unexpected, // read-only
856 error.NoDevice => return error.Unexpected, // not asking for a special device858 error.NoDevice => return error.Unexpected, // not asking for a special device
857 error.FileTooBig => return error.Unexpected,859 error.FileTooBig => return error.Unexpected,
858 error.WouldBlock => return error.Unexpected, // not opened in non-blocking860 error.WouldBlock => return error.Unexpected, // not opened in non-blocking