INtime SDK Help

Opens a file for shared reading or writing.

#include <fcntl.h>
#include <share.h>
#include <sys/stat.h>
#include <io.h>

int sopen (const char *filename, int oflag, int shflag, int pmode);


Filename to open.
Type of operations allowed (open mode). Combine one or more of the manifest constants described in open with the bitwise-OR operator (|).
Type of sharing allowed (share mode).
Permission mode, which specifies the file's ownership and access rights; required only when O_CREAT is specified. Otherwise, argument is ignored. The manifest constants are described in chmod. Join them with the bitwise-OR operator (|).


shflag must be one of these manifest constants:

Value Description
SH_DENYRW Denies read and write access to file.
SH_DENYWR Denies write access to file.
SH_DENYRD Denies read access to file.
SH_DENYNO Permits read and write access.

Ownership and access rights are set when the new file is closed for the first time.

sopen applies the default file-permission mask (set with umask) to pmode before set ting the permissions.

This function performs a translation of POSIX file ownership rights and POSIX access rights to the real-time OS equivalent as described in chmod.

Return Values

A descriptor for the opened file.
-1; and the function sets errno to one of these values:
EACCES Given pathname is a directory; or
The file is read-only but an open for writing was attempted; or
A sharing violation occurred because the file's share mode does not allow the specified operations.
EEXIST The O_CREAT and O_EXCL flags are specified, but the named file already exists.
EINVAL An invalid oflag or shflag argument was given.
EMFILE No more file descriptors available (too many open files).
ENOENT File or pathname not found.


Versions Defined in Include Link to
INtime 3.0 intime/rt/include/io.h fcntl.h

See Also

chmod, close, creat, umask