dfs_creat

Creates and opens a file in Direct File Mode, returning a file handle to the called file.

Library:LibC
Classification:Novell
Service:Direct File System

Syntax

  #include <dfs.h>  
   
  int dfs_creat (
     const char   *path,
     mode_t        mode,
     int           shflag,
     int          *err ); 
  

Parameters

path

(IN) Points to the name of the file to be created. The filename must be NULL-terminated and must include the path, including the volume name but not the server name.

mode

(IN) Specifies the access permissions for the file. For possible values, 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

err

(OUT) Points to an error code value, if dfs_creat returns -1.

Return Values

If successful, returns a file descriptor, which is a non-negative integer, and opens the file. Otherwise, returns -1 and sets the err parameter 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 does not exist or the path argument points to an empty string.

4

EBADF

Invalid path.

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.

79

ENOTSUP

The NLM is loaded in protected address space. This operation is supported only in kernel address space.

81

EOVERFLOW

The operation would overflow.

106

ENOCONTEXT

The current thread has not context.

Remarks

Calling dfs_creat causes DFS to create a file, or to truncate the file if it already exists. The name of the file to be created is given by the path parameter. If the file exists, it is truncated to contain no data. The file is switched to direct mode, forcing subsequent file accesses to be direct. The file must be extended using dfs_extend to provide required file space. The file is left open and must be closed by a subsequent call to dfs_close.

Not all functions are allowed with this form of open once the file has been created. If additional functions such as specifying a stream are required, the caller should close the file and open it again by calling dfs_sopen.

See Also