Guardian C Library Calls Reference Manual

open (supplementary)
3-138 128833Guardian TNS C Library Calls Reference Manual
Reference to Library Calls
Usage Guidelines
The following macros specify the possible attributes for flags. Select the attributes
that represent attributes of the file to be opened. To specify more than one option,
use the bit-wise OR operator (|).
In a C-series system, the open function opens a file with the default exclusion mode
PROTECTED ACCESS, if the flags O_SHARED and O_EXCLUSIVE are not
specified in the call. In the D-series system, the default exclusion mode is
EXCLUSIVE ACCESS.
To work around this C-series and D-series discrepancy, if you want to open a file
with the exclusion mode PROTECTED ACCESS, modify existing C programs to
specify the O_PROTECTED flag in the open function
The open function ignores security, pext, and sext for files that already exist.
If you open a file that is neither an Edit file nor a terminal and you don’t specify
O_TEXT, then open opens the file for binary access.
Macro Description
O_APPEND Sets the file-position indicator to the end of the file before each write.
O_BINARY Opens the file for binary I/O.
O_CREAT Creates the file if it does not exist.
O_EXCL Causes open to fail if the file already exists; it must be used in
conjunction with O_CREAT.
O_EXCLUSIVE Indicates that the opening process cannot allow any simultaneous
access of any kind to the file. Therefore, any further attempts to open
the file, while the file is open, are rejected. Likewise, if a file is
already open, any attempt to open the file with exclusive access is
rejected.
O_PROTECTED Indicates that the opening process can allow simultaneous read access
to the file but cannot allow simultaneous write access to the file.
Therefore, while the file is opened with protected access, any further
attempts to open the file with read-write or write-only access mode
are rejected. Likewise, if the file is already open with read-write or
write-only access mode, any attempt to open it with protected access
is rejected. However, simultaneous accessors can open a file with
read-only access mode.
O_RDONLY Opens the file for read-only access.
O_RDWR Opens the file for read-write access.
O_SHARED Indicates that the opening process can allow simultaneous read and/or
write access by other processes to the file.
O_SYSMSG For internal library use only.
O_TEXT Opens the file for text I/O.
O_TRUNC Truncates the file to a length of zero if the file exists.
O_WRONLY Opens the file for write-only access.