io_uring_pre...nc_file_range(3)

✨ io_uring_prep_sync_file_range β€” bestie edition πŸ’…

okay so this is a page from the liburing Manual, and it's about the cutest little helper that queues up a sync_file_range request for you. no cap, it's short, it's sweet, it slays. let's get into it 🫢


🌸 NAME 🌸

io_uring_prep_sync_file_range β€” prepare a sync_file_range request


πŸŽ€ SYNOPSIS πŸŽ€

#include <fcntl.h>
#include <liburing.h>

void io_uring_prep_sync_file_range(struct io_uring_sqe *sqe,
                                   int fd,
                                   unsigned len,
                                   __u64 offset,
                                   int flags);

πŸ’– DESCRIPTION πŸ’–

so like. the io_uring_prep_sync_file_range(3) function prepares a sync_file_range request. that's literally its whole job and it does it flawlessly, periodt.

the submission queue entry sqe gets set up to use the file descriptor fd β€” that's the file that's gonna get len bytes synced, starting at offset offset, with the modifier flags in the flags argument. yes the argument is called flags and it holds flags. iconic naming honestly, we love a self-explanatory king πŸ‘‘

this function prepares an async sync_file_range(2) request. so if you wanna know the actual details on what those arguments do, go read that man page bestie, this one is just the setup girlie 🧚


⭐ RETURN VALUE ⭐

None

that's it. nothing. void. she returns nothing and she's valid for it πŸ’…


😭 ERRORS 😭

the CQE res field will contain the result of the operation. peek at the related man page for details on possible values, iykyk.

important: where synchronous system calls will 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 like, don't go checking errno, she doesn't live there anymore. it's giving glow up πŸ’€

🌈 SEE ALSO 🌈


and that's the whole page bestie!! πŸ¦‹ this was brought to you by liburing-2.2, dated March 12, 2022 β€” go sync some file ranges, you absolute main character πŸ‘‘πŸ’–βœ¨

πŸ“¦ where this page comes from