OPEN(2) Linux Programmer's Manual OPEN(2)
NAME
open, openat - open and possibly create a file or directory
SYNOPSIS
#include <fcntl.h>
int open(const char *pathname, int flags, ... /* mode_t mode */);
int openat(int dirfd, const char *pathname, int flags, ...);
DESCRIPTION
The open() system call opens the file indicated by pathname and
returns a file descriptor that refers to that open file. The file
descriptor returned by a successful call will be the lowestâ
numbered file descriptor not currently open for the process.
RETURN VALUE
On success, open(), openat(), and creat() return the new file
descriptor (a nonnegative integer). On error, -1 is returned,
and errno is set to indicate the error.
ERRORS
EACCES The requested access to the file is not allowed, or
search permission is denied for one of the directories
in the path prefix of pathname, or the file did not exist yet
and write access to the parent directory is not allowed.
SEE ALSO
close(2), creat(2), fcntl(2), link(2), mkdir(2), mknod(2), mount(2),
openat(2), read(2), rename(2), stat(2), unlink(2), fopen(3)
COLOPHON
This page is part of release 5.13 of the Linux man-pages project.