3.4.5.2.24.9 IVdsAdvancedDisk::FormatPartition (Opnum 11)
The FormatPartition method formats an existing OEM, ESP, or unknown partition.
-
HRESULT FormatPartition( [in] ULONGLONG ullOffset, [in] VDS_FILE_SYSTEM_TYPE type, [in, string] WCHAR* pwszLabel, [in] DWORD dwUnitAllocationSize, [in] long bForce, [in] long bQuickFormat, [in] long bEnableCompression, [out] IVdsAsync** ppAsync );
ullOffset: The byte offset of the partition, from the beginning of the disk. This offset MUST be the offset of a start of a partition.
type: A file system type that is enumerated by VDS_FILE_SYSTEM_TYPE. Clients that want to format by using file systems that are not enumerated by VDS_FILE_SYSTEM_TYPE (section 2.2.1.2.9) can use the IVdsDiskPartitionMF::FormatPartionEx (section 3.4.5.2.29.4) or IVdsDiskPartitionMF2::FormatPartitionEx2 methods.
pwszLabel: A null-terminated Unicode string representing the partition label. The maximum label size is file system-dependent.
dwUnitAllocationSize: The size, in bytes, of the allocation unit for the file system. The value MUST be a power of 2. Allocation unit range is file system-dependent.
bForce: A Boolean that determines whether the format is forced, regardless of whether the partition is in use.
bQuickFormat: A Boolean that determines whether a file system is quick formatted. A quick format does not verify each sector on the volume.
bEnableCompression: A Boolean that determines whether a file system is created with compression enabled.<97>
ppAsync: A pointer to an IVdsAsync interface that, if the operation is successfully completed, receives the IVdsAsync interface to monitor and control this operation. Callers MUST release the interface when they are done with it.
Return Values: The method MUST return zero or a non-error HRESULT (as specified in [MS-ERREF]) to indicate success, or return an implementation-specific nonzero error code to indicate failure. For the HRESULT values predefined by the Virtual Disk Service Remote Protocol, see section 2.2.3.
-
Note This method is not valid on CD/DVD or super floppy devices. These devices do not support partition tables.
ERROR_SUCCESS (0x00000000)
When the server receives this message, it MUST validate the following parameter:
Verify that ppAsync is not NULL.
The server MUST perform the following:
Create a new async object implementing the IVdsAsync interface by using an output type of VDS_ASYNCOUT_FORMAT and set the pointer that ppAsync references to the interface.
Return an HRESULT indicating failure or success. Any errors encountered up through this point in processing the FormatPartition operation are returned in this HRESULT.
The server MUST perform the following. Errors generated in this sequence of steps are returned in the pHrResult parameter to the IVdsAsync::Wait or IVdsAsyncQueryStatus methods.
If the operating system is unable to format the device with the file system type specified using the type parameter, then this method MUST return VDS_E_INCOMPATIBLE_FILE_SYSTEM.
If the target device\media is write-protected, then this method MUST return VDS_E_MEDIA_WRITE_PROTECTED.
If the pwszLabel parameter is incompatible with the file system type specified using the type parameter, then the server MUST return VDS_E_BAD_LABEL.
If the specified file system type has a minimum volume size requirement, and that requirement is not met, then the server MUST return VDS_E_VOLUME_TOO_SMALL.
If the specified file system type has a maximum volume size requirement, and that requirement is not met, then the server MUST return VDS_E_VOLUME_TOO_BIG.
If the specified file system type has a minimum or maximum cluster size requirement, and that requirement is not met, then the server MUST return VDS_E_CLUSTER_SIZE_TOO_SMALL or VDS_E_CLUSTER_SIZE_TOO_BIG, respectively.
If the specified file system type has a maximum cluster count requirement, and that requirement is not met, then the server MUST return VDS_E_CLUSTER_COUNT_BEYOND_32BITS.
The server MUST update the percentage completed value periodically during the following sequence, and send progress notifications to all clients. How often the percentage completed is updated, and at what point in the sequence, is implementation specific. To send progress notifications to the clients:
For each callback object registered in the list of callback objects, call the callback object's IVdsAdviseSink::OnNotify (Opnum 3) method with a VDS_NOTIFICATION structure with the following attributes:
objectType member is VDS_NTT_FILE_SYSTEM.
FileSystem member is a VDS_FILE_SYSTEM_NOTIFICATION with the following attributes:
ulEvent is VDS_NF_FILE_SYSTEM_FORMAT_PROGRESS.
volumeId is set to GUID_NULL.
dwPercentCompleted is the percentage completed value.
The server MUST then perform the following in sequence:
Format the partition following the parameters specified to the method.
If TRUE is specified for bEnableCompression and the file system being formatted supports compression, compress the file system after formatting is complete.<98>
Set the return code in the async object to an HRESULT indicating failure or success.
If the server tried to compress the file system after formatting it and failed, the return code MUST be set to VDS_S_VOLUME_COMPRESS_FAILED--an HRESULT of 0x00042443.
If the task completed successfully, set the percentage completed value in the async object to 100.
Set the signal state in the async object to TRUE.