3.4.5.2.27.1 IVdsCreatePartitionEx::CreatePartitionEx (Opnum 3)

 The CreatePartitionEx method creates a partition on a disk at a specified byte offset, with an optional alignment parameter.

 HRESULT CreatePartitionEx(
   [in] ULONGLONG ullOffset,
   [in] ULONGLONG ullSize,
   [in] unsigned long ulAlign,
   [in] CREATE_PARTITION_PARAMETERS* para,
   [out] IVdsAsync** ppAsync
 );

ullOffset: The byte offset from the beginning of the disk where the new partition will be created. If ulAlign is not zero, the offset MUST fall within the first cylinder for an MBR disk (GPT disks do not have this restriction).

ullSize: The size of the new partition, in bytes.<105>

ulAlign: The number of bytes for volume alignment. The offset specified in ullOffset will be rounded up or down to an alignment boundary. If zero is specified, the server will base the alignment value on the size of the disk on which the volume is created.<106>

para: A pointer to a CREATE_PARTITION_PARAMETERS structure that describes the new partition to create.

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. If the IVdsAsync::Wait method is called on the interface, the interfaces returned in the VDS_ASYNC_OUTPUT structure MUST be released as well. For information on asynchronous tasks, see section 3.4.5.1.9.

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 Creating or deleting partitions on dynamic disks is not supported.

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 parameters:

  • Verify that para is not NULL.

  • Verify that ppAsync is not NULL.

The server MUST perform the following:

  • If the partition cannot be created because there is not enough free space on the specified disk, then the server MUST return VDS_E_NOT_ENOUGH_SPACE.

  • Create a new async object implementing the IVdsAsync interface with an output type of VDS_ASYNCOUT_CREATEPARTITION and set the pointer ppAsync references to the interface.

  • Return an HRESULT indicating failure or success. Any errors encountered up through this point in processing the operation are returned in this HRESULT.

The server MUST then perform the following in sequence. Errors generated in this sequence of steps are returned in the pHrResult parameter to the IVdsAsync::Wait or IVdsAsyncQueryStatus methods.

  • Create a new partition following the parameters specified to the method.

    • If the partition creation resulted in the renumbering of existing partitions on a boot disk, the server MUST update the boot configuration file with the new partition numbering.

  • Set the task-specific return values in the async object to return the values associated with VDS_ASYNCOUT_CREATEPARTITION (as specified in section 3.4.5.1.9).

  • Set the return code in the async object to an HRESULT indicating failure or success.

    • If the server was required to update the boot configuration file but failed, the return code MUST be set to VDS_S_UPDATE_BOOTFILE_FAILED (HRESULT of 0x80042434).

  • 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.

  • For each callback object registered in the list of callback objects, call the callback object's IVdsAdviseSink::OnNotify method with a VDS_NOTIFICATION structure with the following attributes:

    • objectType member is VDS_NTT_PARTITION.

    • Partition member is a VDS_PARTITION_NOTIFICATION with the following attributes:

      • ulEvent is VDS_NF_PARTITION_ARRIVE.

      • diskId is the VDS_OBJECT_ID of the disk object corresponding to the disk on which the partition was added.

      • ullOffset is the byte offset at which the partition starts on the disk.

  • If the partition is created on a removable media disk, for each callback object registered in the list of callback objects, call the callback object's IVdsAdviseSink::OnNotify method with a VDS_NOTIFICATION structure with the following attributes:

    • objectType member is VDS_NTT_VOLUME.

    • Volume member is a VDS_VOLUME_NOTIFICATION with the following attributes:

      • ulEvent is VDS_NF_VOLUME_ARRIVE.

      • volumeId is the VDS_OBJECT_ID of the volume object corresponding to the removable media drive.

      • plexId is NULL GUID, but it is not relevant when ulEvent is VDS_NF_VOLUME_ARRIVE.

      • ulPercentCompleted range is 0-100 and is implementation-specific; however, it is not relevant when ulEvent is VDS_NF_VOLUME_ARRIVE.

  • For each callback object registered in the list of callback objects, call the callback object's IVdsAdviseSink::OnNotify method with a VDS_NOTIFICATION structure with the following attributes:

    • objectType member is VDS_NTT_DISK.

    • Disk member is a VDS_DISK_NOTIFICATION with the following attributes:

      • ulEvent is VDS_NF_DISK_MODIFY.

      • diskId is the VDS_OBJECT_ID of this disk object.

The server MUST update the percentage completed value periodically during the preceding sequence. How often the percentage completed is updated, and at what point in the sequence, is implementation-specific.