Module Name: src Committed By: christos Date: Sun Sep 15 20:53:24 UTC 2019
Modified Files: src/lib/libc/sys: open.2 Log Message: Document O_EXEC, and add some extra explanation for O_CREAT from FreeBSD. To generate a diff of this commit: cvs rdiff -u -r1.60 -r1.61 src/lib/libc/sys/open.2 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/sys/open.2 diff -u src/lib/libc/sys/open.2:1.60 src/lib/libc/sys/open.2:1.61 --- src/lib/libc/sys/open.2:1.60 Sun Sep 1 19:57:14 2019 +++ src/lib/libc/sys/open.2 Sun Sep 15 16:53:24 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: open.2,v 1.60 2019/09/01 23:57:14 sevan Exp $ +.\" $NetBSD: open.2,v 1.61 2019/09/15 20:53:24 christos Exp $ .\" .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,13 +29,13 @@ .\" .\" @(#)open.2 8.2 (Berkeley) 11/16/93 .\" -.Dd September 2, 2019 +.Dd September 16, 2019 .Dt OPEN 2 .Os .Sh NAME .Nm open , .Nm openat -.Nd open or create a file for reading or writing +.Nd open or create a file for reading, writing or executing .Sh LIBRARY .Lb libc .Sh SYNOPSIS @@ -48,15 +48,34 @@ The file name specified by .Fa path is opened -for reading and/or writing as specified by the +for either execution or reading and/or writing as specified by the argument .Fa flags and the file descriptor returned to the calling process. +The +.Fa flags +argument may indicate the file is to be +created if it does not exist (by specifying the +.Dv O_CREAT +flag). +In this case +.Fn open +and +.Fn openat +require an additional argument +.Fa "mode_t mode" , +and the file is created with mode +.Fa mode +as described in +.Xr chmod 2 +and modified by the process' umask value (see +.Xr umask 2 ) . .Pp +The .Fn openat -works the same way as +function is equivalent to the .Fn open -except if +function except in the case where the .Fa path is relative. In that case, it is looked up from a directory whose file @@ -91,6 +110,8 @@ Applications must specify exactly one of Open for reading only. .It Dv O_WRONLY Open for writing only. +.It Dv O_EXEC +Open for execute only. .It Dv O_RDWR Open for reading and writing. .El @@ -412,6 +433,14 @@ In addition, .Fn openat will fail if: .Bl -tag -width Er +.It Bq Er EINVAL +An attempt was made to open a descriptor with an illegal combination +of +.Dv O_RDONLY , +.Dv O_WRONLY , +.Dv O_RDWR +and +.Dv O_EXEC . .It Bq Er EBADF .Fa path does not specify an absolute path and