[libvirt] [PATCH] Fix enumeration of partitions in disks with a trailing digit in path
Eric Blake
eblake at redhat.com
Mon Jun 14 18:15:27 UTC 2010
On 06/08/2010 11:27 AM, Daniel P. Berrange wrote:
> Disks with a trailing digit in their path (eg /dev/loop0 or
> /dev/dm0) have an extra 'p' appended before the partition
> number (eg, to form /dev/loop0p1 not /dev/loop01). Fix the
> partition lookup to append this extra 'p' when required
>
> * src/storage/parthelper.c: Add a 'p' before partition
> number if required
> ---
> src/storage/parthelper.c | 15 +++++++++++----
> 1 files changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/src/storage/parthelper.c b/src/storage/parthelper.c
> index 5626cd2..28d88c9 100644
> --- a/src/storage/parthelper.c
> +++ b/src/storage/parthelper.c
> @@ -36,6 +36,8 @@
> #include <stdio.h>
> #include <string.h>
>
> +#include "c-ctype.h"
> +
...
>
> - if ((dev = ped_device_get(argv[1])) == NULL) {
> - fprintf(stderr, "unable to access device %s\n", argv[1]);
> + path = argv[1];
> + partsep = c_isdigit(path[strlen(path)-1]) ? "p" : "";
If using gcc and -O, this works just fine (c_isdigit is a macro in that
case). But if you set CFLAGS=-g, with no optimization (or if you don't
use gcc), then this results in a link error:
libvirt_parthelper-parthelper.o: In function `main':
/home/remote/eblake/libvirt/src/storage/parthelper.c:72: undefined
reference to `c_isdigit'
I'm working on a followup patch, because it is (sometimes) necessary to
link in -lgnulib when building parthelper.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100614/1c27b53a/attachment-0001.sig>
More information about the libvir-list
mailing list