mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-11-07 04:36:52 -10:00
write.2: explain the atomicity guarantees of the writes
Also provide the pointer to the latest POSIX standard that justifies the requirement. Reviewed by: emaste Discussed with: rmacklem Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D53361
This commit is contained in:
1 parent
5d42c88139
commit
1c8d7bb4cf
1 file changed
+20
@@ -132,6 +132,26 @@ and
|
||||
may write fewer bytes than requested;
|
||||
the return value must be noted,
|
||||
and the remainder of the operation should be retried when possible.
|
||||
.Sh ATOMICITY OF WRITES
|
||||
When operating on regular files on local file systems, the effects of
|
||||
.Fn write
|
||||
are atomic.
|
||||
As required by the POSIX standard,
|
||||
the
|
||||
.Fn read ,
|
||||
.Fn write ,
|
||||
and
|
||||
.Fn ftruncate
|
||||
functions and their variations are atomic with respect to
|
||||
each other on the file data and metadata for regular files.
|
||||
See for instance
|
||||
.St -p1003.1-2024
|
||||
Volume 2, Section 2.9.7 for more information.
|
||||
.Pp
|
||||
.Fx
|
||||
implements the requirement by taking
|
||||
a read/write range lock on the file byte range
|
||||
affected by the corresponding function.
|
||||
.Sh RETURN VALUES
|
||||
Upon successful completion the number of bytes which were written
|
||||
is returned.
|
||||
|
||||
Reference in new issue
Block a user