4.3 Creating a Partition

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

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

Figure 3: Steps to create 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 remote machine.

  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 disk to be used to create 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. 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 with REGIONTYPE REGION_FREE. The client looks at the size of the region to see what size partition can be created in this region. If this free region is not large enough for the expected partition size, the client can continue to look for free regions on that disk that are larger. Once the client finds the region to be used to create the new volume, the client calls IVolumeClient::CreatePartition. The input parameter to the call is a REGION_SPEC structure. The client fills in the LdmObjectId for the region; this information is obtained from the REGION_INFO structure. The region type would be REGION_PRIMARY to create a primary partition. The client fills in the 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 length cannot be greater than the reported region length from the REGION_INFO structure. The start is required to be within the offsets that represent the start and end of the region.

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

  8. The client verifies that the partition was successfully created by looking at the HRESULT returned from the call. The returned TASK_INFO structure will contain the new 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 created notification on the IDMNotify interface's ObjectsChanged method.

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