Open System Services System Calls Reference Manual (G06.25+, H06.03+)
System Functions (n - p) open(2)
DESCRIPTION
The open() function establishes a connection between the file indicated by the path parameter
and the returned file descriptor. The opened file descriptor is used by subsequent I/O functions,
such as read() and write(), to access that file.
The returned file descriptor is the lowest-numbered file descriptor not previously open for that
process. A corresponding Guardian environment file number is also assigned.
The file offset, marking the current position within the file, is set to the beginning of the file. The
new file descriptor is set to remain open across the processing of any of the exec or tdm_exec set
of functions. (See the fcntl(2) reference page.)
The file status flags and file access flags are designated by the oflag parameter. The oflag parame-
ter is constructed by a bitwise-inclusive-OR of exactly one of the
file access flags (O_RDONLY,
O_WRONLY,orO_RDWR) with one or more of the file status flags.
The open() function cannot be used to create a FIFO special file. Use the mkfifo() function for
that purpose.
File Access Flags
The file access flags are:
O_RDONLY The file is open only for reading.
O_WRONLY The file is open only for writing.
O_RDWR The file is open for reading and writing.
Exactly one of the file access flags must be specified.
File Status Flags
The file status flags that specify special open processing are:
O_CREAT Create and open the file. If the file exists, this flag has no effect except as noted
under the O_EXCL flag. If the file does not exist, a regular file is created with
these characteristics:
• The owner ID of the file is set to the effective user ID of the process.
• The group ID of the file is determined by the value of the S_ISGID flag
in the parent directory. If S_ISGID is set, the group ID of the file is set to
the group ID of the parent directory; otherwise, the group ID of the file is
set to the effective group ID of the calling process. If the file is a Guar-
dian file (that is, within /G), the group ID is set to that of the primary
group of the effective user ID.
• The file permission and attribute bits are set to the value of the mode
parameter, modified as listed:
— All bits set in the process file mode creation mask are cleared.
— The set user ID attribute (S_ISUID bit) is cleared.
— The set group ID attribute (S_ISGID bit) is cleared.
If bits other than the file permission and appropriate file-type bits are set
in the mode parameter, errno is set to [EINVAL].
527186-003 Hewlett-Packard Company 5−5