AIO_FSYNC(3P)
π AIO_FSYNC(3P) β POSIX Programmer's Manual π
okay bestie, quick heads up before we even start: this page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (so like, go read the corresponding Linux manual page for the tea β), or honestly the interface might not even be implemented on Linux at all. no cap. π
β¨ NAME β¨
aio_fsync β asynchronous file synchronization π¦
πΈ SYNOPSIS πΈ
#include <aio.h>
int aio_fsync(int op, struct aiocb *aiocbp);
π DESCRIPTION π
So aio_fsync() shall asynchronously perform a file synchronization operation, and which flavor of sync you get is decided by the op argument. It's doing this for the I/O operations associated with the file indicated by the aio_fildes member of the aiocb structure referenced by the aiocbp argument β specifically the ones queued at the time of the call to aio_fsync(). And the function call shall return once the synchronization request has been initiated or queued to the file or device β even when the data literally cannot be synchronized immediately. iconic behavior honestly.
If op is O_DSYNC, all currently queued I/O operations shall be completed as if by a call to fdatasync(); that is, as defined for synchronized I/O data integrity completion.
If op is O_SYNC, all currently queued I/O operations shall be completed as if by a call to fsync(); that is, as defined for synchronized I/O file integrity completion. And here's the scary part, so listen up π: if the aio_fsync() function fails, or if the operation queued by aio_fsync() fails, then outstanding I/O operations are not guaranteed to have been completed. it's giving chaos, ngl.
If aio_fsync() succeeds, then it is only the I/O that was queued at the time of the call to aio_fsync() that is guaranteed to be forced to the relevant completion state. The completion of subsequent I/O on the file descriptor is not guaranteed to be completed in a synchronized fashion. periodt.
The aiocbp argument refers to an asynchronous I/O control block. The aiocbp value may be used as an argument to aio_error() and aio_return() in order to determine the error status and return status, respectively, of the asynchronous operation while it is proceeding. When the request is queued, the error status for the operation is [EINPROGRESS]. When all data has been successfully transferred, the error status shall be reset to reflect the success or failure of the operation. If the operation does not complete successfully, the error status for the operation shall be set to indicate the error. The aio_sigevent member determines the asynchronous notification to occur as specified in Section 2.4.1, Signal Generation and Delivery when all operations have achieved synchronized I/O completion. All other members of the structure referenced by aiocbp are ignored. And if the control block referenced by aiocbp becomes an illegal address prior to asynchronous I/O completion, then the behavior is undefined. π so pls don't do that.
If the aio_fsync() function fails or aiocbp indicates an error condition, data is not guaranteed to have been successfully transferred.
π RETURN VALUE π
The aio_fsync() function shall return the value 0 if the I/O operation is successfully queued π; otherwise, the function shall return the value -1 and set errno to indicate the error. slay if it's zero, sad girl hours if it's negative.
π₯ ERRORS π₯
The aio_fsync() function shall fail if:
EAGAINβ the requested asynchronous operation was not queued due to temporary resource limitations. like babe it's not you, it's the resources πEBADFβ theaio_fildesmember of theaiocbstructure referenced by theaiocbpargument is not a valid file descriptor. nope, that fd is not real.EINVALβ this implementation does not support synchronized I/O for this file.EINVALβ theaio_fildesmember of theaiocbstructure refers to a file on which anfsync()operation is not possible.EINVALβ a value ofopother thanO_DSYNCorO_SYNCwas specified, orO_DSYNCwas specified and the implementation does not provide runtime support for the Synchronized Input and Output option, orO_SYNCwas specified and the implementation does not provide runtime support for the File Synchronization option.
In the event that any of the queued I/O operations fail, aio_fsync() shall return the error condition defined for read() and write(). The error is returned in the error status for the asynchronous operation, which can be retrieved using aio_error(). π«Ά
The following sections are informative.
π EXAMPLES π
None. (bestie there are literally zero examples here, I'm as disappointed as you are π)
π APPLICATION USAGE π
Note that even if the file descriptor is not open for writing, if there are any pending write requests on the underlying file, then that I/O will be completed prior to the return of a call to aio_error() or aio_return() indicating that the operation has completed. sneaky but true. π
π§ RATIONALE π§
None.
β FUTURE DIRECTIONS β
None.
π¦ SEE ALSO π¦
aio_error()aio_return()fcntl()fdatasync()fsync()open()read()write()
The Base Definitions volume of POSIX.1β2017, <aio.h> πΈ
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
okay that's the whole page bestie, mwah π«Ά this one came to you from IEEE/The Open Group, 2017 β go forth and synchronize your I/O asynchronously, you absolute icon ππ
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- 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-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms