Changeset View
Changeset View
Standalone View
Standalone View
head/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 April 2, 2015 | .Dd September 30, 2016 | ||||
.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 50 Lines • ▼ Show 20 Lines | |||||
is passed the special value | is passed the special value | ||||
.Dv AT_FDCWD | .Dv AT_FDCWD | ||||
in the | in the | ||||
.Fa fd | .Fa fd | ||||
parameter, the current working directory is used | parameter, the current working directory is used | ||||
and the behavior is identical to a call to | and the behavior is identical to a call to | ||||
.Fn open . | .Fn open . | ||||
.Pp | .Pp | ||||
In | |||||
.Xr capsicum 4 | |||||
capability mode, | |||||
.Fn open | |||||
is not permitted. | |||||
The | |||||
.Fa path | |||||
argument to | |||||
.Fn openat | |||||
must be strictly relative to a file descriptor | |||||
.Fa fd , | |||||
as defined in | |||||
.Pa sys/kern/vfs_lookup.c . | |||||
.Fa path | |||||
must not be an absolute path and must not contain ".." components. | |||||
Additionally, no symbolic link in | |||||
.Fa path | |||||
may contain ".." components either. | |||||
.Fa fd | |||||
must not be | |||||
.Dv AT_FDCWD . | |||||
.Pp | |||||
The flags specified are formed by | The flags specified are formed by | ||||
.Em or Ns 'ing | .Em or Ns 'ing | ||||
the following values | the following values | ||||
.Pp | .Pp | ||||
.Bd -literal -offset indent -compact | .Bd -literal -offset indent -compact | ||||
O_RDONLY open for reading only | O_RDONLY open for reading only | ||||
O_WRONLY open for writing only | O_WRONLY open for writing only | ||||
O_RDWR open for reading and writing | O_RDWR open for reading and writing | ||||
▲ Show 20 Lines • Show All 336 Lines • ▼ Show 20 Lines | |||||
argument is not an absolute path and | argument is not an absolute path and | ||||
.Fa fd | .Fa fd | ||||
is neither | is neither | ||||
.Dv AT_FDCWD | .Dv AT_FDCWD | ||||
nor a file descriptor associated with a directory. | nor a file descriptor associated with a directory. | ||||
.It Bq Er ENOTDIR | .It Bq Er ENOTDIR | ||||
.Dv O_DIRECTORY | .Dv O_DIRECTORY | ||||
is specified and the file is not a directory. | is specified and the file is not a directory. | ||||
.It Bq Er ECAPMODE | |||||
.Dv AT_FDCWD | |||||
is specified and the process is in capability mode. | |||||
.It Bq Er ECAPMODE | |||||
.Fn open | |||||
was called and the process is in capability mode. | |||||
.It Bq Er ENOTCAPABLE | |||||
.Fa path | |||||
is an absolute path or contained "..". | |||||
.El | .El | ||||
.Sh SEE ALSO | .Sh SEE ALSO | ||||
.Xr capsicum 4 , | |||||
.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 , | ||||
.Xr getfh 2 , | .Xr getfh 2 , | ||||
.Xr lgetfh 2 , | .Xr lgetfh 2 , | ||||
Show All 25 Lines |