Zig Version
0.16.0-dev.3066+da78940dd
Steps to Reproduce and Observed Behavior
I was trying out new io implementations to copy around few files when I encountred this. std.Io.Evented (io_uring backend), Dir.copyFileAbsolute with .replace = false crashes. I understand evented is still not fully done yet but probably worth looking into.
From what I saw the crash path is:
Dir.copyFileAbsolute -> Dir.copyFile -> File.Atomic.link -> Uring.linkat -> errnoBug(INVAL).
I am on:
- Zig:
0.16.0-dev.3066+da78940dd
- OS: Linux (
x86_64-linux)
this is the minimal reproducer I could come up with
conststd=@import("std");constIo=std.Io;constDir=Io.Dir;pubfnmain(init:std.process.Init)!void{constio=init.io;constsrc_path="/tmp/zig-evented-src-repro.txt";constdst_path="/tmp/zig-evented-dst-repro.txt";Dir.deleteFileAbsolute(io,src_path)catch|err|switch(err){error.FileNotFound=>{},else=>returnerr,};Dir.deleteFileAbsolute(io,dst_path)catch|err|switch(err){error.FileNotFound=>{},else=>returnerr,};varsrc_file=tryDir.createFileAbsolute(io,src_path,.{.truncate=true,.read=false});defersrc_file.close(io);trysrc_file.writeStreamingAll(io,"hello\n");deferDir.deleteFileAbsolute(io,src_path)catch{};deferDir.deleteFileAbsolute(io,dst_path)catch{};varevented:Io.Evented=undefined;tryevented.init(init.gpa,.{});deferevented.deinit();tryDir.copyFileAbsolute(src_path,dst_path,evented.io(),.{.replace=false});}
Expected Behavior
Dir.copyFileAbsolute(..., .replace = false) under evented backend should not panic and should either:
- succeed, or
- return a documented/expected filesystem error without hitting
errnoBug.
### Zig Version
0.16.0-dev.3066+da78940dd
### Steps to Reproduce and Observed Behavior
I was trying out new io implementations to copy around few files when I encountred this. `std.Io.Evented` (io_uring backend), `Dir.copyFileAbsolute` with `.replace = false` crashes. I understand evented is still not fully done yet but probably worth looking into.
From what I saw the crash path is:
`Dir.copyFileAbsolute -> Dir.copyFile -> File.Atomic.link -> Uring.linkat -> errnoBug(INVAL)`.
I am on:
- Zig: `0.16.0-dev.3066+da78940dd`
- OS: Linux (`x86_64-linux`)
this is the minimal reproducer I could come up with
```zig
const std = @import("std");
const Io = std.Io;
const Dir = Io.Dir;
pub fn main(init: std.process.Init) !void {
const io = init.io;
const src_path = "/tmp/zig-evented-src-repro.txt";
const dst_path = "/tmp/zig-evented-dst-repro.txt";
Dir.deleteFileAbsolute(io, src_path) catch |err| switch (err) {
error.FileNotFound => {},
else => return err,
};
Dir.deleteFileAbsolute(io, dst_path) catch |err| switch (err) {
error.FileNotFound => {},
else => return err,
};
var src_file = try Dir.createFileAbsolute(io, src_path, .{ .truncate = true, .read = false });
defer src_file.close(io);
try src_file.writeStreamingAll(io, "hello\n");
defer Dir.deleteFileAbsolute(io, src_path) catch {};
defer Dir.deleteFileAbsolute(io, dst_path) catch {};
var evented: Io.Evented = undefined;
try evented.init(init.gpa, .{});
defer evented.deinit();
try Dir.copyFileAbsolute(src_path, dst_path, evented.io(), .{ .replace = false });
}
```
### Expected Behavior
`Dir.copyFileAbsolute(..., .replace = false)` under evented backend should not panic and should either:
- succeed, or
- return a documented/expected filesystem error without hitting `errnoBug`.