From: Fabian Ebner Date: Wed, 6 Oct 2021 09:18:44 +0000 (+0200) Subject: api: disks: initgpt: explicitly abort for partitions X-Git-Url: https://git.proxmox.com/?p=pve-storage.git;a=commitdiff_plain;h=cc884f73d8527722df56f11acb3eced13cd4f2e4 api: disks: initgpt: explicitly abort for partitions In preparation to extend disk_is_used to support partitions. Without this new check, initgpt would also allow partitions once disk_is_used supports partitions, which is not desirable. Signed-off-by: Fabian Ebner --- diff --git a/PVE/API2/Disks.pm b/PVE/API2/Disks.pm index 96c19fd..25c9ded 100644 --- a/PVE/API2/Disks.pm +++ b/PVE/API2/Disks.pm @@ -260,6 +260,7 @@ __PACKAGE__->register_method ({ my $authuser = $rpcenv->get_user(); + die "$disk is a partition\n" if PVE::Diskmanage::is_partition($disk); die "disk $disk already in use\n" if PVE::Diskmanage::disk_is_used($disk); my $worker = sub { PVE::Diskmanage::init_disk($disk, $param->{uuid}); diff --git a/PVE/Diskmanage.pm b/PVE/Diskmanage.pm index c896c5a..f0e14dc 100644 --- a/PVE/Diskmanage.pm +++ b/PVE/Diskmanage.pm @@ -63,8 +63,8 @@ sub init_disk { assert_blockdev($disk); - # we should already have checked if it is in use in the api call - # but we check again for safety + # we should already have checked these in the api call, but we check again for safety + die "$disk is a partition\n" if is_partition($disk); die "disk $disk is already in use\n" if disk_is_used($disk); my $id = $uuid || 'R';