[parted-devel] [PATCH 3/4] Make sure we always create msdos metadata parts.
Jim Meyering
jim at meyering.net
Tue May 26 11:44:33 UTC 2009
Joel Granados Moreno wrote:
> From: Joel Andres Granados <jgranado at redhat.com>
>
> If disks did not contain any partitions, parted did not create metadata
> partitions for msdos labels. This lead to inconsistencies when
> reporting free space partition ranges. This patch addresses this issue.
>
> * libparted/labels/dos.c (get_last_part): Erased this function.
> * libparted/labels/dos.c (get_start_first_nonfree_part): New function to
> find the start sector of the first non-free partition in disk.
> * libparted/labels/dos.c (get_end_last_nonfree_part): New function to
> find the end sector of the last non-free partition in disk.
> * libparted/lables/dos.c (add_startend_metadata): Added code that
> handles disks no partitions. Added check that prevents the metadata
> partitions from being greater than the device length. Added check
> that prevents metadata partitions from overlapping in small devs.
...
Hi Joel,
Thanks for posting this series.
1 and 2 look ok. This one (3/4) required a description for each of the
two new functions (added below), plus I've made small syntax adjustments.
I'm about to amend your #3 with the patch below.
Once I get past #4 (new version coming?) and test, I'll push the series.
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
index f724722..f219e7d 100644
--- a/libparted/labels/dos.c
+++ b/libparted/labels/dos.c
@@ -2082,10 +2082,12 @@ add_logical_part_metadata (PedDisk* disk, const PedPartition* log_part)
}
/*
- * return 0 if we don't asign sector
+ * Find the starting sector number of the first non-free partition,
+ * set *SECTOR to that value, and return 1.
+ * If there is no non-free partition, don't modify *SECTOR and return 0.
*/
static int
-get_start_first_nonfree_part(const PedDisk* disk, PedSector *sector)
+get_start_first_nonfree_part (const PedDisk* disk, PedSector *sector)
{
PedPartition* walk;
@@ -2093,20 +2095,23 @@ get_start_first_nonfree_part(const PedDisk* disk, PedSector *sector)
if (!disk->part_list)
return 0;
- for (walk = disk->part_list; walk; walk = walk->next)
+ for (walk = disk->part_list; walk; walk = walk->next) {
if (walk->type == PED_PARTITION_NORMAL ||
- walk->type == PED_PARTITION_EXTENDED){
+ walk->type == PED_PARTITION_EXTENDED) {
*sector = walk->geom.start;
return 1;
}
+ }
return 0;
}
/*
- * return 0 if we don't asign sector
+ * Find the ending sector number of the last non-free partition,
+ * set *SECTOR to that value, and return 1.
+ * If there is no non-free partition, don't modify *SECTOR and return 0.
*/
static int
-get_end_last_nonfree_part(const PedDisk* disk, PedSector *sector)
+get_end_last_nonfree_part (const PedDisk* disk, PedSector *sector)
{
PedPartition* last_part = NULL;
PedPartition* walk;
@@ -2115,15 +2120,16 @@ get_end_last_nonfree_part(const PedDisk* disk, PedSector *sector)
if (!disk->part_list)
return 0;
- for (walk = disk->part_list; walk; walk = walk->next)
+ for (walk = disk->part_list; walk; walk = walk->next) {
if (walk->type == PED_PARTITION_NORMAL ||
- walk->type == PED_PARTITION_EXTENDED){
+ walk->type == PED_PARTITION_EXTENDED) {
last_part = walk;
}
+ }
if (!last_part)
return 0;
- else{
+ else {
*sector = last_part->geom.end;
return 1;
}
More information about the parted-devel
mailing list