New partitions can be created on a hard disk by scanning a disk for
empty regions and calling CreatePartition() to allocate new partition space.
To find an empty disk region, call GetPartitionDisks() and scan the
available disks for a partition marked as empty (the PTYPE_FREESPACE
flag will be set in the Flags field of empty partitions). Call CreatePartition() with a pointer
to the empty partition and set the Sectors argument to indicate how large
the partition should be (one sector equals 512 bytes). The FileSystem argument needs to be
set to a file system code, as listed in the TranslatePartitionFS() function.
If this function succeeds, the change to the disk structure is immediate.
The disk structure will be re-scanned and the partition structures will be rebuilt
from scratch irrespective of whether or not the call succeeds. The operating
system may not be able to update its view of the new disk structure - if this
is the case, the RebootPartitions() function will return a value of TRUE.
If you would like to create a new partition at an offset within
empty space (e.g. creating a 10 GB partition at the end of a 30 GB drive)
then you can change the Sector field of the empty Partition structure before calling
this function.
There is a limit of 4 primary/extended partitions to a disk. If creating
a new partition inside free space requires a 5th partition entry, the error
code ERR_ArrayFull is returned.
ERR_Okay | The partition was successfully created. |
ERR_Args | Invalid arguments detected. |
ERR_ArrayFull | The maximum number of primary partitions has been reached. |
ERR_OutOfSpace | The Partition structure that you referred to is not an empty space. |
ERR_OpenFile | The hard disk partition table could not be opened. |
ERR_SanityFailure | A sanity check was failed before the partition table was written. |
ERR_Seek | Seeking to a new sector position in the hard disk failed. |
|