From nobody Fri Oct 31 14:42:41 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4cykGp1lDdz6Fvps; Fri, 31 Oct 2025 14:42:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cykGn6bFsz3TML; Fri, 31 Oct 2025 14:42:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761921761; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=f5o+iUjy1nZ6ipDwgdOBkj/4K6dwn1ALJ7TQ5aVQjsc=; b=yRbBN/K8ciuTF54ZHRgOL40whZ/fIKP5SyXPDcapj17FmjYf3k/wuFjv7oyNJ5snmpFRi1 wlDigh07Mca2zxKQi+8NuOgCiBamY5HPisd62pgDxGItMJbFLZurlkr8HnST0SUzWAtIHT 8Jg7LpACNBJpTk8KB03r8gydcErQLdhUE90Ktez+2W4rZ/JsswE9LcwJka7NLTjH9+gRm6 Luhhub+okFtBUIfZgTI7E4u54d3Jn4zrnIabsCMlDswqM/tgRmLioU8suCIO6I58m8KTKs IoPI2rpANLyCBI9iZyTQgsQ0JFJ7dSjH90JqF3G8pcprpuS6ga4/T9/UpN3k9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761921761; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=f5o+iUjy1nZ6ipDwgdOBkj/4K6dwn1ALJ7TQ5aVQjsc=; b=vC6ap6XRYe9BUIBsoJVE8zPoNMHA+BfNRcNb/+nBIQwTjJxESPVaXTc0BAcwfyyLk79OWB F5skng184I3c3/YjgQHwm+kq1HY772U4K6CVQJBlZP0oksH/DO/f7J+rQ5C/47BwUZsyQC Qr+ySmz2na0HetTGvtJdW179Pe5iGOMqMMqQ0NbpRtOv8Xc04q6vA3/k/coAQ+z5mLHohl GDT7zOW8gjwEOzGfWj7GH9Cc3yWxukFh+AmrR9+wVEsGLrGUKoZ5Mp4ncXF2FWq8Z9KY2H Xz9hlZoSSJK39jU2xULjA/H/T56m8INVFEFdLgQ2dc6Xi0LRr5yjF6LnEa0DMQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1761921761; a=rsa-sha256; cv=none; b=ZELAMVF7DQX7MT+bBDZd3V0iwSgeW2LzZtv/79DNc/l48NwQXpuh0Acm3cwKz2V4mYWCHG wO6HkAdVQ4pFTfEXBufvl6E7rUJ8ZJ/0CbJU2yFIhueM3MOnFRKbOtLHtjcUpo8IgFvsjI CiT+TcoJe26uoMKDdmMs00it+H7Ek/S+vP6j4pVMI57RORBRYgmIfiR1OqsncLyKgUgYLv nXeo3ZXlzZmj2VhdHJywegL4cRdBtrCMGUpTmIZAQeyHmzXM18EF38VHdb/Q2TP9vFFbrO Ha2+LAr32AWH30uxjLWNNZpS1UK3rXkZI1MWLakJjvQSIGZ0TlZwr/Adbwqing== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4cykGn62Sqz1Bmt; Fri, 31 Oct 2025 14:42:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 59VEgfd6067291; Fri, 31 Oct 2025 14:42:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59VEgf9U067288; Fri, 31 Oct 2025 14:42:41 GMT (envelope-from git) Date: Fri, 31 Oct 2025 14:42:41 GMT Message-Id: <202510311442.59VEgf9U067288@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: c19f161f5f65 - stable/14 - write.2: explain the atomicity guarantees of the writes List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: c19f161f5f65d61c0152587000eff7cae9492843 Auto-Submitted: auto-generated The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c19f161f5f65d61c0152587000eff7cae9492843 commit c19f161f5f65d61c0152587000eff7cae9492843 Author: Konstantin Belousov AuthorDate: 2025-10-26 14:57:16 +0000 Commit: Konstantin Belousov 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.