diff --git a/partman/package.cfg b/partman/package.cfg index 05c7480..d6a8725 100644 --- a/partman/package.cfg +++ b/partman/package.cfg @@ -1,4 +1,4 @@ {["name"]="partman", ["description"]="Partition vcomponent management daemon", ["authors"]="Izaya", - ["dependencies"]={"vcomponent"}} + ["dependencies"]={"vcomponent", "diskpart"}} diff --git a/partman/service/partman.lua b/partman/service/partman.lua index d1ddb42..14eac8c 100644 --- a/partman/service/partman.lua +++ b/partman/service/partman.lua @@ -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 diff --git a/rtfs-v0/package.cfg b/rtfs-v0/package.cfg index f43856e..a6256d5 100644 --- a/rtfs-v0/package.cfg +++ b/rtfs-v0/package.cfg @@ -1,3 +1,4 @@ {["name"]="rtfs-v0", ["description"]="RT-11 filesystem clone", - ["authors"]="Izaya"} + ["authors"]="Izaya", + ["dependencies"]={"rtfs"}} diff --git a/rtfsman/package.cfg b/rtfsman/package.cfg deleted file mode 100644 index 155575f..0000000 --- a/rtfsman/package.cfg +++ /dev/null @@ -1,4 +0,0 @@ -{["name"]="rtfsman", - ["description"]="rtfs auto-attach daemon", - ["authors"]="Izaya", - ["dependencies"]={"vcomponent"}} diff --git a/rtfsman/service/rtfsman.lua b/rtfsman/service/rtfsman.lua deleted file mode 100644 index b8624ca..0000000 --- a/rtfsman/service/rtfsman.lua +++ /dev/null @@ -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