I have been reading https://kernel.dk/io_uring.pdf and I would like to experiment with the actual syscalls (io_uring_setup, io_uring_enter) to check my understanding, but I am not able to compile the following simple program:
#include <kernel/io_uring.h>
#include <stdint.h>
int main() {
struct io_uring_params p;
int ring = io_uring_setup((__u32) 512, &p);
return 0;
}
I get an implicit declaration error for the io_uring_setup function. The man page https://manpages.debian.org/unstable/liburing-dev/io_uring_setup.2.en.html suggests that the only file to include is linux/io_uring.h, but when I look at the source code, I do not see the definition of io_uring_setup.
(Mid-2021) As @oakad stated in the comments the
io_uring
syscalls are not currently wrapped by libc. If a user wants to invoke rawio_uring
syscalls (e.g. as described inio_uring_setup(2)
) it is up to them to provide the additional boilerplate to do so and ensure they obey all the expected rules... Rather than doing everything by hand it looks easier to use liburing (theio_uring
wrapper library).I'm unclear on why you chose to use
-- this looks wrong. The header on my system is found by
and the following compiles without error on my system:
However as mentioned in Efficient IO with io_uring PDF this is just the tip of the iceberg when using
io_uring
via direct syscalls. The Lord of the io_uring tutorial has a section titled The Low-level io_uring Interface which describes the usage in more detail but usingio_uring
looks both easier and safer.