]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Diskmanage.pm
refactor disk/storage checks for Disk API
[pve-storage.git] / PVE / Diskmanage.pm
index 23e5b13ecce0a1d1bd2104ebf26973f0f9822288..5a5fc87799fc767406fadac086391352d39c2b4a 100644 (file)
@@ -595,4 +595,19 @@ sub get_blockdev {
     return $block_dev;
 }
 
+sub locked_disk_action {
+    my ($sub) = @_;
+    my $res = PVE::Tools::lock_file('/run/lock/pve-diskmanage.lck', undef, $sub);
+    die $@ if $@;
+    return $res;
+}
+
+sub check_unused {
+    my ($dev) = @_;
+
+    die "device $dev is already in use\n" if disk_is_used($dev);
+
+    return undef;
+}
+
 1;