[Libguestfs] [PATCH] inspector: Canonicalize device names (fix RHBZ#526717).

Richard W.M. Jones rjones at redhat.com
Thu Oct 1 16:14:27 UTC 2009


On Thu, Oct 01, 2009 at 05:26:10PM +0200, Jim Meyering wrote:
> sub _canonical_dev ($)
> {
>     my ($dev) = @_;
>     $dev =~ m{^/dev/[vh]d(\w+)}
>       and $dev = "/dev/sd$1";
>     return $dev;
> }
> 
> Also, I find that not using $_ (even when declared local)
> improves maintainability.
> 
> Finally, you can combine those two matches into one.

Thanks.  This is what I will commit:

+sub _canonical_dev ($)
+{
+    my ($dev) = @_;
+    return "/dev/sd$1" if $dev =~ m{^/dev/[vh]d(\w+)};
+    return $dev;
+}

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://et.redhat.com/~rjones/virt-df/




More information about the Libguestfs mailing list