io_uring_prep_read(3)
π io_uring_prep_read β the liburing manual, but make it cute π
okay bestie, welcome to io_uring_prep_read(3) from the liburing manual β¨ this is the one that sets you up to read stuff asynchronously, and she is lowkey iconic. let's get into it π«Ά
β¨ NAME β¨
io_uring_prep_read β prepare an I/O read request π
πΈ SYNOPSIS πΈ
#include <liburing.h>
void io_uring_prep_read(struct io_uring_sqe *sqe,
int fd,
void *buf,
unsigned nbytes,
__u64 offset);
look at her. five little arguments. so demure, so mindful π
π¦ DESCRIPTION π¦
So io_uring_prep_read(3) prepares an IO read request. It takes the submission queue entry sqe and sets it all up to use the file descriptor fd to start reading nbytes into the buffer buf at the specified offset. Slay. That's the whole vibe. β¨
Now here's the part where you have to actually pay attention, bestie, because there's lore:
On files that support seeking, if the offset is set to -1, the read operation commences at the file offset, and the file offset is incremented by the number of bytes read. See read(2) for more details π
π¨ okay but fr fr β for an async API, reading and updating the current file offset may result in unpredictable behavior, unless access to the file is serialized. It is not encouraged to use this feature, if it's possible to provide the desired IO offset from the application or library. likeβ¦ just pass the offset, babe. it's giving safer. π
And on files that are not capable of seeking, the offset must be 0 or -1. No other options. That's the rule. Periodt. π
After the read has been prepared, it can be submitted with one of the submit functions. that's the part where she actually goes and does the thing π«
π RETURN VALUE π
None. literally nothing. she's a void function. she sets up the sqe and dips. no cap. π
π ERRORS π
okay so here's the tea π β the CQE res field will contain the result of the operation. See the related man page for details on possible values.
β¨ important distinction, bestie: where synchronous system calls will return-1on failure and seterrnoto the actual error value,io_uringnever useserrno. Instead it returns the negated errno directly in the CQEresfield. so like,-EAGAINshows up as-11style negativity. iconic behavior honestly π
π SEE ALSO π
go read those too, they're all part of the same friend group π«Ά
liburing-2.1 πΈ November 15, 2021 β mwah, that's the version and the date, love u, bye bestie, go read some bytes πβ¨π
π¦ where this page comes from
- alpine 3.22: liburing-doc 2.9-r0 Β· LGPL-2.1-or-later OR MIT
- alpine 3.23: liburing-doc 2.12-r0 Β· LGPL-2.1-or-later OR MIT
- alpine 3.24: liburing-doc 2.14-r0 Β· LGPL-2.1-or-later OR MIT
- centos-stream 10: liburing-devel 2.12-1.el10 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- centos-stream 9: liburing-devel 2.12-1.el9 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- centos-stream 9: liburing-devel 2.12-1.el9 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- debian bookworm: liburing-dev 2.3-3
- debian trixie: liburing-dev 2.9-1
- fedora 43: liburing-devel 2.9-2.fc43 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- fedora 43: liburing-devel 2.9-2.fc43 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- fedora 44: liburing-devel 2.13-2.fc44 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- fedora 44: liburing-devel 2.13-2.fc44 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- nixpkgs unstable: liburing 2.14
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- ubuntu noble: liburing-dev 2.5-1build1
- ubuntu questing: liburing-dev 2.11-1
- ubuntu resolute: liburing-dev 2.14-1
- π the page's license: LGPL-2.0-or-later
- Copyright (C) 2021 Stefan Roesch <shr@fb.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms