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 le indicated by the path parameter
and the returned le descriptor. The opened le descriptor is used by subsequent I/O functions,
such as read() and write(), to access that le.
The returned le descriptor is the lowest-numbered le descriptor not previously open for that
process. A corresponding Guardian environment le number is also assigned.
The le offset, marking the current position within the le, is set to the beginning of the le. The
new le 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 le status ags and le access ags are designated by the oag parameter. The oag parame-
ter is constructed by a bitwise-inclusive-OR of exactly one of the
le access ags (O_RDONLY,
O_WRONLY,orO_RDWR) with one or more of the le status ags.
The open() function cannot be used to create a FIFO special le. Use the mkfo() function for
that purpose.
File Access Flags
The le access ags are:
O_RDONLY The le is open only for reading.
O_WRONLY The le is open only for writing.
O_RDWR The le is open for reading and writing.
Exactly one of the le access ags must be specied.
File Status Flags
The le status ags that specify special open processing are:
O_CREAT Create and open the le. If the le exists, this ag has no effect except as noted
under the O_EXCL ag. If the le does not exist, a regular le is created with
these characteristics:
The owner ID of the le is set to the effective user ID of the process.
The group ID of the le is determined by the value of the S_ISGID ag
in the parent directory. If S_ISGID is set, the group ID of the le is set to
the group ID of the parent directory; otherwise, the group ID of the le is
set to the effective group ID of the calling process. If the le is a Guar-
dian le (that is, within /G), the group ID is set to that of the primary
group of the effective user ID.
The le permission and attribute bits are set to the value of the mode
parameter, modied as listed:
All bits set in the process le 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 le permission and appropriate le-type bits are set
in the mode parameter, errno is set to [EINVAL].
527186-003 Hewlett-Packard Company 55