io_prep_pwrite(3)
β¨ io_prep_pwrite β the Linux AIO glow-up β¨
okay bestie, welcome to io_prep_pwrite(3), part of the Linux AIO crew π¦ this is the little helper that gets your asynchronous writes ready to slay. no cap, it's giving backstage-pass energy β it sets everything up so the real show (io_submit) can happen later π
πΈ NAME πΈ
io_prep_pwrite β Set up iocb for asynchronous writes
π SYNOPSIS π
#include <errno.h>
#include <libaio.h>
inline void io_prep_pwrite(struct iocb *iocb, int fd, void *buf, size_t count, long long offset);
struct iocb {
void *data;
unsigned key;
short aio_lio_opcode;
short aio_reqprio;
int aio_fildes;
};
π DESCRIPTION π
io_prep_write() is literally a convenience function for setting up parallel writes. it's the "here, let me hold your stuff while you get ready" friend π«Ά
so here's the tea: the first iocb->u.c.nbytes = count bytes of the file β the one where iocb->aio_fildes = fd is the descriptor β get written from the buffer starting at iocb->u.c.buf = buf. and the writing kicks off at the absolute position ioc->u.c.offset = offset in the file π
heads up: this function returns immediately. like, instantly. to actually schedule the operation you must callio_submit(3). noio_submit, no write. periodt π
π¨ also bestie, listen: simultaneous asynchronous operations using the sameiocbproduce undefined results. sameiocb, two ops at once = chaos, and not the fun kind. don't do it π
β RETURN VALUES β
None. nothing. niente. it just does its thing and dips β¨
π ERRORS π
None. zero drama, zero errors. it's the low-maintenance icon we deserve π
π¦ SEE ALSO π¦
io(3)io_cancel(3)io_fsync(3)io_getevents(3)io_prep_fsync(3)io_prep_pread(3)io_queue_init(3)io_queue_release(3)io_queue_run(3)io_queue_wait(3)io_set_callback(3)io_submit(3)errno(3)
and that's the whole page, bestie π this one's from Linux, dated 2019-07-23 β so it's a lil vintage but it still ate, fr fr. go forth and io_submit responsibly π§π
π¦ where this page comes from
- alpine 3.22: libaio-doc 0.3.113-r2 Β· LGPL-2.1-or-later
- alpine 3.23: libaio-doc 0.3.113-r2 Β· LGPL-2.1-or-later
- alpine 3.24: libaio-doc 0.3.113-r2 Β· LGPL-2.1-or-later
- arch rolling: libaio 0.3.113-5 Β· LGPL-2.0-or-later
- debian bookworm: libaio-dev 0.3.113-4 Β· LGPL-2.1-or-later
- debian trixie: libaio-dev 0.3.113-8+b1 Β· LGPL-2.1-or-later
- ubuntu jammy: libaio-dev 0.3.112-13build1 Β· LGPL-2.1-or-later
- ubuntu noble: libaio-dev 0.3.113-6build1 Β· LGPL-2.1-or-later
- ubuntu noble: libaio-dev 0.3.113-6build1.1 Β· LGPL-2.1-or-later
- ubuntu questing: libaio-dev 0.3.113-8
- ubuntu resolute: libaio-dev 0.3.113-8build1 Β· LGPL-2.1-or-later
- ubuntu stonking: libaio-dev 0.3.113-9 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms