4.4 Deleting a Partition

The following diagram shows how the IVolumeClient interfaces are used to delete a partition on a disk.

Steps to delete a partition on a disk by using the IVolumeClient interfaces

Figure 4: Steps to delete a partition on a disk by using the IVolumeClient interfaces

  1. The client calls IVolumeClient::Initialize and passes its implementation of the IDMNotify interface to the server.

  2. The client calls IVolumeClient::EnumDisks to get the list of disks from the server.

  3. For each disk, a DISK_INFO structure is returned. The server allocates the memory and returns the array of DISK_INFO structures and HRESULT to the client.

  4. The client verifies that the call was successful by looking at the returned HRESULT. If the call was successful, the client finds the disks to be used to delete the partition (for example, by looking at the disk name field in the DISK_INFO structure). The client then calls IVolumeClient::EnumDiskRegions to get an array that represents the regions on the disk on that it wants to delete the partition. The input parameter to EnumDiskRegions is the disk's LdmObjectId, which is the first member of the DISK_INFO structure.

  5. The server allocates an array of REGION_INFO structures and returns the array to the client.

  6. The client verifies that the call was successful by looking at the returned HRESULT. If the call was successful, the client parses the array to find a region that it wants to delete. Once the client finds the region to be deleted, the client calls IVolumeClient::DeletePartition. The input parameter to the call is a REGION_SPEC structure and bForce flag. The client fills in the LdmObjectId for the region; this information is obtained from the REGION_INFO structure. The client fills in the region type, disk ID and lastKnownState members of the REGION_SPEC structure by using the values from the REGION_INFO structure. The client also fills in the start and length fields of the REGION_SPEC. The client sets the force parameter to TRUE if it wants to force the deletion of the partition; otherwise, it sets the force parameter to FALSE.

  7. The server deletes the partition and fills in the TASK_INFO structure. The call to IVolumeClient::DeletePartition returns this TASK_INFO structure.

  8. The client verifies that the partition was successfully deleted by looking at the HRESULT returned from the call. The returned TASK_INFO structure will contain the deleted region's id in the storageId field. The status field in the TASK_INFO structure will be REQ_COMPLETED.

  9. The server calls back the client with a disk modified notification on the IDMNotify Interface's ObjectsChanged method.

  10. The client code processes the disk modified notification. For example, the client might query for the current disk information and all disk regions when it gets a disk modified notification, so that it can update its cache or display.

  11. The server calls back the client with a region deleted notification on the IDMNotify Interface's ObjectsChanged method.

  12. The client code processes the region deleted notification. For example, the client might query for all disk regions when it gets a region deleted notification, so that it can update its cache or display.