The branch stable/14 has been updated by kib:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=3416ed9d077f75b314eb98a2cb1d6fd8273cce13

commit 3416ed9d077f75b314eb98a2cb1d6fd8273cce13
Author:     artembunichev <artembunic...@zohomail.com>
AuthorDate: 2025-02-27 14:21:20 +0000
Commit:     Konstantin Belousov <k...@freebsd.org>
CommitDate: 2025-03-07 05:23:08 +0000

    open.2: add separate paragraph for O_CREAT
    
    PR:     284353
    
    (cherry picked from commit 8cebb0630046a8eb10c551a856397ed230e73833)
---
 lib/libc/sys/open.2 | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/lib/libc/sys/open.2 b/lib/libc/sys/open.2
index ea4bc9160da1..e29abbb70342 100644
--- a/lib/libc/sys/open.2
+++ b/lib/libc/sys/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.

Reply via email to