nwsopen

Opens a file or stream for shared access.

Library:LibC
Classification:Novell
Service:File and Directory I/O

Syntax

  #include <fsio.h> 
   
  int nwsopen (
     const char   *path,
     int           oflag,
     int           shflag,
     int           nwflags,
     ...);
  

Parameters

path

(IN) Points to the path and name of the file to open.

oflag

(IN) Specifies the open access mode. See File Control Open Modes.

shflag

(IN) Specifies the share mode for the file and uses one of the following:

Flag

Value

Description

SH_DENYRW

0x00000010

Deny read and write mode

SH_DENYWR

0x00000020

Deny write mode

SH_DENYRD

0x00000030

Deny read mode

SH_DENYNO

0x00000040

Deny none mode, which allows read and write access to the file

nwflags

(IN) Specifies flags which modify I/O behavior:

Flag

Value

Description

M_A_FILE_WRITE_THROUGH_BIT

0x00000040

Prevents file I/O from being buffered and causes it to be written immediately to disk.

M_A_ENABLE_IO_ON_COMPRESSED_DATA_BIT

0x00000100

Allows I/O on a compressed file. The file must be opened in exclusive mode.

This flag should be used in conjunction with the M_A_LEAVE_FILE_ COMPRESSED_DATA_BIT flag.

M_A_LEAVE_FILE_COMPRESSED_DATA_BIT

0x00000200

Opens a file without compressing the file. The file must be opened in exclusive mode.

This flag should be used in conjunction with the M_A_ENABLE_IO_ON_ COMPRESSED_DATA_BIT flag.

M_A_DELETE_FILE_ON_CLOSE_ BIT

0x00000400

Causes the file to be deleted when it is closed.

M_A_NO_RIGHTS_CHECK_ON_ OPEN_BIT

0x00010000

Allows the file to be opened without any rights checking. This is used mainly by backup and virus scanning software.

M_A_OK_TO_OPEN_DOS_FILE

0x80000000

 

...

(IN) Specifies an optional mode argument when the O_CREAT flag is specified in oflag. See File Access Modes and NetWare Attributes.

Return Values

If successful, returns a file descriptor, which is a non-negative integer. If an error occurs, returns -1 and sets errno to one of the following values:

Decimal

Constant

Description

1

ENONENT

No such file. O_CREAT is not set and the named file does not exist; or O_CREAT is set and either the path prefix does not exist or the path argument points to an empty string.

5

ENOMEM

The system is unable to allocate resources.

6

EACCES

Permission denied.

7

EEXIST

The named file exists and O_CREAT and O_EXCL are set.

9

EINVAL

Invalid parameter.

10

ENFILE

The maximum allowable number of files is currently open in the system.

11

EMFILE

The maximum number of files are currently open.

12

ENOSPC

There is no space left on the device to create the file.

25

ENXIO

The device does not exist.

28

EIO

A physical I/O error occurred.

63

EINTR

A signal was caught during the execution of the function.

64

EISDIR

The specified file is a directory and oflag includes O_WRONLY or O_RDWR.

65

ENAMETOOLONG

The length of the path parameter exceeds the maximum allowed length, or a component of the path parameter is longer than the maximum name length.

67

ENOTDIR

A component specified in the path parameter is not a directory.

76

EROFS

The named file resides on a read-only file system.

81

EOVERFLOW

The operation would overflow.

Remarks

The nwsopen function returns a file descriptor that refers to the file. The path parameter supplies the name of the file to open. The file is accessed according to the access mode specified by the oflag parameter.

If the O_CREAT flag is set in the oflag parameter, the shflag parameter is ignored and the fifth parameter is a mode parameter of type mode_t. For the flags to use with this parameter, see File Access Modes and NetWare Attributes.

You pass the returned file descriptor to other POSIX functions to perform operations on the file, such as reading and writing.

See Also