Optionally allow blockdev in abs_filesystem_path

This is required to import from LVM storages, for example

Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
This commit is contained in:
Dominic Jäger
2021-03-26 13:32:25 +01:00
committed by Thomas Lamprecht
parent 342a56805c
commit 4b84ad5e25

View File

@ -609,22 +609,22 @@ sub path {
} }
sub abs_filesystem_path { sub abs_filesystem_path {
my ($cfg, $volid) = @_; my ($cfg, $volid, $allow_blockdev) = @_;
my $path; my $path;
if (parse_volume_id ($volid, 1)) { if (parse_volume_id ($volid, 1)) {
activate_volumes($cfg, [ $volid ]); activate_volumes($cfg, [ $volid ]);
$path = PVE::Storage::path($cfg, $volid); $path = PVE::Storage::path($cfg, $volid);
} else { } else {
if (-f $volid) { if (-f $volid || ($allow_blockdev && -b $volid)) {
my $abspath = abs_path($volid); my $abspath = abs_path($volid);
if ($abspath && $abspath =~ m|^(/.+)$|) { if ($abspath && $abspath =~ m|^(/.+)$|) {
$path = $1; # untaint any path $path = $1; # untaint any path
} }
} }
} }
die "can't find file '$volid'\n"
die "can't find file '$volid'\n" if !($path && -f $path); if !($path && (-f $path || ($allow_blockdev && -b $path)));
return $path; return $path;
} }