FDATASYNC(3POSIX)
๐พ FDATASYNC(3POSIX) ๐พ
okay bestie, so this one is from the POSIX Programmer's Manual (yes, that whole manual, we're in it) โจ
๐จ PROLOG ๐จ
Real talk before we even start: this page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ โ so if you're on Linux, go check the corresponding Linux manual page for the actual tea. Also possible: the interface just isn't implemented on Linux at all. ๐
๐ธ NAME ๐ธ
fdatasync โ synchronize the data of a file (REALTIME) ๐ซถ
โจ SYNOPSIS โจ
#include <unistd.h>
int fdatasync(int fildes);
๐ DESCRIPTION ๐
So here's the vibe: fdatasync() shall force all currently queued I/O operations associated with the file indicated by the file descriptor fildes into the synchronized I/O completion state. Like, everything that's been queued up? It's getting flushed. No cap. ๐ฅ
And the functionality shall be equivalent to fsync() with the symbol _POSIX_SYNCHRONIZED_IO defined โ with the exception that all I/O operations shall be completed as defined for synchronized I/O data integrity completion. That's the one little plot twist, iykyk. ๐
๐ RETURN VALUE ๐
If it slays (success): fdatasync() shall return the value 0. โจ
If it does NOT slay: it shall return the value -1 and set errno to indicate the error. ๐ญ
and lowkey important: if fdatasync() fails, outstanding I/O operations are not guaranteed to have been completed. so like, don't assume. ๐
๐ ERRORS ๐
The fdatasync() function shall fail if:
EBADFโ thefildesargument is not a valid file descriptor. bestie that's not a real fd ๐ซEINVALโ this implementation does not support synchronized I/O for this file. it's giving "not supported, sorry" ๐
And plot twist: in the event that any of the queued I/O operations fail, fdatasync() shall return the error conditions defined for read() and write(). so the drama can come from elsewhere fr fr.
The following sections are informative. ๐
๐ EXAMPLES ๐
None. (yeah. that's it. iconic of them honestly.) ๐
๐ฆ APPLICATION USAGE ๐ฆ
Notable note, bestie: 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 fdatasync(). so it's still doing the work even when you didn't think it would. main character energy. โญ
๐ง RATIONALE ๐ง
None.
๐ฎ FUTURE DIRECTIONS ๐ฎ
None.
๐ SEE ALSO ๐
aio_fsync()fcntl()fsync()open()read()write()
And from The Base Definitions volume of POSIX.1โ2017: <unistd.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, you ate it, you read it, you understood it, periodt ๐
signing off with all the love โ IEEE/The Open Group, 2017, and this little page right here: FDATASYNC(3POSIX). mwah ๐
๐ฆ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 ยท Other
- debian trixie: manpages-posix-dev 2017a-2 ยท Other
- ubuntu jammy: manpages-posix-dev 2017a-2 ยท Other
- ubuntu noble: manpages-posix-dev 2017a-2 ยท Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 ยท Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 ยท Other
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms