FSCTL_REARRANGE_FILE - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
// ntifs.h

// CTL_CODE(0x0009, 0x108, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define FSCTL_REARRANGE_FILE 0x0009C420
View the official Windows Driver Kit DDI reference

NtDoc

No description available.

Windows Driver Kit DDI reference (ni-ntifs-fsctl_rearrange_file)

Description

FSCTL_REARRANGE_FILE rearranges allocation within the file, moving clusters from a requested contiguous source range within a file to another location within the same file.

Parameters

Major code

Input buffer

Pointer to a REARRANGE_FILE_DATA structure that describes the allocation to be rearranged. (For 32-bit callers, the input buffer is a pointer to a REARRANGE_FILE_DATA32 structure.)

Input buffer length

Size in bytes of the input buffer.

Output buffer

None; set to NULL.

Output buffer length

Set to zero.

Input/output buffer

Input/output buffer length

Status block

Return values

FSCTL_REARRANGE_FILE returns STATUS_SUCCESS upon successful completion; otherwise it returns an NTSTATUS code such as one of the following.

Return code Meaning
STATUS_ACCESS_DENIED Only kernel-mode calls are allowed.
STATUS_BUFFER_TOO_SMALL The specified input buffer length is smaller than sizeof(REARRANGE_FILE_DATA).
STATUS_PENDING Operation completion is pending.

Remarks

Request parameters contain source and target file byte offsets, and length in bytes of the source region to move, all of which must be cluster-aligned.

In both cases, the target offset indicates that the source range should be inserted before the cluster that begins at the target offset, the distinction being forced by the constraint that the allocation size remains fixed.

Unlike FSCTL_SHUFFLE_FILE, FSCTL_REARRANGE_FILE doesn't allow adding allocations containing random data.

To perform this operation, call FltFsControlFile or ZwFsControlFile with the following parameters.

Parameter Description
Instance [in] For FltFsControlFile only. An opaque instance pointer for the caller. This parameter is required and cannot be NULL.
FileObject [in] For FltFsControlFile only. A file object pointer for the file or directory that is the target of this request. This parameter is required and cannot be NULL.
FileHandle [in] For ZwFsControlFile only. File handle of the file or directory that is the target of this request. This parameter is required and cannot be NULL.
IoStatusBlock [out] For ZwFsControlFile only. Pointer to an IO_STATUS_BLOCK structure that contains the final status of the request.
FsControlCode [in] Set to FSCTL_REARRANGE_FILE.
InputBuffer [in] See IOCTL parameters.
InputBufferLength [in] See IOCTL parameters.

See also

FltFsControlFile

FSCTL_SHUFFLE_FILE

REARRANGE_FILE_DATA

ZwFsControlFile