[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH parted 6/7] libparted: add ped_disk_get_partition_alignment() fun
From: |
Hans de Goede |
Subject: |
[PATCH parted 6/7] libparted: add ped_disk_get_partition_alignment() function |
Date: |
Fri, 30 Oct 2009 12:59:04 +0100 |
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
- [PATCH parted 5/7] libparted: add ped_device_get_xxx_aligned_constraint() functions, (continued)
Re: [PATCH parted 1/7] libparted: add ped_device_get_xxx_alignment() functions, Jim Meyering, 2009/10/29
[PATCH parted 1/7] libparted: add ped_device_get_xxx_alignment() functions, Hans de Goede, 2009/10/30