Platform SDK: Files and I/O

File System Control Codes

The following are defragmentation control codes.

Value Meaning
FSCTL_GET_RETRIEVAL_POINTERS Get information about a file's cluster use.
FSCTL_GET_VOLUME_BITMAP Get a bitmap of cluster allocation.
FSCTL_MOVE_FILE Move all or part of a file from one set of clusters to another within a volume.

The following control codes are used with file compression.

Value Meaning
FSCTL_GET_COMPRESSION Obtains the compression state of a file or directory
FSCTL_SET_COMPRESSION Sets the compression state of a file or directory.

The following control codes are used with NTFS change journals.

Value Meaning
FSCTL_CREATE_USN_JOURNAL Creates an NTFS change journal stream on a target volume or modifies an existing change journal stream.
FSCTL_DELETE_USN_JOURNAL Deletes the NTFS change journal on a volume or awaits notification of deletion of an NTFS change journal.
FSCTL_ENUM_USN_DATA Creates an enumeration that lists the NTFS change journal entries between two specified boundaries.
FSCTL_MARK_HANDLE Marks a specified file or directory and its NTFS change journal record with information about changes to that file or directory.
FSCTL_QUERY_USN_JOURNAL Queries for information on the current NTFS change journal, its records, and its capacity.
FSCTL_READ_USN_JOURNAL Returns to the calling process the set of NTFS change journal records between two specified USN values.
FSCTL_WRITE_USN_CLOSE_RECORD Generates a record in the change journal stream for the input file. This record will have the USN_REASON_CLOSE flag.

The following control codes are used with opportunistic locks.

Value Meaning
FSCTL_OPBATCH_ACK_CLOSE_PENDING Notifies a server that a client application is about to close a file. An application uses this operation following notification that an opportunistic lock on the file is about to be broken.
FSCTL_OPLOCK_BREAK_ACK_NO_2 Responds to notification that an opportunistic lock on a file is about to be broken. An application uses this operation to loose all opportunistic locks on the file but keep the file open.
FSCTL_OPLOCK_BREAK_ACKNOWLEDGE Responds to notification that an exclusive opportunistic lock on a file is about to be broken. An application uses this operation to indicate that the file should receive a level 2 opportunistic lock.
FSCTL_OPLOCK_BREAK_NOTIFY Allows the calling application to wait for completion of an opportunistic lock break.
FSCTL_REQUEST_BATCH_OPLOCK Requests a batch opportunistic lock on a file.
FSCTL_REQUEST_FILTER_OPLOCK Requests a filter opportunistic lock on a file.
FSCTL_REQUEST_OPLOCK_LEVEL_1 Requests a level 1 opportunistic lock on a file.
FSCTL_REQUEST_OPLOCK_LEVEL_2 Requests a level 2 opportunistic lock on a file.

The following control codes are used with reparse points.

Value Meaning
FSCTL_DELETE_REPARSE_POINT Deletes a reparse point for a file or directory.
FSCTL_GET_REPARSE_POINT Returns reparse point data for a file or directory.
FSCTL_SET_REPARSE_POINT Sets a reparse point on a file or directory.

The following control codes are used with sparse files.

Value Meaning
FSCTL_QUERY_ALLOCATED_RANGES Scans a file for ranges of the file for which disk space is allocated.
FSCTL_SET_SPARSE Marks a file as a sparse file.
FSCTL_SET_ZERO_DATA Sets a range of a files bytes to zeroes.