FDATASYNC(3P)
πΎ fdatasync β the POSIX page, but make it slay
okay bestie, welcome to FDATASYNC(3P) from the POSIX Programmer's Manual. Yes, the manual name is right there in the title, we're not doing a whole separate header line, we're keeping it cute. Let's go π
π’ PROLOG
So this page? It's part of the POSIX Programmer's Manual. That's the vibe.
Heads up though: the Linux implementation of this interface may differ from what's written here β like, consult the corresponding Linux manual page for the details of Linux behavior. Or the interface might just not be implemented on Linux at all. Not me being dramatic, that's literally what it says π
β¨ NAME
fdatasync β synchronize the data of a file (REALTIME)
π SYNOPSIS
#include <unistd.h>
int fdatasync(int fildes);
π DESCRIPTION
The fdatasync() function shall force all currently queued I/O operations associated with the file indicated by the file descriptor fildes to the synchronized I/O completion state. Like, everything that's queued up? It's going in. Periodt.
And the functionality shall be equivalent to fsync() with the symbol _POSIX_SYNCHRONIZED_IO defined β with the one exception that all I/O operations shall be completed as defined for synchronized I/O data integrity completion. That's the whole tea. π«
π¦ RETURN VALUE
If it's successful, fdatasync() shall return the value 0. Iconic. We love a zero.
Otherwise? The function shall return the value -1 and set errno to indicate the error. π
And if fdatasync() fails, outstanding I/O operations are not guaranteed to have been completed. So yeah, that's a whole thing.
π 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. Rude, but okay.
And in the event that any of the queued I/O operations fail, fdatasync() shall return the error conditions defined for read() and write().
The following sections are informative. (Just so you know which ones are the β¨requiredβ¨ lore and which ones are bonus content.)
πΈ EXAMPLES
None. Truly nothing. Empty. The void. π
π APPLICATION USAGE
Okay so real talk β 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 don't think you're off the hook just because you opened it read-only. π§
β RATIONALE
None. Moving on, nothing to see here, we're keeping it moving. π
π FUTURE DIRECTIONS
None. The future is unspecified and honestly? Same.
π 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 .
that's the whole page, bestie, no cap π β this one's brought to you by IEEE/The Open Group, dated 2017, and yes, the man page is literally called FDATASYNC(3P). iykyk π¦β¨
π¦ 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