[PATCH parted 6/7] libparted: add ped_disk_get_partition_alignment() function

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

 



This functions get the alignment needed for partition boundaries on this disk.
The returned alignment describes the alignment for the start sector of the
partition, for all disklabel types which require alignment, except Sun
disklabels, the end sector must be aligned too. To get the end sector
alignment decrease the PedAlignment offset by 1.
---
 include/parted/disk.h |    2 ++
 libparted/disk.c      |   20 ++++++++++++++++++++
 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/include/parted/disk.h b/include/parted/disk.h
index 46b5f28..76397a8 100644
--- a/include/parted/disk.h
+++ b/include/parted/disk.h
@@ -214,6 +214,7 @@ struct _PedDiskOps {
         int (*get_max_primary_partition_count) (const PedDisk* disk);
         bool (*get_max_supported_partition_count) (const PedDisk* disk,
                                                    int* supported);
+        PedAlignment *(*get_partition_alignment)(const PedDisk *disk);
 };
 
 struct _PedDiskType {
@@ -263,6 +264,7 @@ extern int ped_disk_get_last_partition_num (const PedDisk* disk);
 extern int ped_disk_get_max_primary_partition_count (const PedDisk* disk);
 extern bool ped_disk_get_max_supported_partition_count(const PedDisk* disk,
                                                        int* supported);
+extern PedAlignment *ped_disk_get_partition_alignment(const PedDisk *disk);
 
 /** @} */
 
diff --git a/libparted/disk.c b/libparted/disk.c
index f3074a3..60efc54 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -686,6 +686,26 @@ ped_disk_get_max_supported_partition_count(const PedDisk* disk, int* supported)
 }
 
 /**
+ * Get the alignment needed for partition boundaries on this disk.
+ * The returned alignment describes the alignment for the start sector of the
+ * partition, for all disklabel types which require alignment, except Sun
+ * disklabels, the end sector must be aligned too. To get the end sector
+ * alignment decrease the PedAlignment offset by 1.
+ *
+ * \return NULL on error, otherwise a pointer to a dynamically allocated
+ *         alignment.
+ */
+PedAlignment*
+ped_disk_get_partition_alignment(const PedDisk *disk)
+{
+        /* disklabel handlers which don't need alignment don't define this */
+        if (!disk->type->ops->get_partition_alignment)
+                return ped_alignment_duplicate(ped_alignment_any);
+
+        return disk->type->ops->get_partition_alignment(disk);
+}
+
+/**
  * Get the maximum number of (primary) partitions the disk label supports.
  *
  * For example, MacIntosh partition maps can have different sizes,
-- 
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