summaryrefslogtreecommitdiffstats
path: root/man2/fsync.2
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--man2/fsync.247
1 files changed, 26 insertions, 21 deletions
diff --git a/man2/fsync.2 b/man2/fsync.2
index 623e7ca..8566ef7 100644
--- a/man2/fsync.2
+++ b/man2/fsync.2
@@ -15,7 +15,7 @@
.\" 2006-04-28, mtk, substantial rewrite of various parts.
.\" 2012-02-27 Various changes by Christoph Hellwig <hch@lst.de>
.\"
-.TH fsync 2 2023-03-30 "Linux man-pages 6.05.01"
+.TH fsync 2 2023-10-31 "Linux man-pages 6.7"
.SH NAME
fsync, fdatasync \- synchronize a file's in-core state with storage device
.SH LIBRARY
@@ -24,17 +24,17 @@ Standard C library
.SH SYNOPSIS
.nf
.B #include <unistd.h>
-.PP
+.P
.BI "int fsync(int " fd );
-.PP
+.P
.BI "int fdatasync(int " fd );
.fi
-.PP
+.P
.RS -4
Feature Test Macro Requirements for glibc (see
.BR feature_test_macros (7)):
.RE
-.PP
+.P
.nf
.BR fsync ():
glibc 2.16 and later:
@@ -43,7 +43,7 @@ Feature Test Macro Requirements for glibc (see
_BSD_SOURCE || _XOPEN_SOURCE
|| /* Since glibc 2.8: */ _POSIX_C_SOURCE >= 200112L
.fi
-.PP
+.P
.BR fdatasync ():
.nf
_POSIX_C_SOURCE >= 199309L || _XOPEN_SOURCE >= 500
@@ -59,12 +59,12 @@ changed information can be retrieved even if the system crashes or
is rebooted.
This includes writing through or flushing a disk cache if present.
The call blocks until the device reports that the transfer has completed.
-.PP
+.P
As well as flushing the file data,
.BR fsync ()
also flushes the metadata information associated with the file (see
.BR inode (7)).
-.PP
+.P
Calling
.BR fsync ()
does not necessarily ensure
@@ -72,7 +72,7 @@ that the entry in the directory containing the file has also reached disk.
For that an explicit
.BR fsync ()
on a file descriptor for the directory is also needed.
-.PP
+.P
.BR fdatasync ()
is similar to
.BR fsync (),
@@ -93,7 +93,7 @@ On the other hand, a change to the file size
as made by say
.BR ftruncate (2)),
would require a metadata flush.
-.PP
+.P
The aim of
.BR fdatasync ()
is to reduce disk activity for applications that do not
@@ -130,12 +130,16 @@ all file descriptors that were open on the file when the error was recorded.
.B ENOSPC
Disk space was exhausted while synchronizing.
.TP
-.BR EROFS ", " EINVAL
+.B EROFS
+.TQ
+.B EINVAL
.I fd
is bound to a special file (e.g., a pipe, FIFO, or socket)
which does not support synchronization.
.TP
-.BR ENOSPC ", " EDQUOT
+.B ENOSPC
+.TQ
+.B EDQUOT
.I fd
is bound to a file on NFS or another filesystem which does not allocate
space at the time of a
@@ -155,23 +159,17 @@ to a value greater than 0.
.\" POSIX.1-2001: It shall be defined to -1 or 0 or 200112L.
.\" -1: unavailable, 0: ask using sysconf().
.\" glibc defines them to 1.
-.PP
-On some UNIX systems (but not Linux),
-.I fd
-must be a
-.I writable
-file descriptor.
.SH STANDARDS
POSIX.1-2008.
.SH HISTORY
-POSIX.1-2001, 4.3BSD.
-.PP
+POSIX.1-2001, 4.2BSD.
+.P
In Linux 2.2 and earlier,
.BR fdatasync ()
is equivalent to
.BR fsync (),
and so has no performance advantage.
-.PP
+.P
The
.BR fsync ()
implementations in older kernels and lesser used filesystems
@@ -181,6 +179,13 @@ In these cases disk caches need to be disabled using
or
.BR sdparm (8)
to guarantee safe operation.
+.P
+Under AT&T UNIX System V Release 4
+.I fd
+needs to be opened for writing.
+This is by itself incompatible with the original BSD interface
+and forbidden by POSIX,
+but nevertheless survives in HP-UX and AIX.
.SH SEE ALSO
.BR sync (1),
.BR bdflush (2),