OC-PsychOS/modules/util/fs-automount.lua

42 lines
1.3 KiB
Lua
Raw Normal View History

do
local C=0
for c in component.list("filesystem") do
if c == computer.tmpAddress() then
fs.mount("tmp",component.proxy(c))
print(c:sub(1,8).." mounted as tmp")
end
if c == computer.getBootAddress() then
fs.mount("boot",component.proxy(c))
print(c:sub(1,8).." mounted as boot")
end
if component.invoke(c,"getLabel") ~= "" and component.invoke(c,"getLabel") ~= nil then
fs.mount(component.invoke(c,"getLabel"),component.proxy(c))
print(c:sub(1,8).." mounted as "..component.invoke(c,"getLabel"))
end
fs.mount("fs"..string.format("%02d",C),component.proxy(c))
print(c:sub(1,8).." mounted as fs"..string.format("%02d",C))
C=C+1
end
if component.type(computer.getBootAddress()) == "tape_drive" then
fs.mount("boot",component.proxy(computer.tmpAddress()))
print(computer.tmpAddress():sub(1,8).." mounted as boot")
if tape then
tape.rewind()
local pt = tape.records()
for k,v in ipairs(pt) do
if v[1] == "D" then
print(tostring(k).."\t"..v[1].."\t/boot/"..tape.rrecord(k))
fs.mkdir("/boot/"..tape.rrecord(k))
elseif v[1] == "f" then
local fn,fc = tape.parsefile(tape.rrecord(k))
print(tostring(k).."\t"..v[1].."\t/boot/"..fn)
local f=io.open("/boot/"..fn,"wb")
f:write(fc)
f:close()
end
computer.beep()
end
end
end
end