1
1
mirror of https://git.shadowkat.net/izaya/OC-PsychOS2.git synced 2024-11-25 12:42:10 -05:00

Compare commits

..

5 Commits

Author SHA1 Message Date
XeonSquared
026f2524e6 this one works, I tested it 2023-08-07 13:26:42 +10:00
XeonSquared
e20123b527 clean up print tabbing 2023-08-07 13:26:20 +10:00
XeonSquared
efdb01328f I don't know why it was looking at package.loaded but it isn't now. 2023-08-07 13:25:57 +10:00
XeonSquared
a05e19b545 I'm stupid sometimes 2023-08-07 12:56:59 +10:00
XeonSquared
00d4472f91 make fsmanager's mount function externally accessible 2023-08-07 12:54:25 +10:00
3 changed files with 6 additions and 5 deletions

View File

@ -24,7 +24,7 @@ local function saveConfig()
end end
function rc.load(name,force) -- string boolean -- table -- Attempts to load service *name*, and if *force* is true, replaces the current instance. function rc.load(name,force) -- string boolean -- table -- Attempts to load service *name*, and if *force* is true, replaces the current instance.
if not package.loaded[name] or force then if not service[name] or force then
for d in rc.paths:gmatch("[^\n]+") do for d in rc.paths:gmatch("[^\n]+") do
if fs.exists(d.."/"..name..".lua") then if fs.exists(d.."/"..name..".lua") then
service[name] = runfile(d.."/"..name..".lua") service[name] = runfile(d.."/"..name..".lua")

View File

@ -34,7 +34,7 @@ end
function print(...) -- Writes each argument to the default output stream, separated by space. function print(...) -- Writes each argument to the default output stream, separated by space.
for k,v in ipairs({...}) do for k,v in ipairs({...}) do
io.write(tostring(v).."\t") io.write((k>1 and "\t" or "")..tostring(v))
end end
io.write("\n") io.write("\n")
end end

View File

@ -1,7 +1,8 @@
local fsmanager = {} local fsmanager = {}
fsmanager.filesystems = {} fsmanager.filesystems = {}
local run = true local run = true
local function mount(addr)
function fsmanager.mount(addr)
dest = "/" .. (component.invoke(addr,"getLabel") or "mnt/"..addr:sub(1,3)) dest = "/" .. (component.invoke(addr,"getLabel") or "mnt/"..addr:sub(1,3))
syslog("Mounting "..addr.." to "..dest) syslog("Mounting "..addr.." to "..dest)
fs.makeDirectory(dest) fs.makeDirectory(dest)
@ -17,12 +18,12 @@ function fsmanager.start()
run = true run = true
return os.spawn(function() return os.spawn(function()
for addr, _ in component.list("filesystem") do for addr, _ in component.list("filesystem") do
mount(addr) fsmanager.mount(addr)
end end
while run do while run do
local tE = {coroutine.yield()} local tE = {coroutine.yield()}
if tE[1] == "component_added" and tE[3] == "filesystem" then 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 elseif tE[1] == "component_removed" and fsmanager.filesystems[tE[2]] and tE[3] == "filesystem" then
syslog("Unmounting "..tE[2].." from "..fsmanager.filesystems[tE[2]]) syslog("Unmounting "..tE[2].." from "..fsmanager.filesystems[tE[2]])
fs.umount(fsmanager.filesystems[tE[2]]) fs.umount(fsmanager.filesystems[tE[2]])