[pve-devel] [PATCH 3/9] add find_loopdev sub
Wolfgang Bumiller
w.bumiller at proxmox.com
Mon Aug 24 14:41:36 CEST 2015
Somehow I missed this before, but this looks like a generic "find key
for value" function.
If getting the first element of
grep { $hash->{$_} eq $key } keys %$hash
is too much typing work, maybe a generic find in Tools might be called
for? (The only difference to grep is that it's only looking for a single
key, while grep returns a list.)
On Sun, Aug 16, 2015 at 07:43:00PM +0200, Alexandre Derumier wrote:
> Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
> ---
> src/PVE/LXC.pm | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
> index fbdc5bb..10a89f2 100644
> --- a/src/PVE/LXC.pm
> +++ b/src/PVE/LXC.pm
> @@ -1800,4 +1800,11 @@ sub blockdevices_list {
> return $bdevs;
> }
>
> +sub find_loopdev {
> + my ($loopdevs, $path) = @_;
> +
> + foreach my $dev (keys %$loopdevs){
> + return $dev if $loopdevs->{$dev} eq $path;
> + }
> +}
> 1;
> --
> 2.1.4
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
More information about the pve-devel
mailing list