Date: Fri, 31 Oct 2025 14:42:41 GMT From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: c19f161f5f65 - stable/14 - write.2: explain the atomicity guarantees of the writes Message-ID: <202510311442.59VEgf9U067288@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c19f161f5f65d61c0152587000eff7cae9492843 commit c19f161f5f65d61c0152587000eff7cae9492843 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2025-10-26 14:57:16 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2025-10-31 14:42:18 +0000 write.2: explain the atomicity guarantees of the writes (cherry picked from commit 1c8d7bb4cf7a6b19262333b2a9b1dacf3094b938) --- lib/libc/sys/write.2 | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/libc/sys/write.2 b/lib/libc/sys/write.2 index adf60aa91d7a..2f0a9d034038 100644 --- a/lib/libc/sys/write.2 +++ b/lib/libc/sys/write.2 @@ -134,6 +134,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.home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202510311442.59VEgf9U067288>
