c_dkcre - Creates and allocates a disk file

SYNTAX

#include      "las.h"
#include      "diskio.h"
int c_dkcre (directories, filename, filesize, wait)

     char                directories[][CMLEN];
     char               *filename;
     long long           filesize;
     int                 wait;

PARAMETERS

directories (input, character, length(CMLEN))

List of pathnames for directories to be searched for available space.

filename (input, character, length(CMLEN))

Pathname of the file to be created.

filesize (input long long)

Size, in bytes, of the file to be created.

wait (input integer)

Number of seconds between retries in searching for available space. A value of zero indicates the calling function wants an immediate return status if the specified disk space is not available.

DESCRIPTION

If the specified filename already exists, c_dkcre() returns a status of DISK_EXISTS. c_dkcre() selects a directory on a best-fit basis. The amount of available space in the directories specified in directories is determined, and the directory with the minimum amount of free spae that satisfies the filesize request is selected. If a NULL value is passed for directories, the environment variable DATAPATH is interrogated and is assumed to be a list of colon-separated directories. If the DATAPATH environment variable does not exist, c_dkre() only looks in the current working directory for space. Filename is created in the directory selected.

If the directory selected is not the current working directory, filename.XXXXXX is created, where XXXXXX is replaced by a letter and the current process ID. Filename is created in the current working directory as a symbolic link to the actual file. After the best directory is selected, c_dkcre() allocates the file by writing filesize and filename to a disk reserve file. If there is not enough available spae in any of the directories and the calling function desires to wait for it, a message of the form "PID: 12345 username waiting for 1234567 bytes on /usr/production: /usr/production2" is displayed on the operator's console every wait seconds until the process is killed or enough disk space becomes available.

RETURN VALUE

c_dkcre() returns

     E_SUCC (0)        --> successful completion
     E_FAIL (-1)       --> failure status
     DISK_EXISTS (-2)  --> the specified file already exists
     DISK_NOSPACE (-4) --> the disk space specified was not available and 
                           the calling function did not want to wait for
                           it

SPECIAL CONSIDERATIONS

The caller must have write access to all specified directories.

A single file is not allowed to span multiple directories, file systems or disk drives.

The size of the disk file that can be created with this function is limited to the precision of a long long integer (i.e., 263 bytes) or the size of the file system, whichever is smaller.