]> git.proxmox.com Git - pve-storage.git/commitdiff
api: disks: initgpt: explicitly abort for partitions
authorFabian Ebner <f.ebner@proxmox.com>
Wed, 6 Oct 2021 09:18:44 +0000 (11:18 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 7 Oct 2021 12:39:26 +0000 (14:39 +0200)
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 <f.ebner@proxmox.com>
PVE/API2/Disks.pm
PVE/Diskmanage.pm

index 96c19fd72964ae48b310809b439aa1c559b8e6b4..25c9ded4eb7a273beaf0631cb8af92e40ce36742 100644 (file)
@@ -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});
index c896c5ab3a0e26a2b036e9d8bff6c89cb2e24066..f0e14dc5f3a3e6b38c7f6e0ba6679b361b92fcfd 100644 (file)
@@ -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';