[PATCH parted 7/7] Implement get_partition_alignment DiskOp for all labels which need it

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Implement get_partition_alignment DiskOp for all labels which require
an alignment with a grain_size != 1.
---
 libparted/labels/dasd.c |   12 ++++++++++++
 libparted/labels/mac.c  |   11 ++++++++++-
 libparted/labels/pc98.c |   12 +++++++++++-
 libparted/labels/rdb.c  |   12 +++++++++++-
 libparted/labels/sun.c  |   10 ++++++++++
 5 files changed, 54 insertions(+), 3 deletions(-)

diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
index 01a2357..93706ea 100644
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
@@ -99,6 +99,7 @@ static int dasd_partition_align (PedPartition* part,
 static int dasd_partition_enumerate (PedPartition* part);
 static int dasd_get_max_primary_partition_count (const PedDisk* disk);
 static bool dasd_get_max_supported_partition_count (const PedDisk* disk, int *max_n);
+static PedAlignment *dasd_get_partition_alignment(const PedDisk *disk);
 
 static PedDisk* dasd_alloc (const PedDevice* dev);
 static PedDisk* dasd_duplicate (const PedDisk* disk);
@@ -131,6 +132,7 @@ static PedDiskOps dasd_disk_ops = {
 	alloc_metadata: dasd_alloc_metadata,
 	get_max_primary_partition_count: dasd_get_max_primary_partition_count,
 	get_max_supported_partition_count: dasd_get_max_supported_partition_count,
+	get_partition_alignment: dasd_get_partition_alignment,
 
 	partition_duplicate: NULL
 };
@@ -723,6 +725,16 @@ dasd_get_max_supported_partition_count (const PedDisk* disk, int *max_n)
 	return true;
 }
 
+static PedAlignment*
+dasd_get_partition_alignment(const PedDisk *disk)
+{
+        DasdDiskSpecific* disk_specific = disk->disk_specific;
+        PedSector sector_size =
+                disk_specific->real_sector_size / disk->dev->sector_size;
+
+        return ped_alignment_new(0, disk->dev->hw_geom.sectors * sector_size);
+}
+
 static PedConstraint*
 _primary_constraint (PedDisk* disk)
 {
diff --git a/libparted/labels/mac.c b/libparted/labels/mac.c
index c8bf0d2..561ca5f 100644
--- a/libparted/labels/mac.c
+++ b/libparted/labels/mac.c
@@ -1425,6 +1425,14 @@ mac_partition_get_name (const PedPartition* part)
 	return mac_data->volume_name;
 }
 
+static PedAlignment*
+mac_get_partition_alignment(const PedDisk *disk)
+{
+        PedSector sector_size = disk->dev->sector_size / 512;
+
+        return ped_alignment_new(0, sector_size);
+}
+
 static PedConstraint*
 _primary_constraint (PedDisk* disk)
 {
@@ -1659,7 +1667,8 @@ static PedDiskOps mac_disk_ops = {
 	get_max_primary_partition_count:
 				mac_get_max_primary_partition_count,
 	get_max_supported_partition_count:
-				mac_get_max_supported_partition_count
+				mac_get_max_supported_partition_count,
+	get_partition_alignment: mac_get_partition_alignment,
 };
 
 static PedDiskType mac_disk_type = {
diff --git a/libparted/labels/pc98.c b/libparted/labels/pc98.c
index 40f74a2..4a8bcd4 100644
--- a/libparted/labels/pc98.c
+++ b/libparted/labels/pc98.c
@@ -720,6 +720,15 @@ pc98_partition_get_name (const PedPartition* part)
 	return pc98_data->name;
 }
 
+static PedAlignment*
+pc98_get_partition_alignment(const PedDisk *disk)
+{
+	PedSector cylinder_size =
+		disk->dev->hw_geom.sectors * disk->dev->hw_geom.heads;
+
+        return ped_alignment_new(0, cylinder_size);
+}
+
 static PedConstraint*
 _primary_constraint (PedDisk* disk)
 {
@@ -879,7 +888,8 @@ static PedDiskOps pc98_disk_ops = {
 	get_max_primary_partition_count:
 				pc98_get_max_primary_partition_count,
 	get_max_supported_partition_count:
-				pc98_get_max_supported_partition_count
+				pc98_get_max_supported_partition_count,
+	get_partition_alignment: pc98_get_partition_alignment,
 };
 
 static PedDiskType pc98_disk_type = {
diff --git a/libparted/labels/rdb.c b/libparted/labels/rdb.c
index 1d21dbd..9460f0c 100644
--- a/libparted/labels/rdb.c
+++ b/libparted/labels/rdb.c
@@ -1027,6 +1027,15 @@ amiga_partition_get_name (const PedPartition* part)
 	return _amiga_get_bstr(partition->pb_DriveName);
 }
 
+static PedAlignment*
+amiga_get_partition_alignment(const PedDisk *disk)
+{
+	PedSector cylinder_size =
+		disk->dev->hw_geom.sectors * disk->dev->hw_geom.heads;
+
+        return ped_alignment_new(0, cylinder_size);
+}
+
 static PedConstraint*
 _amiga_get_constraint (const PedDisk *disk)
 {
@@ -1175,7 +1184,8 @@ static PedDiskOps amiga_disk_ops = {
 	get_max_primary_partition_count:
 				amiga_get_max_primary_partition_count,
 	get_max_supported_partition_count:
-				amiga_get_max_supported_partition_count
+				amiga_get_max_supported_partition_count,
+	get_partition_alignment: amiga_get_partition_alignment,
 };
 
 static PedDiskType amiga_disk_type = {
diff --git a/libparted/labels/sun.c b/libparted/labels/sun.c
index 41f0bae..86e4ef4 100644
--- a/libparted/labels/sun.c
+++ b/libparted/labels/sun.c
@@ -707,6 +707,15 @@ sun_get_max_primary_partition_count (const PedDisk* disk)
 	return SUN_DISK_MAXPARTITIONS;
 }
 
+static PedAlignment*
+sun_get_partition_alignment(const PedDisk *disk)
+{
+	PedSector block =
+		disk->dev->hw_geom.sectors * disk->dev->hw_geom.heads;
+
+        return ped_alignment_new(0, block);
+}
+
 static PedConstraint*
 _get_strict_constraint (PedDisk* disk)
 {
@@ -904,6 +913,7 @@ static PedDiskOps sun_disk_ops = {
 				sun_get_max_primary_partition_count,
 	get_max_supported_partition_count:
 				sun_get_max_supported_partition_count,
+	get_partition_alignment: sun_get_partition_alignment,
 
 	partition_set_name:		NULL,
 	partition_get_name:		NULL,
-- 
1.6.5.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux