* Noteworthy changes in release ?.? (????-??-??) [?]
+** New features
+
+ The ped_device_get_*_alignment() functions now return a sane default
+ value instead of NULL when the so called topology information is incomplete.
+ The default minimum alignment aligns to physical sector size, the default
+ optimal alignment is 1MiB, which is what vista and windows 7 do.
+
** Bug fixes
Parted no longer uses a physical sector size of 0 or of any other
PedAlignment*
ped_device_get_minimum_alignment(const PedDevice *dev)
{
+ PedAlignment *align = NULL;
+
if (ped_architecture->dev_ops->get_minimum_alignment)
- return ped_architecture->dev_ops->get_minimum_alignment(dev);
+ align = ped_architecture->dev_ops->get_minimum_alignment(dev);
+
+ if (align == NULL)
+ align = ped_alignment_new(0,
+ dev->phys_sector_size / dev->sector_size);
- return NULL; /* ped_alignment_none */
+ return align;
}
/**
PedAlignment*
ped_device_get_optimum_alignment(const PedDevice *dev)
{
+ PedAlignment *align = NULL;
+
if (ped_architecture->dev_ops->get_optimum_alignment)
- return ped_architecture->dev_ops->get_optimum_alignment(dev);
+ align = ped_architecture->dev_ops->get_optimum_alignment(dev);
+
+ /* If the arch specific code could not give as an alignment
+ return a default value based on the type of device. */
+ if (align == NULL) {
+ switch (dev->type) {
+ case PED_DEVICE_DASD:
+ align = ped_device_get_minimum_alignment(dev);
+ break;
+ default:
+ /* Align to a grain of 1MiB (like vista / win7) */
+ align = ped_alignment_new(0,
+ 1048576 / dev->sector_size);
+ }
+ }
- return NULL; /* ped_alignment_none */
+ return align;
}
/** @} */