aboutsummaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorThomas Munro <tmunro@FreeBSD.org>2021-01-07 10:46:51 +0000
committerThomas Munro <tmunro@FreeBSD.org>2021-01-08 00:15:56 +0000
commita5e284038edc36b0447f1e6337419a3c0ea1788d (patch)
treedb9ff03268a0007b04d9d4b174462f364feebe69 /lib/libc
parent81098ca81dd09514f702f8087d01f66b6156f95c (diff)
downloadsrc-a5e284038edc36b0447f1e6337419a3c0ea1788d.tar.gz
src-a5e284038edc36b0447f1e6337419a3c0ea1788d.zip
open(2): Add O_DSYNC flag.
POSIX O_DSYNC means that writes include an implicit fdatasync(2), just as O_SYNC implies fsync(2). VOP_WRITE() functions that understand the new IO_DATASYNC flag can act accordingly, but we'll still pass down IO_SYNC so that file systems that don't understand it will continue to provide the stronger O_SYNC behaviour. Flag also applies to fcntl(2). Reviewed by: kib, delphij Differential Revision: https://reviews.freebsd.org/D25090
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/sys/fcntl.219
-rw-r--r--lib/libc/sys/open.220
2 files changed, 30 insertions, 9 deletions
diff --git a/lib/libc/sys/fcntl.2 b/lib/libc/sys/fcntl.2
index 9793024f48ed..33ad7a5673e1 100644
--- a/lib/libc/sys/fcntl.2
+++ b/lib/libc/sys/fcntl.2
@@ -28,7 +28,7 @@
.\" @(#)fcntl.2 8.2 (Berkeley) 1/12/94
.\" $FreeBSD$
.\"
-.Dd January 17, 2020
+.Dd January 6, 2021
.Dt FCNTL 2
.Os
.Sh NAME
@@ -196,7 +196,7 @@ The flags for the
.Dv F_GETFL
and
.Dv F_SETFL
-flags are as follows:
+commands are as follows:
.Bl -tag -width O_NONBLOCKX
.It Dv O_NONBLOCK
Non-blocking I/O; if no data is available to a
@@ -225,6 +225,21 @@ Enable the
signal to be sent to the process group
when I/O is possible, e.g.,
upon availability of data to be read.
+.It Dv O_SYNC
+Enable synchronous writes.
+Corresponds to the
+.Dv O_SYNC
+flag of
+.Xr open 2 .
+.Dv O_FSYNC
+is an historical synonym for
+.Dv O_SYNC .
+.It Dv O_DSYNC
+Enable synchronous data writes.
+Corresponds to the
+.Dv O_DSYNC
+flag of
+.Xr open 2 .
.El
.Pp
The seals that may be applied with
diff --git a/lib/libc/sys/open.2 b/lib/libc/sys/open.2
index d0918fb02eee..e43d012770df 100644
--- a/lib/libc/sys/open.2
+++ b/lib/libc/sys/open.2
@@ -181,8 +181,9 @@ O_EXCL error if create and file exists
O_SHLOCK atomically obtain a shared lock
O_EXLOCK atomically obtain an exclusive lock
O_DIRECT eliminate or reduce cache effects
-O_FSYNC synchronous writes
+O_FSYNC synchronous writes (historical synonym for O_SYNC)
O_SYNC synchronous writes
+O_DSYNC synchronous data writes
O_NOFOLLOW do not follow symlinks
O_NOCTTY ignored
O_TTY_INIT ignored
@@ -230,15 +231,18 @@ returns immediately.
The descriptor remains in non-blocking mode for subsequent operations.
.Pp
If
-.Dv O_FSYNC
+.Dv O_SYNC
is used in the mask, all writes will
immediately and synchronously be written to disk.
-.Pp
-.Dv O_SYNC
-is a synonym for
.Dv O_FSYNC
-required by
-.Tn POSIX .
+is an historical synonym for
+.Dv O_SYNC .
+.Pp
+If
+.Dv O_DSYNC
+is used in the mask, all data and metadata required to read the data will be
+synchronously written to disk, but changes to metadata such as file access and
+modification timestamps may be written later.
.Pp
If
.Dv O_NOFOLLOW
@@ -651,6 +655,8 @@ The
.Fn openat
function was introduced in
.Fx 8.0 .
+.Dv O_DSYNC
+appeared in 13.0.
.Sh BUGS
The Open Group Extended API Set 2 specification requires that the test
for whether