make fsmanager's mount function externally accessible

This commit is contained in:
Izaya 2023-08-07 12:54:25 +10:00
parent 82decfabf9
commit 00d4472f91
1 changed files with 3 additions and 2 deletions

View File

@ -1,7 +1,8 @@
local fsmanager = {}
fsmanager.filesystems = {}
local run = true
local function mount(addr)
local function fsmanager.mount(addr)
dest = "/" .. (component.invoke(addr,"getLabel") or "mnt/"..addr:sub(1,3))
syslog("Mounting "..addr.." to "..dest)
fs.makeDirectory(dest)
@ -22,7 +23,7 @@ function fsmanager.start()
while run do
local tE = {coroutine.yield()}
if tE[1] == "component_added" and tE[3] == "filesystem" then
mount(tE[2])
fsmanager.mount(tE[2])
elseif tE[1] == "component_removed" and fsmanager.filesystems[tE[2]] and tE[3] == "filesystem" then
syslog("Unmounting "..tE[2].." from "..fsmanager.filesystems[tE[2]])
fs.umount(fsmanager.filesystems[tE[2]])