io_uring_prep_write_fixed(3)

πŸ“¦
version 2.14 Β· 4 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, nixpkgs unstable, ubuntu questing, ubuntu resolute

πŸ’– io_uring_prep_write_fixed(3) πŸ’–

okay bestie, you know liburing? the liburing Manual? yeah. this is one of those pages. it's giving "registered buffer write energy" and honestly? we're obsessed. πŸ¦‹


✨ NAME ✨

io_uring_prep_write_fixed β€” prepare an I/O write request with a registered buffer, no cap 🫢


✨ SYNOPSIS ✨

#include <liburing.h>

void io_uring_prep_write_fixed(struct io_uring_sqe *sqe,
                        int fd,
                        const void *buf,
                        unsigned nbytes,
                        __u64 offset,
                        int buf_index);

✨ DESCRIPTION ✨

so like. io_uring_prep_write_fixed(3) sets you up with an I/O write request that uses a buffer you already registered earlier. the submission queue entry sqe gets all dressed up so it can use the file descriptor fd and start writing nbytes out of the buffer buf, at the offset you picked, with the buffer matching the registered index buf_index. πŸ’…

basically it works exactly like io_uring_prep_write(3) β€” same vibe, same energy β€” except it requires you to use buffers that you registered with io_uring_register_buffers(3). like, mandatory. no registration, no write. periodt. πŸ”₯

and listen: buf and nbytes have to fall within a region that's specified by buf_index in the previously registered buffer. that part is non-negotiable. but β€” and this is the slay part β€” the buffer does not need to be aligned with the start of the registered buffer. she's flexible like that. ✨

once the write has been prepared, you can submit it with one of the submit functions. that's it, that's the whole thing. go off. πŸŽ€


✨ RETURN VALUE ✨

None. literally nothing. it returns nothing. that's the whole section bestie 😭


✨ ERRORS ✨

the res field of the CQE is where the result of the operation lives. check the related man page for the deets on possible values. πŸ‘‘

⚠️ okay important: where synchronous system calls would return -1 on failure and set errno to the actual error value, io_uring never uses errno. instead it returns the negated errno directly in the CQE res field. so don't go looking for errno in there, she's not home πŸ’€

✨ SEE ALSO ✨


and that's the page!! πŸ’œ this was liburing-2.1, dated February 13, 2022 β€” yes she's an icon, yes she's from liburing, yes she ate. mwah πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from