[parted-devel] [patch] Use 'p' partition separator only when necessary

Jim Meyering jim at meyering.net
Fri Mar 11 21:04:15 UTC 2011


Phillip Susi wrote:

> Device mapper type should not automatically mean add 'p'
> before the partition number.  Fall back to adding it only
> if the previous character is a digit.  This compilies
> with kpartx behavior.
>
> Index: parted/libparted/arch/linux.c
> ===================================================================
> --- parted.orig/libparted/arch/linux.c	2011-03-04 21:17:20.481991942 -0500
> +++ parted/libparted/arch/linux.c	2011-03-04 21:17:36.681991907 -0500
> @@ -2215,7 +2215,6 @@
>          } else if (dev->type == PED_DEVICE_DAC960
>                          || dev->type == PED_DEVICE_CPQARRAY
>                          || dev->type == PED_DEVICE_ATARAID
> -                        || dev->type == PED_DEVICE_DM
>                          || isdigit (dev->path[path_len - 1]))
>                  snprintf (result, result_len, "%sp%d", dev->path, num);
>          else
> @@ -2735,7 +2734,11 @@
>
>          dev_name = dm_task_get_name (task);
>
> -        if (asprintf (&vol_name, "%sp%d", dev_name, part->num) == -1)
> +        if (isdigit(dev_name[strlen(dev_name)-1]))
> +        {
> +                if (asprintf (&vol_name, "%sp%d", dev_name, part->num) == -1)
> +                        goto err;
> +        } else if (asprintf (&vol_name, "%s%d", dev_name, part->num) == -1)
>                  goto err;
>
>          /* Caution: dm_task_destroy frees dev_name.  */

Thanks for the patch.

This sounds like a good change.
However, can you give a little more detail?
Does parted's current behavior induce failure in some other tool?
What's the motivation?

And especially, can you write a test for it, or at least
outline a quick procedure for demonstrating how this changes
parted's behavior (in which case I'll write it)?



More information about the parted-devel mailing list