[PATCH 4/5] libparted: new interfaces: max start sector, max partition length

Jim Meyering meyering at redhat.com
Fri Dec 4 16:18:57 UTC 2009


* libparted/disk.c (ped_disk_max_partition_start_sector): New function.
(ped_disk_max_partition_length): New function.
* include/parted/disk.h: Declare them.
* NEWS (New features): Mention them.
---
 NEWS                  |    6 ++++++
 include/parted/disk.h |    3 +++
 libparted/disk.c      |   20 ++++++++++++++++++++
 3 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/NEWS b/NEWS
index 5241301..9a0ac2c 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,12 @@ GNU parted NEWS                                    -*- outline -*-

 ** New features

+  libparted: new functions to return per-partition-table-type limits:
+    - ped_disk_max_partition_start_sector: Return the largest representable
+    start sector number for a given "disk".
+    - ped_disk_max_partition_length: Return the maximum partition length
+    for a given "disk".
+
   new command "align-check TYPE N" to determine whether the starting sector
   of partition N is TYPE(minimal|optimal)-aligned for the disk.  E.g.,
       parted -s /dev/sda align-check min 1 && echo partition 1 is min-aligned
diff --git a/include/parted/disk.h b/include/parted/disk.h
index 3449df6..cb5d179 100644
--- a/include/parted/disk.h
+++ b/include/parted/disk.h
@@ -327,6 +327,9 @@ extern PedPartition* ped_disk_get_partition_by_sector (const PedDisk* disk,
                                                        PedSector sect);
 extern PedPartition* ped_disk_extended_partition (const PedDisk* disk);

+extern PedSector ped_disk_max_partition_length (const PedDisk *disk);
+extern PedSector ped_disk_max_partition_start_sector (const PedDisk *disk);
+
 /* internal functions */
 extern PedDisk* _ped_disk_alloc (const PedDevice* dev, const PedDiskType* type);
 extern void _ped_disk_free (PedDisk* disk);
diff --git a/libparted/disk.c b/libparted/disk.c
index 89476a7..a615d36 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -1479,6 +1479,26 @@ ped_disk_get_partition_by_sector (const PedDisk* disk, PedSector sect)
 	return NULL;
 }

+/**
+ * Return the maximum representable length (in sectors) of a
+ * partition on disk \disk.
+ */
+PedSector
+ped_disk_max_partition_length (const PedDisk* disk)
+{
+  return disk->type->ops->max_length ();
+}
+
+/**
+ * Return the maximum representable start sector of a
+ * partition on disk \disk.
+ */
+PedSector
+ped_disk_max_partition_start_sector (const PedDisk* disk)
+{
+  return disk->type->ops->max_start_sector ();
+}
+
 /* I'm beginning to agree with Sedgewick :-/ */
 static int
 _disk_raw_insert_before (PedDisk* disk, PedPartition* loc, PedPartition* part)
--
1.6.6.rc0.285.g73651




More information about the parted-devel mailing list