Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Feb 2025 10:29:30 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 8cebb0630046 - main - open.2: add separate paragraph for O_CREAT
Message-ID:  <202502281029.51SATUA7083201@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=8cebb0630046a8eb10c551a856397ed230e73833

commit 8cebb0630046a8eb10c551a856397ed230e73833
Author:     artembunichev <artembunichev@zohomail.com>
AuthorDate: 2025-02-27 14:21:20 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202502281029.51SATUA7083201>