partman will now attempt to mount filesystems, making rtfsman redundant. updated package.cfgs to reflect that.

This commit is contained in:
Izaya 2023-10-01 13:49:06 +10:00
parent 45bf02a843
commit 99f0449eb1
5 changed files with 28 additions and 50 deletions

View File

@ -1,4 +1,4 @@
{["name"]="partman",
["description"]="Partition vcomponent management daemon",
["authors"]="Izaya",
["dependencies"]={"vcomponent"}}
["dependencies"]={"vcomponent", "diskpart"}}

View File

@ -1,13 +1,32 @@
local diskpart = require "diskpart"
local vcomponent = require "vcomponent"
local partman = {}
partman.fstypes = {"rtfs"}
local run = true
local function attach(addr)
local function attachPartition(addr)
syslog("Finding filesystem that will mount "..addr)
for _,n in ipairs(partman.fstypes) do
local w,l = pcall(require,string.format("fs.%s",n))
if w then
syslog("Trying "..n)
local w, f = pcall(l.mount,addr)
if w then
syslog(n.." successful!")
vcomponent.register(string.format("%s/%s",addr,n), "filesystem",f)
break
end
end
end
end
local function attachDrive(addr)
for k,v in ipairs(diskpart.getPartitions(addr)) do
if v[4] > 0 then
syslog(string.format("Registering vcomponent for partition %s/%i",addr,k))
vcomponent.register(string.format("%s/%i",addr,k), "partition", diskpart.proxyPartition(addr, k))
syslog("Attempting to mount a filesystem...")
attachPartition(string.format("%s/%i",addr,k))
end
end
end
@ -16,16 +35,16 @@ function partman.start()
run = true
os.spawn(function()
for a,_ in component.list("drive") do
attach(a)
attachDrive(a)
end
while run do
local tE = {coroutine.yield()}
if tE[1] == "component_added" and tE[3] == "drive" then
attach(tE[2])
attachDrive(tE[2])
elseif tE[1] == "component_removed" and tE[3] == "drive" then
for a,t in component.list("partition") do
if a:sub(1,tE[2]:len()) == tE[2] then
syslog("Removing partition vcomponent "..a)
for a,t in component.list() do
if (t == "partition" or t == "filesystem") and a:sub(1,tE[2]:len()) == tE[2] then
syslog("Removing "..t.." vcomponent "..a)
vcomponent.unregister(a)
end
end

View File

@ -1,3 +1,4 @@
{["name"]="rtfs-v0",
["description"]="RT-11 filesystem clone",
["authors"]="Izaya"}
["authors"]="Izaya",
["dependencies"]={"rtfs"}}

View File

@ -1,4 +0,0 @@
{["name"]="rtfsman",
["description"]="rtfs auto-attach daemon",
["authors"]="Izaya",
["dependencies"]={"vcomponent"}}

View File

@ -1,38 +0,0 @@
local vcomponent = require "vcomponent"
local rtfs = require "rtfs"
local rtfsman = {}
rtfsman.filesystems = {}
local run = true
local function attach(addr)
local w, e = pcall(rtfs.mount,component.proxy(addr))
if w then
syslog("rtfs filesystem found on " .. addr)
rtfsman.filesystems[addr] = true
vcomponent.register(addr .. "/rtfs", "filesystem", e)
end
end
function rtfsman.start()
run = true
return os.spawn(function()
for a,_ in component.list("partition") do
attach(a)
end
while run do
local tE = {coroutine.yield()}
if tE[1] == "component_added" and tE[3] == "partition" then
attach(tE[2])
elseif tE[1] == "component_removed" and rtfsman.filesystems[tE[2]] and tE[3] == "partition" then
syslog("Un-registering rtfs filesystem on " .. tE[2])
vcomponent.unregister(tE[2] .. "/rtfs")
rtfsman.filesystems[tE[2]] = nil
end
end
end,"rtfs-manager")
end
function rtfsman.stop()
run = false
end
return rtfsman