From 89c27ea8ab2ca77279d365231fc52552d38ff79a Mon Sep 17 00:00:00 2001 From: Fabian Ebner Date: Tue, 26 Jan 2021 12:45:22 +0100 Subject: [PATCH] Diskmanage: collect partitions in hash Signed-off-by: Fabian Ebner --- PVE/Diskmanage.pm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/PVE/Diskmanage.pm b/PVE/Diskmanage.pm index 95aba12..fbdd330 100644 --- a/PVE/Diskmanage.pm +++ b/PVE/Diskmanage.pm @@ -614,7 +614,6 @@ sub get_disks { my $db_count = 0; my $wal_count = 0; - my $found_partitions; my $found_lvm; my $found_mountpoints; my $found_zfs; @@ -626,10 +625,15 @@ sub get_disks { # e.g. from /dev/cciss/c0d0 get /dev/cciss $partpath =~ s/\/[^\/]+$//; + my $partitions = {}; + dir_glob_foreach("$sysdir", "$dev.+", sub { my ($part) = @_; - $found_partitions = 1; + $partitions->{$part}->{devpath} = "$partpath/$part"; + $partitions->{$part}->{gpt} = $data->{gpt}; + $partitions->{$part}->{size} = + get_sysdir_size("$sysdir/$part") // 0; if (my $mp = $mounted->{"$partpath/$part"}) { $found_mountpoints = 1; @@ -673,7 +677,7 @@ sub get_disks { $used = 'LVM' if $found_lvm && !$used; $used = 'ZFS' if $found_zfs && !$used; $used = 'Device Mapper' if $found_dm && !$used; - $used = 'partitions' if $found_partitions && !$used; + $used = 'partitions' if scalar(keys %{$partitions}) && !$used; # multipath, software raid, etc. # this check comes in last, to show more specific info -- 2.39.5