sfdisk: accept empty partitions from dump
Old sfdisk uses: dev/sdc2 : start= 0, size= 0, Id= 0 for undefined MBR partitions. Let's follow this behaviour. Reported-by: Ruediger Meier <sweet_f_a@gmx.de> Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
1d2dfb9c30
commit
2928068a3c
|
@ -1120,6 +1120,22 @@ static char *sfdisk_fgets(struct fdisk_script *dp,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static int ignore_partition(struct fdisk_partition *pa)
|
||||||
|
{
|
||||||
|
/* incomplete partition setting */
|
||||||
|
if (!fdisk_partition_has_start(pa) && !fdisk_partition_start_is_default(pa))
|
||||||
|
return 1;
|
||||||
|
if (!fdisk_partition_has_size(pa) && !fdisk_partition_end_is_default(pa))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* probably dump from old sfdisk with start=0 size=0 */
|
||||||
|
if (fdisk_partition_has_start(pa) && fdisk_partition_get_start(pa) == 0 &&
|
||||||
|
fdisk_partition_has_size(pa) && fdisk_partition_get_size(pa) == 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* sfdisk <device> [[-N] <partno>]
|
* sfdisk <device> [[-N] <partno>]
|
||||||
*
|
*
|
||||||
|
@ -1301,9 +1317,9 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv)
|
||||||
|
|
||||||
assert(pa);
|
assert(pa);
|
||||||
|
|
||||||
if (!fdisk_partition_has_start(pa) &&
|
if (ignore_partition(pa)) {
|
||||||
!fdisk_partition_start_is_default(pa)) {
|
fdisk_info(sf->cxt, _("Ignoring partition."));
|
||||||
fdisk_info(sf->cxt, _("Ignoring partition %zu."), next_partno + 1);
|
next_partno++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!created) { /* create a new disklabel */
|
if (!created) { /* create a new disklabel */
|
||||||
|
|
Loading…
Reference in New Issue