Open for shared access a file associated with a given descriptor
#include <unistd.h> int sopenfd( int fd, int oflag, int sflag );
- A file descriptor associated with the file that you want to open.
- How you want to open the file; a combination of the following bits:
- O_RDONLY — permit the file to be only read.
- O_WRONLY — permit the file to be only written.
- O_RDWR — permit the file to be both read and written.
- O_APPEND — cause each record that's written to be written at the end of the file.
- O_TRUNC — if the file exists, truncate it to contain no data. This flag has no effect if the file doesn't exist.
- How you want the file to be shared; a combination of the following bits:
- SH_COMPAT — set compatibility mode.
- SH_DENYRW — prevent read or write access to the file.
- SH_DENYWR — prevent write access to the file.
- SH_DENYRD — prevent read access to the file.
- SH_DENYNO — permit both read and write access to the file.
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The sopenfd() function opens for shared access the file associated with the file descriptor, fd. The access mode, oflag, must be equal to or more restrictive than the access mode of the source fd.
openfd( fd, oflag );
is the same as:
sopenfd( fd, oflag, SH_DENYNO );
The file descriptor, or -1 if an error occurs ( errno is set).
- Invalid file descriptor fd.
- The access mode specified by oflag isn't equal to or more restrictive than the access mode of the source fd.
- Sharing mode (sflag) was denied due to a conflicting open.
Last modified: 2014-06-24