CcSetFileSizesEx function (ntifs.h)

The CcSetFileSizesEx routine updates the cache maps and section object for a cached file whose size has changed.

Syntax

NTSTATUS CcSetFileSizesEx(
  PFILE_OBJECT   FileObject,
  PCC_FILE_SIZES FileSizes
);

Parameters

FileObject

[in] Pointer to a file object for the cached file.

FileSizes

[in] Pointer to a CC_FILE_SIZES structure containing the new file size information.

Return value

CcSetFileSizesEx returns STATUS_SUCCESS if the file size was successfully changed, and, if a purge was needed that the purge was successful. Otherwise it returns a non-success NSTATUS code such as STATUS_INSUFFICIENT_RESOURCES, and might raise a status exception.

Regarding raising a status exception on error:

  • If the operation causes CcSetFileSizesEx to flush and/or purge the file, CcSetFileSizesEx won't raise on errors; it just returns the appropriate non-success NTSTATUS code of the flush or purge operation.

  • If the operation causes CcSetFileSizesEx to extend the section, then CcSetFileSizesEx will raise on any error it hits during this extension.

Remarks

File systems must call CcSetFileSizesEx to update the cache manager data structures whenever one of the following changes is made to a cached file:

  • Its allocation size is increased.

  • Its valid data length is decreased.

  • Its valid data length is increased by a non-cached I/O operation.

  • Its file size is increased or decreased.

If the operation causes CcSetFileSizesEx to extend the section and a failure occurs, CcSetFileSizesEx raises a status exception for that particular failure. For example, if a pool allocation failure occurs, CcSetFileSizesEx raises a STATUS_INSUFFICIENT_RESOURCES exception. Therefore, to gain control if a failure occurs, the driver should wrap the call to CcSetFileSizesEx in a try-except or try-finally statement.

The file system must ensure that the cache map is valid and will remain so for the duration of this call.

To cache a file, use CcInitializeCacheMap.

To get the size of the cached file, pass FileObject to CcGetFileSizePointer.

Requirements

Requirement Value
Header ntifs.h

See also

CcInitializeCacheMap

CcSetCacheFileSizes