
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@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org