From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <f.gruenbichler@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id AE7466A6A7
 for <pve-devel@lists.proxmox.com>; Mon, 15 Mar 2021 10:26:31 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id A4E8B1E5BE
 for <pve-devel@lists.proxmox.com>; Mon, 15 Mar 2021 10:26:01 +0100 (CET)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [212.186.127.180])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS id EF97C1E5B4
 for <pve-devel@lists.proxmox.com>; Mon, 15 Mar 2021 10:26:00 +0100 (CET)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id B95864259C
 for <pve-devel@lists.proxmox.com>; Mon, 15 Mar 2021 10:26:00 +0100 (CET)
Date: Mon, 15 Mar 2021 10:25:54 +0100
From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= <f.gruenbichler@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
References: <20210309104318.317454-1-d.jaeger@proxmox.com>
In-Reply-To: <<20210309104318.317454-1-d.jaeger@proxmox.com>
MIME-Version: 1.0
User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid)
Message-Id: <1615546537.wzwar6nrpb.astroid@nora.none>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.027 Adjusted score from AWL reputation of From: address
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 RCVD_IN_DNSWL_MED        -2.3 Sender listed at https://www.dnswl.org/,
 medium trust
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: Re: [pve-devel] [PATCH v6 storage] Optionally allow blockdev in
 abs_filesystem_path
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Mon, 15 Mar 2021 09:26:31 -0000

On March 9, 2021 11:43 am, Dominic J=C3=A4ger wrote:
> This is required to import from LVM storages
>=20
> Signed-off-by: Dominic J=C3=A4ger <d.jaeger@proxmox.com>
> ---
> v5->v6: unchanged
>=20
>  PVE/Storage.pm | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>=20
> diff --git a/PVE/Storage.pm b/PVE/Storage.pm
> index 8ee2c92..7c2e24e 100755
> --- a/PVE/Storage.pm
> +++ b/PVE/Storage.pm
> @@ -609,7 +609,7 @@ sub path {
>  }
> =20
>  sub abs_filesystem_path {
> -    my ($cfg, $volid) =3D @_;
> +    my ($cfg, $volid, $allowBlockdev) =3D @_;

that's not how we name perl variables..

> =20
>      my $path;
>      if (parse_volume_id ($volid, 1)) {
> @@ -623,8 +623,11 @@ sub abs_filesystem_path {
>  	    }
>  	}
>      }
> -
> -    die "can't find file '$volid'\n" if !($path && -f $path);
> +    if ($allowBlockdev) {
> +	die "can't find file '$volid'\n" if !($path && (-f $path || -b $path));
> +    } else {
> +	die "can't find file '$volid'\n" if !($path && -f $path);
> +    }

this could easily still be a single if:

    die "can't find file '$volid'\n"
      if !($path && -f $path) && !($path && $allow_block_dev && -b $path);

or some other transformation of the condition, like

  if !$path || !(-f $path || ($allow_block_dev && -b $path))

or

  if !($path && (-f $path || ($allow_block_dev && -b $path)))

> =20
>      return $path;
>  }
> --=20
> 2.20.1
>=20
>=20
> _______________________________________________
> pve-devel mailing list
> pve-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>=20
=