io_uring_prep_ftruncate(3)

✨ io_uring_prep_ftruncate β€” prepare an ftruncate request ✨

okay so bestie, this is page 3 of the liburing Manual for io_uring_prep_ftruncate, and I am so ready to tell you about it πŸ’–


πŸŽ€ NAME πŸŽ€

io_uring_prep_ftruncate β€” prepare an ftruncate request

like. that's it. that's the whole job. and she does it flawlessly πŸ’…


🌸 SYNOPSIS 🌸

#include <liburing.h>

void io_uring_prep_ftruncate(struct io_uring_sqe *sqe,
                             int fd,
                             loff_t len);

πŸ¦‹ DESCRIPTION πŸ¦‹

so the io_uring_prep_ftruncate(3) function prepares an ftruncate request, no cap. The submission queue entry sqe gets set up to use the file descriptor fd β€” that's the one that should get truncated β€” down (or up, we don't judge) to the length indicated by the len argument. iconic behaviour honestly ✨

🚨 important bestie alert 🚨 Applications must define _GNU_SOURCE to obtain the definition of this helper, because loff_t will not be defined without it. and if loff_t isn't defined, nothing compiles, and we simply cannot have that 😭

πŸ’œ RETURN VALUE πŸ’œ

None. she returns nothing. she's mysterious like that πŸ™ˆ


πŸ”₯ ERRORS πŸ”₯

The CQE res field will contain the result of the operation. See the related man page for the details on possible values, fr fr β€” I'm not about to make up numbers that aren't in the original, that's not the vibe. πŸ’€

Now here's the part you need to know: where synchronous system calls will return -1 on failure and set errno to the actual error value, io_uring never uses errno. periodt. Instead it returns the negated errno directly in the CQE res field. so like, negative number = your error code, just flipped. remember that or you'll be debugging for three business days 🫢


🌈 SEE ALSO 🌈


and that's the whole page!! go truncate something responsibly, bestie πŸ’–βœ¨πŸŒΈπŸ¦‹πŸŽ€πŸ’…

this was page io_uring_prep_ftruncate(3) from liburing-2.6, dated January 23, 2024 β€” ty for coming to my ted talk, mwah 😘

πŸ“¦ where this page comes from