IoWritePartitionTable

NTSTATUS
    IoWritePartitionTable(

        IN PDEVICE_OBJECT  DeviceObject,
        IN ULONG  SectorSize,
        IN ULONG  SectorsPerTrack,
        IN ULONG  NumberOfHeads,
        IN struct _DRIVE_LAYOUT_INFORMATION  *PartitionBuffer
        );

IoWritePartitionTable writes partition tables from the entries in the partition list buffer for each partition on the disk represented by the given device object.

Parameters

DeviceObject
Points to the device object representing the disk whose partition tables are to be written.
SectorSize
Specifies the size in bytes of sectors on the device.
SectorsPerTrack
Specifies the track size on the device.
NumberOfHeads
Specifies the number of tracks per cylinder.
PartitionBuffer
Points to the drive layout buffer that contains the partition list entries. For more detailed information about the DRIVE_LAYOUT_INFORMATION structure, see IoReadPartitionTable.

Return Value

If all writes are completed without error, IoWritePartitionTable returns STATUS_SUCCESS.

Comments

IoWritePartitionTable is called when a disk device driver is asked to set the partition type in a partition table entry or to repartition the disk by an IRP_MJ_DEVICE_CONTROL request. The device control request is generally issued by the format utility, which performs I/O control functions on the partitions and disks in the machine.

To reset a partition type, the driver passes a pointer to the device object representing the physical disk and the number of the partition associated with the device object that the format utility has open. When a disk is to be repartitioned dynamically, the disk driver must tear down its set of device objects representing the current disk partitions and create a new set of device objects representing the new partitions on the disk.

Applications that create and delete partitions and require full descriptions of the system should call IoReadPartitionTable with ReturnRecognizedPartitions set to FALSE. The drive layout structure can be modified by the system format utility to reflect a new configuration of the disk.

IoWritePartitionTable is synchronous. It must be called by the disk driver’s Dispatch routine or by a driver thread. Thus, all user and file system threads must be prepared to enter a wait state when issuing the device control request to reset partition types for the device.

Callers of this routine must be running at IRQL PASSIVE_LEVEL.

See Also

IoCreateDevice, IoReadPartitionTable, IoSetPartitionInformation