Changeset View
Changeset View
Standalone View
Standalone View
lib/libc/sys/open.2
Show All 22 Lines | |||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
.\" SUCH DAMAGE. | .\" SUCH DAMAGE. | ||||
.\" | .\" | ||||
.\" @(#)open.2 8.2 (Berkeley) 11/16/93 | .\" @(#)open.2 8.2 (Berkeley) 11/16/93 | ||||
.\" $FreeBSD$ | .\" $FreeBSD$ | ||||
.\" | .\" | ||||
.Dd December 1, 2017 | .Dd October 20, 2018 | ||||
.Dt OPEN 2 | .Dt OPEN 2 | ||||
.Os | .Os | ||||
.Sh NAME | .Sh NAME | ||||
.Nm open , openat | .Nm open , openat | ||||
.Nd open or create a file for reading, writing or executing | .Nd open or create a file for reading, writing or executing | ||||
.Sh LIBRARY | .Sh LIBRARY | ||||
.Lb libc | .Lb libc | ||||
.Sh SYNOPSIS | .Sh SYNOPSIS | ||||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | |||||
O_FSYNC synchronous writes | O_FSYNC synchronous writes | ||||
O_SYNC synchronous writes | O_SYNC synchronous writes | ||||
O_NOFOLLOW do not follow symlinks | O_NOFOLLOW do not follow symlinks | ||||
O_NOCTTY ignored | O_NOCTTY ignored | ||||
O_TTY_INIT ignored | O_TTY_INIT ignored | ||||
O_DIRECTORY error if file is not a directory | O_DIRECTORY error if file is not a directory | ||||
O_CLOEXEC set FD_CLOEXEC upon open | O_CLOEXEC set FD_CLOEXEC upon open | ||||
O_VERIFY verify the contents of the file | O_VERIFY verify the contents of the file | ||||
O_BENEATH fails if outside current directory or its children | |||||
jonathan: maybe "require path to be strictly relative to starting directory"? | |||||
.Ed | .Ed | ||||
.Pp | .Pp | ||||
Opening a file with | Opening a file with | ||||
.Dv O_APPEND | .Dv O_APPEND | ||||
set causes each write on the file | set causes each write on the file | ||||
to be appended to the end. | to be appended to the end. | ||||
If | If | ||||
.Dv O_TRUNC | .Dv O_TRUNC | ||||
▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | |||||
may be used to indicate to the kernel that the contents of the file should | may be used to indicate to the kernel that the contents of the file should | ||||
be verified before allowing the open to proceed. | be verified before allowing the open to proceed. | ||||
The details of what | The details of what | ||||
.Dq verified | .Dq verified | ||||
means is implementation specific. | means is implementation specific. | ||||
The run-time linker (rtld) uses this flag to ensure shared objects have | The run-time linker (rtld) uses this flag to ensure shared objects have | ||||
been verified before operating on them. | been verified before operating on them. | ||||
.Pp | .Pp | ||||
.Dv O_BENEATH | |||||
Not Done Inline ActionsWorded slightly better: .Dv O_BENEATH allanjude: Worded slightly better:
.Dv O_BENEATH
returns
.Er ENOTCAPABLE
if the specified path, after… | |||||
returns | |||||
.Er ENOTCAPABLE | |||||
if the specified path, after resolving all symlinks and ".." references | |||||
in it, does not reside in the directory hierarchy of children beneath | |||||
the starting directory, or is an absolute path. | |||||
Starting directory is the process current directory if relative | |||||
.Fa path | |||||
is used for | |||||
.Fn open , | |||||
and the directory referenced by the | |||||
.Fa fd | |||||
argument when specifying relative | |||||
.Fa path | |||||
for | |||||
.Fn openat . | |||||
.Pp | |||||
If successful, | If successful, | ||||
.Fn open | .Fn open | ||||
returns a non-negative integer, termed a file descriptor. | returns a non-negative integer, termed a file descriptor. | ||||
It returns \-1 on failure. | It returns \-1 on failure. | ||||
The file pointer used to mark the current position within the | The file pointer used to mark the current position within the | ||||
file is set to the beginning of the file. | file is set to the beginning of the file. | ||||
.Pp | .Pp | ||||
If a sleeping open of a device node from | If a sleeping open of a device node from | ||||
▲ Show 20 Lines • Show All 202 Lines • ▼ Show 20 Lines | |||||
.It Bq Er ECAPMODE | .It Bq Er ECAPMODE | ||||
.Dv AT_FDCWD | .Dv AT_FDCWD | ||||
is specified and the process is in capability mode. | is specified and the process is in capability mode. | ||||
.It Bq Er ECAPMODE | .It Bq Er ECAPMODE | ||||
.Fn open | .Fn open | ||||
was called and the process is in capability mode. | was called and the process is in capability mode. | ||||
.It Bq Er ENOTCAPABLE | .It Bq Er ENOTCAPABLE | ||||
.Fa path | .Fa path | ||||
is an absolute path or contained a ".." component leading to a | is an absolute path, | ||||
or contained a ".." component leading to a | |||||
directory outside of the directory hierarchy specified by | directory outside of the directory hierarchy specified by | ||||
.Fa fd . | .Fa fd , | ||||
and the process is in capability mode or the | |||||
.Dv O_BENEATH | |||||
flag was provided. | |||||
.El | .El | ||||
.Sh SEE ALSO | .Sh SEE ALSO | ||||
.Xr chmod 2 , | .Xr chmod 2 , | ||||
.Xr close 2 , | .Xr close 2 , | ||||
.Xr dup 2 , | .Xr dup 2 , | ||||
.Xr fexecve 2 , | .Xr fexecve 2 , | ||||
.Xr fhopen 2 , | .Xr fhopen 2 , | ||||
.Xr getdtablesize 2 , | .Xr getdtablesize 2 , | ||||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |
maybe "require path to be strictly relative to starting directory"?