Skip to content

Latest commit

 

History

History
120 lines (95 loc) · 4.78 KB

ni-winioctl-fsctl_shrink_volume.md

File metadata and controls

120 lines (95 loc) · 4.78 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist f1_keywords dev_langs topic_type api_type api_location api_name
NI:winioctl.FSCTL_SHRINK_VOLUME
FSCTL_SHRINK_VOLUME
Signals that the volume is to be prepared to perform the shrink operation, the shrink operation is to be committed, or the shrink operation is to be terminated.
FSCTL_SHRINK_VOLUME
FSCTL_SHRINK_VOLUME control
FSCTL_SHRINK_VOLUME control code [Files]
fs.fsctl_shrink_volume
winioctl/FSCTL_SHRINK_VOLUME
fs\fsctl_shrink_volume.htm
fs
cf545417-f933-4054-bed4-e6adbf822f9c
12/05/2018
FSCTL_SHRINK_VOLUME, FSCTL_SHRINK_VOLUME control, FSCTL_SHRINK_VOLUME control code [Files], fs.fsctl_shrink_volume, winioctl/FSCTL_SHRINK_VOLUME
winioctl.h
Windows.h
Windows
Windows Vista [desktop apps only]
Windows Server 2008 [desktop apps only]
Windows
FSCTL_SHRINK_VOLUME
winioctl/FSCTL_SHRINK_VOLUME
c++
APIRef
kbSyntax
HeaderDef
WinIoCtl.h
FSCTL_SHRINK_VOLUME

FSCTL_SHRINK_VOLUME IOCTL

-description

Signals that the volume is to be prepared to perform the shrink operation, the shrink operation is to be committed, or the shrink operation is to be terminated.

To perform this operation, call the DeviceIoControl function with the following parameters.

BOOL DeviceIoControl(
  (HANDLE) hDevice,             // handle to device
  FSCTL_SHRINK_VOLUME,          // dwIoControlCode
  (LPVOID) lpInBuffer,          // input buffer
  nInBufferSize,                // size of input buffer    
  NULL,                         // output buffer
  O,                            // size of output buffer
  (LPDWORD) lpBytesReturned,    // number of bytes returned
  (LPOVERLAPPED) lpOverlapped   // OVERLAPPED structure
);

-ioctlparameters

-input-buffer

-input-buffer-length

-output-buffer

-output-buffer-length

-in-out-buffer

-inout-buffer-length

-status-block

Irp->IoStatus.Status is set to STATUS_SUCCESS if the request is successful.

Otherwise, Status to the appropriate error condition as a NTSTATUS code.

For more information, see NTSTATUS Values.

-remarks

This control code is only supported on NTFS and RAW file systems.

To complete a shrink operation, you must:

  1. Call CreateFile to open a handle to the volume.
  2. Call FSCTL_SHRINK_VOLUME. Set the ShrinkRequestType member of the SHRINK_VOLUME_INFORMATION structure to ShrinkPrepare. Set the NewNumberOfSectors member of the same structure to zero. If this call succeeds, the filesystem will not allocate clusters beyond the end of the new volume length.
  3. Call FSCTL_MOVE_FILE on all files beyond the new number of sectors and move them within the valid range. You are responsible for moving any files that are affected by the shrink operation.
  4. Call FSCTL_SHRINK_VOLUME. Set the ShrinkRequestType member of the SHRINK_VOLUME_INFORMATION structure to ShrinkCommit. Set the NewNumberOfSectors member of the same structure to zero. If all files beyond the end of the new volume size have not been moved, the call fails with STATUS_ALREADY_COMMITTED (ERROR_ACCESS_DENIED). Otherwise, the filesystem has now been shrunk.
  5. Call IOCTL_DISK_GROW_PARTITION. Set the BytesToGrow member of the DISK_GROW_PARTITION structure to the negative number that represents the number of bytes to remove.

In Windows 8 and Windows Server 2012, this code is supported by the following technologies.

Technology Supported
Server Message Block (SMB) 3.0 protocol No
SMB 3.0 Transparent Failover (TFO) No
SMB 3.0 with Scale-out File Shares (SO) No
Cluster Shared Volume File System (CsvFS) See comment

Is supported only on the node that has NTFS mounted.

-see-also