make partman handle tape drives again, and support extension in future maybe

This commit is contained in:
Izaya 2023-11-12 23:21:50 +10:00
parent ac23911d6d
commit 3d99efded9

View File

@ -1,11 +1,16 @@
local diskpart = require "diskpart"
local vcomponent = require "vcomponent"
local partman = {}
local partman = {
dtypes={
drive=true,
["tape_drive"]=true
}
}
local hooks = {}
function hooks.component_added(_,a,t)
if t ~= "drive" then return end
if not partman.dtypes[t] then return end
for k,v in ipairs(diskpart.getPartitions(a)) do
if v[4] > 0 then
syslog(string.format("Registering vcomponent for partition %s/%i",a,k))
@ -23,7 +28,7 @@ function hooks.component_added(_,a,t)
end
function hooks.component_removed(_,a,t)
if t ~= "drive" then return end
if not partman.dtypes[t] then return end
for ca,t in component.list() do
if (t == "partition" or t == "filesystem") and ca:sub(1,a:len()) == a then
vcomponent.unregister(ca)