aio_fsync(3)

✨ aio_fsync(3) ✨

okay bestie, so you're deep in the librt corner of the library (that's the real-time library, -lrt, keep it πŸ’…) and this is the Library Functions Manual page for aio_fsync. it's giving asynchronous file sync, it's giving "yes i queued your write, no i did not wait for it." let's get into it πŸ¦‹


🌸 NAME 🌸

aio_fsync β€” asynchronous file synchronization. that's it, that's the whole vibe ✨


πŸŽ€ LIBRARY πŸŽ€

the real-time library, aka librt, and you link it like this:

-lrt

that's the one, no cap 🫢


πŸ”₯ SYNOPSIS πŸ”₯

#include <aio.h>

int aio_fsync(int op, struct aiocb *aiocbp);

so two args, op and a pointer to a struct aiocb called aiocbp. she's simple like that πŸ’–


πŸ’œ DESCRIPTION πŸ’œ

so aio_fsync() does a sync on all the outstanding asynchronous I/O operations that are associated with aiocbp->aio_fildes. and if you're like "wait what even is the aiocb structure," go read aio(7), it has the whole description, i'm not doing that to you here 🫢

more precisely (because apparently we're being precise now, okay, periodt):

  • if op is O_SYNC, then all currently queued I/O operations shall be completed as if by a call of fsync(2)
  • if op is O_DSYNC, this call is the asynchronous analog of fdatasync(2)

and here's the thing bestie β€” this is a request only; it does not wait for I/O completion. so don't be out here assuming it finished, because it did not, it just put in the request like a text message you send and immediately put your phone down ✨

apart from aio_fildes, the only field in the structure pointed to by aiocbp that this call uses is the aio_sigevent field β€” that's a sigevent structure, described over in sigevent(3type) β€” and it tells you what kind of asynchronous notification you want at completion. every other field? ignored. not used. not read. don't @ me 😭


πŸ’– RETURN VALUE πŸ’–

  • on success β€” meaning the sync request was successfully queued β€” this function returns 0 πŸ‘‘
  • on error it returns -1, and errno gets set to tell you what went wrong

🩷 ERRORS 🩷

like, the whole errno roster:

  • EAGAIN β€” out of resources. she's tapped out, no more to give πŸ’€
  • EBADF β€” aio_fildes is not a valid file descriptor open for writing
  • EINVAL β€” synchronized I/O is not supported for this file, or op is not O_SYNC or O_DSYNC
  • ENOSYS β€” aio_fsync() is not implemented πŸ™ˆ

πŸ¦‹ ATTRIBUTES πŸ¦‹

for the whole explanation of what these terms even mean, go check out attributes(7). here's the rundown:

  • aio_fsync() β€” Thread safety: MT-Safe πŸ”₯

MT-Safe means she's safe to call from multiple threads, slay πŸ’…


⭐ STANDARDS ⭐

POSIX.1-2008. that's the standard she follows, periodt ✨


🌈 HISTORY 🌈

  • glibc 2.1
  • POSIX.1-2001

so she's been around a minute, an icon honestly πŸ‘‘


πŸ’… SEE ALSO πŸ’…

go get your read on, bestie:


and that's the page!! this came to you from Linux man-pages 6.20, dated 2026-02-08, and honestly that's such a cute little timestamp. stay async, stay synced, queue your requests and don't wait around for them πŸ«ΆπŸ’–βœ¨

πŸ“¦ where this page comes from
  • arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • πŸ“œ the page's license: GPL-2.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms