[Libguestfs] [PATCH] inspector: Canonicalize device names (fix RHBZ#526717).
Richard W.M. Jones
rjones at redhat.com
Thu Oct 1 15:08:45 UTC 2009
This seems to be the completed fix for:
https://bugzilla.redhat.com/show_bug.cgi?id=526717
--
Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones
Read my programming blog: http://rwmj.wordpress.com
Fedora now supports 75 OCaml packages (the OPEN alternative to F#)
http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
-------------- next part --------------
>From c56f348d1f5f1f93ab7258c391e760b960a0db74 Mon Sep 17 00:00:00 2001
From: Richard Jones <rjones at trick.home.annexia.org>
Date: Thu, 1 Oct 2009 16:06:17 +0100
Subject: [PATCH] inspector: Canonicalize device names (fix RHBZ#526717).
Make filesystem device names canonical, so they are /dev/sd*
instead of /dev/vd*.
---
perl/lib/Sys/Guestfs/Lib.pm | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm
index a9868e2..068cde5 100644
--- a/perl/lib/Sys/Guestfs/Lib.pm
+++ b/perl/lib/Sys/Guestfs/Lib.pm
@@ -575,7 +575,19 @@ sub inspect_all_partitions
my $g = shift;
my $parts = shift;
my @parts = @$parts;
- return map { $_ => inspect_partition ($g, $_, @_) } @parts;
+ return map { _canonical_dev ($_) => inspect_partition ($g, $_, @_) } @parts;
+}
+
+# Turn /dev/vd* and /dev/hd* into canonical device names
+# (see BLOCK DEVICE NAMING in guestfs(3)).
+
+sub _canonical_dev
+{
+ local $_ = shift;
+
+ return "/dev/sd$1" if m{^/dev/hd(\w+)};
+ return "/dev/sd$1" if m{^/dev/vd(\w+)};
+ return $_;
}
=head2 inspect_partition
--
1.6.2.5
More information about the Libguestfs
mailing list