14.2 Direct File System Tasks

This documentation describes common tasks associated with Direct File System:

14.2.1 Creating a File

You can create files by calling dfs_creat. This creates a file on the specified volume with the permissions indicated, and leaves the file open in direct file mode. The file must later be closed with dfs_close). The dfs_create function is the DFS equivalent of creat.

You can also create files by calling dfs_sopen. The dfs_sopen function is the DFS equivalent of sopen.

14.2.2 Extending Files Using Allocation

To extend a file using default file allocation:

  1. Determine if space is available.

    Call dfs_getvolmapinfo to obtain the volume size, allocation unit size, sector size, number of free blocks, number of blocks available in deleted files, number of blocks not available in deleted files, and so forth. If the desired number of blocks is not available on the volume, skip to Step 4.

    Since the OS is multitasking, it is possible (and likely) that other processes allocate (and free) volume blocks at any time, making information returned by dfs_getvolmapinfo obsolete. As a result you must design a DFS application to repeat this procedure multiple times to deal with the failure of dfs_extend and dfs_freelimbospace.

  2. Determine the current allocation of the file, specifically the file block where the file is to be extended.

    Call dfs_getfilemapinfo to determine the file’s current mapping, including volume segments and blocks allocated. The starting file block to be extended must be specified in the extend request made in Step 3.

    A file might not be extended by specifying file block addresses that already exist. This means that an extend request to allocate file space for a hole in a sparse file must not specify a number of contiguous blocks that exceed the size of the hole.

  3. Allocate blocks to expand the file.

    Call dfs_extend specifying the number of blocks to be extended and wildcards (-1) for the volume block number and optionally for the volume segment number. This allows DFS to select the range of contiguous blocks used to extend the file.

    For normal files, extending a file a single block at a time and specifying wildcards for both the volume block address and the volume segment is identical in function to letting the NetWare® OS allocate for normal files.

    Specifying a wildcard segment number in conjunction with a wildcard volume block address allows the OS to alternate its selection of volume segments for file allocation, thus facilitating file striping on systems where it is advantageous to stripe files. Specifying a larger number of blocks with a wildcard volume segment stripes the file (provided that multiple volume segments exist) with the larger granularity. If there is not enough contiguous available space to expand the file by the requested number of blocks, applications might be required to make several calls specifying smaller request sizes, or fail the request.

    If the return code indicates that the above operation was not successful, proceed to Step 4. Otherwise, the file has been extended as requested.

  4. Free up volume space.

    Call dfs_freelimbospace specifying the volume number and the requested number of blocks to be freed. This causes one or more deleted files to be purged from the volume in order of time of deletion. Go to Step 1.

14.2.3 Extending Files Using Specific Allocation

To extend a file by selecting the volume segments and/or blocks to be allocated:

  1. Determine if space is available.

    Call dfs_getvolmapinfo to obtain the volume size, allocation unit size, sector size, number of free blocks, number of blocks available in deleted files, number of blocks not available in deleted files, and so forth. If adequate space for the file extension is not available, go to Step 5.

    Since the OS is multitasking, it is possible (and likely) that other processes allocate (and free) volume blocks at any time, making information returned by dfs_getvolmapinfo obsolete. As a result you must design a DFS application to repeat this procedure multiple times to deal with the failure of dfs_extend and dfs_freelimbospace.

  2. Determine the current allocation for the file.

    Call dfs_getfilemapinfo to determine the file’s current mapping, including volume segments and blocks allocated. This information is required to determine where to extend a file.

    A file may not be extended by specifying file block addresses which already exist. This means that an extend request to allocate file space for a hole in a sparse file must not specify a number of contiguous blocks which exceed the size of the hole.

  3. Determine the available blocks on a volume.

    Call dfs_getvolblockinfo to obtain a bit map of available blocks on the desired volume. Determine from the bitmap a contiguous range of blocks large enough to extend the file as needed.

    As a result of multitasking, the bitmap of available blocks is valid only at the moment it is obtained, and may have changed by the time an application requests a specific range of blocks to be allocated for a file (possibly requiring this step to be repeated multiple times).

  4. Extend the file.

    Call dfs_extend to specify the range of contiguous available blocks selected from the preceding bitmap. Specifying more than a single block causes the requested contiguous blocks to be allocated from the same volume segment. A good return code indicates that the requested function is completed.

    If enough contiguous space to expand the file the requested number of blocks is not available, applications might be required to make several calls specifying smaller request sizes, or fail the request.

    If the return code indicates that the above operation was not successful, proceed to Step 5. Some other module may have allocated the requested blocks, so the calling application must be prepared to retry the operation several times.

  5. Free up volume space.

    Call dfs_freelimbospace to specify the volume number and the requested number of blocks to be freed. This causes one or more deleted files to be purged from the volume in the order of the time of deletion. Go back to Step 1.