From nobody Sun Oct 26 17:36:13 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 4cvkMK5JfZz6DfFs; Sun, 26 Oct 2025 17:36:13 +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 4cvkMK4lKLz3xXH; Sun, 26 Oct 2025 17:36:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761500173; 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=hYBkdgPT0TqkeSihryXL7A1CPFje7ac5EUqj8H0jfus=; b=Ee5xAw7tn4fiB+52LzJCrmuwsdUHSzwyS0UV4rrwzwQzk7Jlk+1rM0tPNVsL/IKJwZgTiM pMRNx7wd2nJTCiH+Gduo/AUzeFh6Tq5sY9sa5f5hyEMJkeL65Sl4ZXtTrGKFd7sceYWDpD his51n2vNijkcYAJAOdq7+R97zGUjabPJQNaZSxjZ5b0NdMcIl8HmqIY3D6k6KIYb7AhWP 1I2NJptzRh/tJ2dv0nCVWgeG2brj+PPKguvwTYIIQXrHwj/7s6IrSPJ7mrRR+guAGNvhbM yrq7RiukSIxoyLm1VlLjZXTZ5hY6NV4vjy8tBdzGkHPYmOvOIL53HIUG7SQM9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761500173; 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=hYBkdgPT0TqkeSihryXL7A1CPFje7ac5EUqj8H0jfus=; b=fMEB4VrEAFNEWmlW+LvqvWRj+kLkTxNaKYR8ACBH92zomwouAnt5jLIcQ+sLyjJEfRYRw6 nu2ULMk+BUhQI472fb2ZSFLwQijWrtHBLGFbAjGK72/l7T3QL5SNyEFwP2nyr3w85WdMrt 4bSmuaPGYN+MM5ZUb0ut35nrZxe2DxaSd3acyZAyOB4hCKrkN3MHjo9LCbyGu/OysJ3P4/ UNJlFDmj7xzFRfkGhkZKsrK8+Gi5oLZqoLV0hRcgj1c3LWzjxZ7n9HB6YMQxuTaUiFir3Q 9d9lJD5hy4Bf5X5cRsHJPOYZIQA37wtfinzeSPpX79//nW8SIgTvd+fOXOJi0Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1761500173; a=rsa-sha256; cv=none; b=Wy+Ig5I17Wo0Fa1Gw7fot4bDd4OmKmSbiaoMisBh3ji1+kYZrXAwzdPXxgJbhVCxG/UMvt SsvPxkpaqSueAzF6P6Q6mVmQyHvAE6asNK3eLYG/GnTl4MA5unOwywjwjqTRLDjoY72tM9 ZAeQM/flbZYRb+mMNh6ZdwpFJPCpEGspQKrPE3WRb2KtSiUzJ3pzZ54zgXkG2kmLRS3Hmx s7WzJlUOVkSafvNj2PAXiBWKnOBtmw4qT47SFRwG3xip3bEJ/FCgCC4GcE8P8zHzHErD3+ bUKtCnYD+aYUocY/WODT5InWG6iRmnPI8e2UT4ENiyQgFMzCCtyBgVfuV3Yvvg== 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 4cvkMK46g6zjwX; Sun, 26 Oct 2025 17:36:13 +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 59QHaDxS079516; Sun, 26 Oct 2025 17:36:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59QHaDik079513; Sun, 26 Oct 2025 17:36:13 GMT (envelope-from git) Date: Sun, 26 Oct 2025 17:36:13 GMT Message-Id: <202510261736.59QHaDik079513@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 1c8d7bb4cf7a - main - 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/main X-Git-Reftype: branch X-Git-Commit: 1c8d7bb4cf7a6b19262333b2a9b1dacf3094b938 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=1c8d7bb4cf7a6b19262333b2a9b1dacf3094b938 commit 1c8d7bb4cf7a6b19262333b2a9b1dacf3094b938 Author: Konstantin Belousov AuthorDate: 2025-10-26 14:57:16 +0000 Commit: Konstantin Belousov CommitDate: 2025-10-26 17:35:31 +0000 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 --- lib/libsys/write.2 | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/libsys/write.2 b/lib/libsys/write.2 index d2ff41ceead9..77067893ab4c 100644 --- a/lib/libsys/write.2 +++ b/lib/libsys/write.2 @@ -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.