* [pve-devel] [PATCH storage] diskmanage: get_partnum: fix check
@ 2021-04-20 12:07 Fabian Ebner
2021-04-20 16:13 ` [pve-devel] applied: " Thomas Lamprecht
0 siblings, 1 reply; 2+ messages in thread
From: Fabian Ebner @ 2021-04-20 12:07 UTC (permalink / raw)
To: pve-devel
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 | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/PVE/Diskmanage.pm b/PVE/Diskmanage.pm
index 853d333..b916d2e 100644
--- a/PVE/Diskmanage.pm
+++ b/PVE/Diskmanage.pm
@@ -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/";
--
2.20.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [pve-devel] applied: [PATCH storage] diskmanage: get_partnum: fix check
2021-04-20 12:07 [pve-devel] [PATCH storage] diskmanage: get_partnum: fix check Fabian Ebner
@ 2021-04-20 16:13 ` Thomas Lamprecht
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2021-04-20 16:13 UTC (permalink / raw)
To: Proxmox VE development discussion, Fabian Ebner
On 20.04.21 14:07, Fabian Ebner wrote:
> 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 | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
>
applied, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-04-20 16:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-20 12:07 [pve-devel] [PATCH storage] diskmanage: get_partnum: fix check Fabian Ebner
2021-04-20 16:13 ` [pve-devel] applied: " Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox