io_uring_register_query(3)

πŸ“¦ version 2.15, in arch rolling, ubuntu stonking

πŸ’– io_uring_register_query β€” your lil' feature-detector bestie πŸ’–

okay so this is a page from the liburing Manual (yes, the manual, but make it cute) and it's all about io_uring_register_query(3), aka the function that lets you ask the kernel what it can do before you commit to anything. it's giving "let me check ur vibe first" energy and honestly? we love that for us. πŸ¦‹


✨ NAME ✨

io_uring_register_query β€” query io_uring capabilities and feature support πŸ‘‘

ngl the name is literally the whole job: you're querying what io_uring supports. that's it. that's the gig. πŸ’…


🌸 SYNOPSIS 🌸

#include <liburing.h>

int io_uring_register_query(struct io_uring_query_hdr *query);

one function, one pointer, zero drama. slay. ✨


πŸŽ€ DESCRIPTION πŸŽ€

so, bestie, io_uring_register_query(3) is the function that goes "hey kernel, whatcha got?" and comes back with the receipts. it hands you info about supported opcodes, flags, and subsystem-specific capabilities. no cap, it's your pre-flight check. πŸ”₯

the query argument has to point to a struct io_uring_query_hdr structure, and that struct is what tells the kernel what you wanna know. here's the whole thing, verbatim, iconic:

struct io_uring_query_hdr {
    __u64 next_entry;
    __u64 query_data;
    __u32 query_op;
    __u32 size;
    __s32 result;
    __u32 __resv[3];
};

let's break down every single field because we are thorough in this house:

  • next_entry β€” this is your chain-maker 🫢. it can point to the next struct io_uring_query_hdr structure, or you set it to 0 if this is the last entry in the chain. one query to rule them all, or a whole conga line β€” your call.
  • query_data β€” must point to a data structure that actually matches the query type you put in query_op. wrong struct here = wrong vibes, so match them up. 🧚
  • query_op β€” the field that says which query you're doing. and it can be one of these three beauties:
    • IO_URING_QUERY_OPCODES β€” returns info about supported opcodes and flags πŸ’«. your query_data field must point to a struct io_uring_query_opcode structure, and it'll get filled in with info about supported request opcodes, register opcodes, feature flags, setup flags, enter flags, and SQE flags. it's the full buffet, fr fr.
    • IO_URING_QUERY_ZCRX β€” returns info about zero-copy receive support 🌈. your query_data field must point to a struct io_uring_query_zcrx structure, and it gets filled with info about supported zero-copy receive flags, features, and configuration details.
    • IO_URING_QUERY_SCQ β€” returns info about the SQ/CQ ring layout πŸŽ€. your query_data field must point to a struct io_uring_query_scq structure, and it gets filled with info about ring header size and alignment requirements.
  • size β€” set this to the size of the data structure that query_data points to. yes, the kernel wants to know how big the thing is. be honest with it. πŸ’–
  • result β€” upon return, this is where the answer lands: 0 on success, or a negative error code on failure 😭. check it. always.
  • __resv β€” the reserved fields. they must be cleared to zero. no sneaky little values in there, bestie, that's the rule. 🚫

⭐ RETURN VALUE ⭐

returns 0 on success πŸ’…. on error, it returns a negative errno value. so if your number is less than zero, something went sideways and that's your sign to look at it.


πŸ“ NOTES πŸ“

  • this function is available since Linux kernel 6.15 🌱 (so if you're on something older, it's simply not gonna happen, and that's not a skill issue, it's a kernel issue).
  • you can do multiple queries efficiently in a single system call by chaining them together using the next_entry field πŸ”—. one syscall, many questions, maximum efficiency. main character energy, genuinely.

πŸ‘€ SEE ALSO πŸ‘€


ok real talk: if result comes back negative, do NOT just ignore it and keep vibing. read the errno. the kernel is telling you something and it's not being subtle. πŸ’€

and that's the whole page, bestie!! this one's from liburing-2.15, dated March 26, 2026 πŸ’œ β€” go forth, chain ur queries, respect ur __resv fields, and always, always check that result. mwah 🫢✨

πŸ“¦ where this page comes from