Changeset View
Changeset View
Standalone View
Standalone View
lib/libc/sys/open.2
Show First 20 Lines • Show All 136 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. | |||||
Starting directory is the process root directory for absolute path, | |||||
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 205 Lines • ▼ Show 20 Lines | |||||
.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 . | ||||
.It Bq Er ENOTCAPABLE | |||||
.Fa path | |||||
contained a ".." component leading to a directory outside of the directory | |||||
hierarchy specified by the start directory. | |||||
.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"?