[Libguestfs] [PATCH 1/2] daemon: Fix part-to-dev when the partition name includes p<N>.

Pino Toscano ptoscano at redhat.com
Thu Jan 19 11:27:11 UTC 2017


On Thursday, 19 January 2017 11:24:36 CET Richard W.M. Jones wrote:
> From: Pino Toscano <ptoscano at redhat.com>
> 
> If the device name ends with a number, Linux uses partition names of
> the form <device>p<N>.  Handle this case by knocking off the 'p'
> character.
> ---
>  daemon/devsparts.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/daemon/devsparts.c b/daemon/devsparts.c
> index 5862ae2..b764f63 100644
> --- a/daemon/devsparts.c
> +++ b/daemon/devsparts.c
> @@ -203,6 +203,9 @@ do_part_to_dev (const char *part)
>      return NULL;
>    }
>  

Can you please add here a small comment for the if that follow? I.e.
something like:

 /* Deal with <device>p<N> partition names. */

> +  if (part[n-1] == 'p')
> +    n--;
> +
>    char *r = strndup (part, n);
>    if (r == NULL) {
>      reply_with_perror ("strdup");
> 

LGTM with the small addition above.

Thanks,
-- 
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20170119/3f0f776a/attachment.sig>


More information about the Libguestfs mailing list