File Management Control Codes

The following control codes are used in file management.

In this section

Control Code Description
FSCTL_ALLOW_EXTENDED_DASD_IO
Signals the file system driver not to perform any I/O boundary checks on partition read or write calls.
FSCTL_CREATE_OR_GET_OBJECT_ID
Retrieves the object identifier for the specified file or directory. If no object identifier exists, using FSCTL_CREATE_OR_GET_OBJECT_ID creates one.
FSCTL_CSV_CONTROL
Retrieves the results of a CSV control operation.
FSCTL_DELETE_OBJECT_ID
Removes the object identifier from a specified file or directory.
FSCTL_DUPLICATE_EXTENTS_TO_FILE
Instructs the file system to copy a range of file bytes on behalf of an application.
FSCTL_FILE_LEVEL_TRIM
Indicates to the storage system which ranges in the file are not needed to be stored.
FSCTL_FILESYSTEM_GET_STATISTICS
Retrieves the information from various file system performance counters.
FSCTL_FILESYSTEM_GET_STATISTICS_EX
Retrieves the information from various file system performance counters.
Support for this control code started with Windows 10.
FSCTL_FIND_FILES_BY_SID
Searches a directory for a file whose creator owner matches the specified SID.
FSCTL_GET_COMPRESSION
Retrieves the current compression state of a file or directory on a volume whose file system supports per-stream compression.
FSCTL_GET_NTFS_FILE_RECORD
Retrieves the first file record that is in use and is of a lesser than or equal ordinal value to the requested file reference number.
FSCTL_GET_OBJECT_ID
Retrieves the object identifier for the specified file or directory.
FSCTL_GET_REPAIR
Retrieves information about the NTFS file system's self-healing mechanism.
FSCTL_INITIATE_REPAIR
Triggers the NTFS file system to start a self-healing cycle on a single file.
FSCTL_MAKE_MEDIA_COMPATIBLE
Closes an open UDF session on write-once media to make the media ROM compatible.
FSCTL_OPBATCH_ACK_CLOSE_PENDING
Notifies a server that a client application is ready to close a file.
FSCTL_OPLOCK_BREAK_ACK_NO_2
Responds to notification that an opportunistic lock on a file is about to be broken. Use this operation to unlock 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. Use this operation to indicate that the file should receive a level 2 opportunistic lock.
FSCTL_OPLOCK_BREAK_NOTIFY
Enables the calling application to wait for completion of an opportunistic lock break.
FSCTL_QUERY_ALLOCATED_RANGES
Scans a file or alternate stream looking for ranges that may contain nonzero data.
FSCTL_QUERY_ON_DISK_VOLUME_INFO
Requests UDF-specific volume information.
FSCTL_QUERY_SPARING_INFO
Retrieves the defect management properties of the volume. Used for UDF file systems.
FSCTL_RECALL_FILE
Recalls a file from storage media that Remote Storage manages, which is the hierarchical storage management software.
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
Requests an opportunistic lock (oplock) on a file and acknowledges that an oplock break has occurred.
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.
FSCTL_SET_COMPRESSION
Sets the compression state of a file or directory on a volume whose file system supports per-file and per-directory compression.
FSCTL_SET_DEFECT_MANAGEMENT
Sets the software defect management state for the specified file. Used for UDF file systems.
FSCTL_SET_OBJECT_ID
Sets the object identifier for the specified file or directory.
FSCTL_SET_OBJECT_ID_EXTENDED
Modifies user data associated with the object identifier for the specified file or directory.
FSCTL_SET_REPAIR
Sets the mode of an NTFS file system's self-healing capability.
FSCTL_SET_SPARSE
Marks the indicated file as sparse or not sparse. In a sparse file, large ranges of zeros may not require disk allocation.
FSCTL_SET_ZERO_DATA
Fills a specified range of a file with zeros (0).
FSCTL_SET_ZERO_ON_DEALLOCATION
Indicates an NTFS file system file handle should have its clusters filled with zeros when it is deallocated.
FSCTL_WAIT_FOR_REPAIR
Returns when the specified repairs are completed.

The following control codes are used with file compression and decompression.

FSCTL_GET_COMPRESSION
FSCTL_SET_COMPRESSION

The following control codes are used with object identifiers.

FSCTL_CREATE_OR_GET_OBJECT_ID
FSCTL_DELETE_OBJECT_ID
FSCTL_GET_OBJECT_ID
FSCTL_SET_OBJECT_ID
FSCTL_SET_OBJECT_ID_EXTENDED

The following control codes are used with opportunistic locks.

FSCTL_OPBATCH_ACK_CLOSE_PENDING
FSCTL_OPLOCK_BREAK_ACK_NO_2
FSCTL_OPLOCK_BREAK_ACKNOWLEDGE
FSCTL_OPLOCK_BREAK_NOTIFY
FSCTL_REQUEST_BATCH_OPLOCK
FSCTL_REQUEST_FILTER_OPLOCK
FSCTL_REQUEST_OPLOCK
FSCTL_REQUEST_OPLOCK_LEVEL_1
FSCTL_REQUEST_OPLOCK_LEVEL_2

The following control codes are used with sparse files.

FSCTL_QUERY_ALLOCATED_RANGES
FSCTL_SET_SPARSE
FSCTL_SET_ZERO_DATA

The following control codes are used with the NTFS self-healing mechanism.

FSCTL_GET_REPAIR
FSCTL_INITIATE_REPAIR
FSCTL_SET_REPAIR
FSCTL_WAIT_FOR_REPAIR

The following control codes are used with UDF.

FSCTL_MAKE_MEDIA_COMPATIBLE
FSCTL_QUERY_ON_DISK_VOLUME_INFO
FSCTL_QUERY_SPARING_INFO
FSCTL_SET_DEFECT_MANAGEMENT

Directory Management Control Codes

Volume Management Control Codes