]> git.proxmox.com Git - pve-storage.git/commitdiff
diskmanage: get_partnum: fix check
authorFabian Ebner <f.ebner@proxmox.com>
Tue, 20 Apr 2021 12:07:50 +0000 (14:07 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 20 Apr 2021 16:13:18 +0000 (18:13 +0200)
Not replacing it with return, because the current behavior is dying:
    Can't "next" outside a loop block
and the single existing caller in pve-manager's API2/Ceph/OSD.pm does not check
the return value.

Also check for $st, which can be undefined in case a non-existing path was
provided. This also led to dying previously:
    Can't call method "mode" on an undefined value

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
PVE/Diskmanage.pm

index 853d333ddf48cf12ed369661527a3687d70f67cb..b916d2efc0a74f2980bbffe434ef9225e1b8368c 100644 (file)
@@ -750,7 +750,9 @@ sub get_partnum {
 
     my $st = stat($part_path);
 
-    next if !$st->mode || !S_ISBLK($st->mode) || !$st->rdev;
+    die "error detecting block device '$part_path'\n"
+       if !$st || !$st->mode || !S_ISBLK($st->mode) || !$st->rdev;
+
     my $major = PVE::Tools::dev_t_major($st->rdev);
     my $minor = PVE::Tools::dev_t_minor($st->rdev);
     my $partnum_path = "/sys/dev/block/$major:$minor/";