Skip to content

Turning "normal" FD into a fixed/direct one #1141

Answered by axboe
cmazakas asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, you want to use io_uring_register_files_update() for that case. It basically just replaces an existing fixed file slot with whatever you provide. If the slot is currently empty (eg holds -1, sparse), then the sparse entry is replaced with the file you specify and put into the given offset.

There are really two ways to turn a normal file descriptor into a regular one - either register it like that in the first place, eg when you register the table, or do it via io_uring_register_files_update.

The test cases have some usage of it, here's a bare bones example of registering a sparse table and then later putting a pipe fd in there:

int main(int argc, char *argv[])
{
	struct io_uring_sqe …

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@axboe
Comment options

axboe May 1, 2024
Maintainer

@cmazakas
Comment options

@axboe
Comment options

axboe May 1, 2024
Maintainer

@cmazakas
Comment options

@axboe
Comment options

axboe May 1, 2024
Maintainer

Answer selected by cmazakas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants