From bf6ea125577dccdb18cab635eda1fb79cd98e0d5 Mon Sep 17 00:00:00 2001 From: Richard Jones 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 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm index a9868e2..8ea2c1b 100644 --- a/perl/lib/Sys/Guestfs/Lib.pm +++ b/perl/lib/Sys/Guestfs/Lib.pm @@ -569,13 +569,23 @@ C flag are explained below. =cut +# Turn /dev/vd* and /dev/hd* into canonical device names +# (see BLOCK DEVICE NAMING in guestfs(3)). + +sub _canonical_dev ($) +{ + my ($dev) = @_; + return "/dev/sd$1" if $dev =~ m{^/dev/[vh]d(\w+)}; + return $dev; +} + sub inspect_all_partitions { local $_; my $g = shift; my $parts = shift; my @parts = @$parts; - return map { $_ => inspect_partition ($g, $_, @_) } @parts; + return map { _canonical_dev ($_) => inspect_partition ($g, $_, @_) } @parts; } =head2 inspect_partition -- 1.8.3.1