HP-UX Reference (11i v1 00/12) - 2 System Calls (vol 5)

__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man2/!!!intro.2
________________________________________________________________
___ ___
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 translatingthe 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.
[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 either does not exist, or the driver for this device has not been
configured into the kernel.
[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.
int infd;
infd = open ("inputfile", O_RDONLY);
HP-UX Release 11i: December 2000 3 Section 2203
___
___