From nobody Fri Feb 28 10:29:30 2025 X-Original-To: dev-commits-src-main@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 4Z44Fk64Yxz59W0C; Fri, 28 Feb 2025 10:29:30 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Z44Fk5PMGz3vR0; Fri, 28 Feb 2025 10:29:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1740738570; 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=PxD+Ubpe3rNzUscujBl1eqsUMpH0tAKoKl+TCai6JXE=; b=yRNkv/n+xf/bBkvsphBOjkXetK+JGT3frFBBnlDSXjH4BYC3kDNhc7ywep9wFeiY1Yoe+n 33xpQxu81Q/1YrntlfyvZpy0cBVcZOEvL9s0GB3OLc96Txry3cvPmorG8aTwV9cpBHchcg WtmfF/WKYx3OkDEfy7EIhQoaUr8GSaHVKtafVYQG8Z3iSJYsjBuCd6gMYkVCEipA5fo1pb d9hADe8kaRRK7PykZT90yaAscsz0jCBrw0PXJH9zpy1qQrZItFF89ekncpEUP7Atm1V09s MegQKl+3w955f11OZ/LYEi027HSrqk9vhtE25+Uhpdy51m38hQLUbVRcc89kdA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1740738570; a=rsa-sha256; cv=none; b=CHSqgEugCK1yq/xzT7oT1AdfejiiYr/xvQ2nyXiOrV0Eqa9+kK3YFyOUVicMmDViwRFz8W fKL4Uu6sNhupvNCrfJqfFNg85QsUAmyG9Ezz5BN9MBMAT3xgVlFpZltN4ZBHu6u6/NCrS1 prLUpxZ5DlhlxlUjf94Evnkanal2LK2MH9DIgn//4TXUL7n+n4a1ZLv+f7h9Jc+SqHlNk3 MG0BtwxVUbQbQZeKU5M6b7QNwyotz5XXanXkUmFotAOGG1G292D5MidAGI4sQqb9LjtzBD gS2A3/R9eZ0asiND8jtiFR4bu593emBivT5D6rDRe9M7uYeHxFemZiPaxhDPrg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1740738570; 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=PxD+Ubpe3rNzUscujBl1eqsUMpH0tAKoKl+TCai6JXE=; b=V/oHvSvSuZD4/xCHbD7pSSLLqhaz1ptuQjmLY+xtddJ3pKeiZnze9q1PBBVp9pgI4/Vpir Y/2WI6jD0dKuPXHAtC8JCuhsC2Lwy2Z7Rt+kIrbW6K76j1Yj5Wzbm/jerm9F8PInVci1l0 4a91RfAjqsX1OuYY7JLp8uhjsd0gpntmC6fk/GdjnyfToJko7T+gM8XBHn/Jl6CXyP/hsV 4mZkNsX4L3TmKDG5WiahlQ4zE0O2JtwOGMRaiO7+2sgc0BTlQ+Hajyj7D5sHWAGEkOQmuw 2SW5naO5nQ7dwJmgN9jbcCuEeR/D+WA0zLAkyQpw82GgonEmsDZSRFTts1EuxQ== 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 4Z44Fk4zspz8Wf; Fri, 28 Feb 2025 10:29:30 +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 51SATUgF083204; Fri, 28 Feb 2025 10:29:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 51SATUA7083201; Fri, 28 Feb 2025 10:29:30 GMT (envelope-from git) Date: Fri, 28 Feb 2025 10:29:30 GMT Message-Id: <202502281029.51SATUA7083201@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: 8cebb0630046 - main - open.2: add separate paragraph for O_CREAT List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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: 8cebb0630046a8eb10c551a856397ed230e73833 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=8cebb0630046a8eb10c551a856397ed230e73833 commit 8cebb0630046a8eb10c551a856397ed230e73833 Author: artembunichev AuthorDate: 2025-02-27 14:21:20 +0000 Commit: Konstantin Belousov CommitDate: 2025-02-28 10:29:12 +0000 open.2: add separate paragraph for O_CREAT PR: 284353 MFC after: 1 week --- lib/libsys/open.2 | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/lib/libsys/open.2 b/lib/libsys/open.2 index 9ad5440bf239..699446b6c7c2 100644 --- a/lib/libsys/open.2 +++ b/lib/libsys/open.2 @@ -231,16 +231,36 @@ is specified and the file exists, the file is truncated to zero length. .Pp If -.Dv O_EXCL -is set with .Dv O_CREAT -and the file already -exists, +is set, but file already exists, +this flag has no effect except when +.Dv O_EXCL +is set too, in this case .Fn open fails with .Er EEXIST . This may be used to implement a simple exclusive access locking mechanism. +In all other cases, the file is created +and the access permission bits (see +.Xr chmod 2) +of the file mode +are set to the value of the third argument taken as +.Fa "mode_t mode" +and passed through the +.Xr umask 2 . +This argument does not affect whether the file is opened +for reading, writing, or for both. +The open' request for a lock on the file, created with +.Dv O_CREAT , +will never fail +(provided that the underlying file system supports locking; +see also +.Dv O_SHLOCK +and +.Dv O_EXLOCK +below). +.Pp If .Dv O_EXCL is set and the last component of the pathname is @@ -289,10 +309,6 @@ semantics can be obtained by setting for a shared lock, or .Dv O_EXLOCK for an exclusive lock. -If creating a file with -.Dv O_CREAT , -the request for the lock will never fail -(provided that the underlying file system supports locking). .Pp .Dv O_DIRECT may be used to minimize or eliminate the cache effects of reading and writing.