dfs_setlength

Sets the file size.

Library:LibC
Classification:Novell
Service:Direct File System

Syntax

  #include <dfs.h>  
   
  int dfs_setlength (
     int        fildes,
     size64_t   newSize,
     int        setSizeFlags ); 
  

Parameters

fildes

(IN) Specifies the handle returned from dfs_sopen or dfs_creat for the file on which to set the size.

newSize

(IN) Specifies the logical byte offset at which the new end of the file is to be set

setSizeFlags

(IN) Specifies a bit mask, indicating the ways in which the file can be expanded

Flag

Value

Description

DFS_SETSIZE_NON_ SPARSE_FILE

0x00000001

If a file is being expanded with this bit set, it is expanded in a nonsparse manner, and data is physically allocated to the file. Blocks in such added data are zero-filled unless SETSIZE_NO_ZERO_FILL is also set. If this bit is not set, the file is expanded in a sparse manner and no data is physically written to the file.

DFS_SETSIZE_NO_ZERO_ FILL

0x00000002

With this bit set, if a file is being expanded in a nonsparse manner, newly allocated disk blocks are not zero filled. The blocks are allocated to the file but not initialized. If this bit is not set, zero-filled data is physically written from the original end of the file to the new end.

This bit is allowed only from the NLM application running on the local server and cannot be set by an NCP operation.

DFS_SETSIZE_UNDO_ ON_ERR

0x00000004

If an error occurs during file expansion, an error is returned and the file is restored to its original size as though no expansion had taken place. If this bit is not set and an error occurs during expansion, the remaining expansion is aborted, and any partially completed expansion remains part of the file.

DFS_SETSIZE_PHYSICAL_ ONLY

0x00000008

Only the physical end of the file is changed. The logical end is untouched. File expansion with this bit set is done in a nonsparse manner as though SETSIZE_NON_SPARSE_FILE were set. Truncation is likewise only physical, with no change to the logical end of the file.

DFS_SETSIZE_LOGICAL_ ONLY

0x00000010

With this bit set, dfs_setlength changes only the logical end of the file. Allocated physical storage is neither expanded nor truncated, but remains unchanged.

Return Values

If successful, returns 0. Otherwise, returns a nonzero error code:

Decimal

Constant

Description

4

EBADF

The fildes parameter isn't a valid file descriptor.

79

ENOTSUP

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

106

ENOCONTEXT

The current thread has not context.

For possible DFS errors, see Section 13.4.5, DFS Return Values.

Remarks

The dfs_setlength function modifies the data size (end of file) for the open file identified by fildes. If the file has more than one data stream, only the size of the data stream identified by fildes is modified. To modify the size of more than one data stream, an application must open each stream independently and call dfs_setlength once for each data stream.

The dfs_setlength function works with the Novell Storage Services file system only. If fildes specifies a file for any other system, dfs_setlength does not operate.

If the new size is smaller than the original size, the data at the end of the original data stream is truncated. If the new size is larger than the original size, the data size is expanded.

See Also