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 β€” The fildes argument 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> πŸŽ€


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