X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=perl%2Flib%2FSys%2FGuestfs%2FLib.pm;h=549916f50a4c6cb1618a5f66bffe98fb0f5e8395;hb=3e70b34eed5a48640e20fbf6dcba774aaace1f3c;hp=dfa79afc1fe147d556817f93cc358dba10cb23ac;hpb=569989b7505be8e1ad556fed02805acbf38d1188;p=libguestfs.git diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm index dfa79af..549916f 100644 --- a/perl/lib/Sys/Guestfs/Lib.pm +++ b/perl/lib/Sys/Guestfs/Lib.pm @@ -100,7 +100,7 @@ read-write handle, this function will refuse to use active libvirt domains. The handle is still in the config state when it is returned, so you -have to call C<$g-Elaunch ()> and C<$g-Ewait_ready>. +have to call C<$g-Elaunch ()>. The optional C
parameter can be added to specify the libvirt URI. In addition, L lists other parameters which are @@ -267,38 +267,12 @@ by C characters. Do not use C<\>, drive names, etc. sub resolve_windows_path { - local $_; my $g = shift; my $path = shift; - if (substr ($path, 0, 1) ne "/") { - warn __"resolve_windows_path: path must start with a / character"; - return undef; - } - - my @elems = split (/\//, $path); - shift @elems; - - # Start reconstructing the path at the top. - $path = "/"; - - foreach my $dir (@elems) { - my $found = 0; - foreach ($g->ls ($path)) { - if (lc ($_) eq lc ($dir)) { - if ($path eq "/") { - $path = "/$_"; - $found = 1; - } else { - $path = "$path/$_"; - $found = 1; - } - } - } - return undef unless $found; - } - - return $path; + my $r; + eval { $r = $g->case_sensitive_path ($path); }; + return $r; } =head2 file_architecture @@ -569,13 +543,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 @@ -1558,12 +1542,8 @@ sub _check_for_kernels # Check the kernel was recognised if(defined($kernel)) { # Put this kernel on the top level kernel list - my $kernels = $os->{kernels}; - if(!defined($kernels)) { - $kernels = []; - $os->{kernels} = $kernels; - } - push(@$kernels, $kernel); + $os->{kernels} ||= []; + push(@{$os->{kernels}}, $kernel); $config{kernel} = $kernel; @@ -1766,13 +1746,8 @@ sub _inspect_initrd } # Add to the top level initrd_modules entry - my $initrd_modules = $os->{initrd_modules}; - if(!defined($initrd_modules)) { - $initrd_modules = {}; - $os->{initrd_modules} = $initrd_modules; - } - - $initrd_modules->{$version} = \@modules; + $os->{initrd_modules} ||= {}; + $os->{initrd_modules}->{$version} = \@modules; return \@modules; }