Closed Oipo closed 2 months ago
io_uring is not wrong based on your report.
The syscall
instruction itself actually returns a negative error code.
However, the libc syscall wrappers, in their wisdom, return a -1 on
error and stash the error code in the errno
global variable (declared
in <errno.h>
).
On the other hand, io_uring, which doesn't use errno
, correctly
returns -2 (-ENOENT: No such file or directory) in your case.
It's the expected result.
You can interpret the io_uring return code using strerror
(make it
positive when you pass it). For example:
if (cqe->res < 0) {
printf("Error: (%d): %s\n", cqe->res, strerror(-cqe->res));
}
Note the -
sign in strerror(-cqe->res)
.
Oh, that explains it. :facepalm:
Thanks for letting me know!
According to the openat(2) man page, the
openat
command returns -1 and only -1 on error. When a non-existing file is being tried to open using the regularopenat
command, -1 is returned. Using io_uring openat, thecqe->res
value is -2, which to my understanding is not allowed.liburing version: 2.6 kernel version: 6.9.5
Repro file:
Execution result on my PC:
config-host.h contents: