mirror of
https://git.shadowkat.net/izaya/OC-PsychOS2.git
synced 2024-11-22 12:04:20 -05:00
Compare commits
No commits in common. "265681c61c6c45fef2419aeaf854d4ade47b1ce9" and "6d96109217e1755fb2f83c8d6a52966aed7aec57" have entirely different histories.
265681c61c
...
6d96109217
@ -83,7 +83,7 @@ function shutil.df() -- Prints free disk space.
|
|||||||
local fstr = "%-"..tostring(ml).."s %5s %5s"
|
local fstr = "%-"..tostring(ml).."s %5s %5s"
|
||||||
print("fs"..(" "):rep(ml-2).." size used")
|
print("fs"..(" "):rep(ml-2).." size used")
|
||||||
for k,v in pairs(mt) do
|
for k,v in pairs(mt) do
|
||||||
local st, su = fs.spaceTotal(v.."/."), fs.spaceUsed(v.."/.")
|
local st, su = fs.spaceTotal(v), fs.spaceUsed(v)
|
||||||
print(string.format(fstr,v,wrapUnits(st),wrapUnits(su)))
|
print(string.format(fstr,v,wrapUnits(st),wrapUnits(su)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,36 +1,29 @@
|
|||||||
local fsmanager = {}
|
local fsmanager = {}
|
||||||
fsmanager.filesystems = {}
|
|
||||||
local run = true
|
|
||||||
local function mount(addr)
|
local function mount(addr)
|
||||||
dest = "/" .. (component.invoke(addr,"getLabel") or "mnt/"..addr:sub(1,3))
|
dest = component.invoke(addr,"getLabel") or "mnt/"..addr:sub(1,3)
|
||||||
|
dest = "/"..dest
|
||||||
syslog("Mounting "..addr.." to "..dest)
|
syslog("Mounting "..addr.." to "..dest)
|
||||||
fs.makeDirectory(dest)
|
fs.makeDirectory(dest)
|
||||||
local w,r = fs.mount(dest,component.proxy(addr))
|
local w,r = fs.mount(dest,component.proxy(addr))
|
||||||
if not w then
|
if not w then
|
||||||
syslog("Failed to mount: "..r)
|
syslog("Failed to mount: "..r)
|
||||||
end
|
end
|
||||||
fsmanager.filesystems[addr] = dest
|
|
||||||
end
|
end
|
||||||
for addr, _ in component.list("filesystem") do
|
for addr, _ in component.list("filesystem") do
|
||||||
mount(addr)
|
mount(addr)
|
||||||
end
|
end
|
||||||
|
|
||||||
function fsmanager.start()
|
function fsmanager.start()
|
||||||
run = true
|
|
||||||
return os.spawn(function()
|
return os.spawn(function()
|
||||||
while run do
|
while true 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])
|
mount(tE[2])
|
||||||
elseif tE[1] == "component_removed" and fsmanager.filesystems[tE[2]] and tE[3] == "filesystem" then
|
elseif tE[1] == "component_removed" and tE[3] == "filesystem" then
|
||||||
syslog("Unmounting "..tE[2].." from "..fsmanager.filesystems[tE[2]])
|
fs.umount("/mnt/"..tE[2]:sub(1,3))
|
||||||
fs.umount(fsmanager.filesystems[tE[2]])
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,"fsmanager")
|
end,"fsmanager")
|
||||||
end
|
end
|
||||||
function fsmanager.stop()
|
|
||||||
run = false
|
|
||||||
end
|
|
||||||
|
|
||||||
return fsmanager
|
return fsmanager
|
||||||
|
Loading…
Reference in New Issue
Block a user