HP-UX Reference (11i v1 05/09) - 2 System Calls (vol 5)
o
open(2) open(2)
n Successful completion. n is a file descriptor for the opened file.
-1 Failure.
errno is set to indicate the error.
ERRORS
If
open() fails, errno is set to one of the following values.
[EACCES] oflag permission is denied for the named file.
[EACCES] A component of the path prefix denies search permission.
[EACCES] The file does not exist and the directory in which the file is to be created does not per-
mit writing.
[EACCES] O_TRUNC is specified and write permission is denied.
[EAGAIN] The file exists, enforcement mode file/record locking is set (see chmod(2)), there are
outstanding record locks on the file with the
lockf() or fcntl() system calls, and
O_TRUNC is set.
[EDQUOT] User’s disk quota block or inode limit has been reached for this file system.
[EEXIST] O_CREAT and O_EXCL are set and the named file exists.
[EFAULT] path points outside the allocated address space of the process.
[EINTR] A signal was caught during the open() system call, and the system call was not res-
tarted (see signal(5) and sigvector (2)).
[EINVAL] oflag specifies both O_WRONLY and
O_RDWR.
[EISDIR] The named file is a directory and oflag is write or read/write.
[ELOOP] Too many symbolic links are encountered in translating the path name.
[EMFILE] The maximum number of file descriptors allowed are currently open.
[ENAMETOOLONG]
The length of the specified path name exceeds
PATH_MAX bytes, or the length of a
component of the path name exceeds NAME_MAX bytes while _POSIX_NO_TRUNC
is
in effect.
[ENFILE] The system file table is full.
[ENODEV] The named file is a character special or block special file, and the driver associated
with this special file has not been configured into the kernel or the DLKM driver asso-
ciated with this special file failed to load.
[ENOENT] The named file does not exist (for example, path is null or a component of path does
not exist, or the file itself does not exist and
O_CREAT is not set).
[ENOTDIR] A component of the path prefix is not a directory.
[ENXIO] O_NDELAY is set, the named file is a FIFO, O_WRONLY is set, and no process has the
file open for reading.
[ENXIO] The named file is a character special or block special file, and the device associated
with this special file does not exist.
[ENOSPC] O_CREAT is specified, the file does not already exist, and the directory that would
contain the file cannot be extended.
[EOVERFLOW]
The named file is a regular file and the size of the file cannot be represented correctly
in an object of size off_t.
[EROFS] The named file resides on a read-only file system and oflag is write or read/write.
[ETXTBSY] The file is open for execution and oflag is write or read/write. Normal executable files
are only open for a short time when they start execution. Other executable file types
can be kept open for a long time, or indefinitely under some circumstances.
EXAMPLES
The following call to open() opens file inputfile for reading only and returns a file descriptor for
inputfile. For an example of reading from file inputfile , see the read(2) manual entry.
HP-UX 11i Version 1: September 2005 − 3 − Hewlett-Packard Company Section 2−−209