Compare commits
No commits in common. "256e05233a2e0e958caa3a168a60c49acfaa91e5" and "a97e3c93ee727ef100d9ea4846530537f89367b4" have entirely different histories.
256e05233a
...
a97e3c93ee
@ -1,2 +1 @@
|
||||
getty.lua
|
||||
fsmanager.lua
|
||||
|
@ -97,16 +97,12 @@ function fs.rename(from,to) -- moves file *from* to *to*
|
||||
end
|
||||
|
||||
function fs.mount(path,proxy) -- mounts the filesystem *proxy* to the mount point *path* if it is a directory. BYO proxy.
|
||||
if fs.isDirectory(path) and not fsmounts[table.concat(fs.segments(path),"/")] then
|
||||
if fs.isDirectory(path) then
|
||||
fsmounts[table.concat(fs.segments(path),"/")] = proxy
|
||||
return true
|
||||
end
|
||||
return false, "path is not a directory"
|
||||
end
|
||||
function fs.umount(path)
|
||||
local fsi,_ = fs.resolve(path)
|
||||
fsmounts[fsi] = nil
|
||||
end
|
||||
|
||||
function fs.mounts() -- returns a table containing the mount points of all mounted filesystems
|
||||
local rt = {}
|
||||
@ -131,5 +127,9 @@ if computer.getBootAddress then
|
||||
fs.makeDirectory("boot")
|
||||
fs.mount("boot",component.proxy(computer.getBootAddress()))
|
||||
end
|
||||
for addr, _ in component.list("filesystem") do
|
||||
fs.makeDirectory(addr:sub(1,3))
|
||||
fs.mount(addr:sub(1,3),component.proxy(addr))
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -1,21 +1,11 @@
|
||||
local function mount(addr)
|
||||
dest = component.invoke(addr,"getLabel") or "mnt/"..addr:sub(1,3)
|
||||
dest = "/"..dest
|
||||
syslog("Mounting "..addr.." to "..dest)
|
||||
fs.makeDirectory(dest)
|
||||
local w,r = fs.mount(dest,component.proxy(addr))
|
||||
if not w then
|
||||
syslog("Failed to mount: "..r)
|
||||
end
|
||||
end
|
||||
for addr, _ in component.list("filesystem") do
|
||||
mount(addr)
|
||||
end
|
||||
while true do
|
||||
local tE = {coroutine.yield()}
|
||||
if tE[1] == "component_added" and tE[3] == "filesystem" then
|
||||
mount(tE[2])
|
||||
local w, doesExist = pcall(fs.exists,"/"..tE[2]:sub(1,3))
|
||||
if not w or not doesExist then
|
||||
fs.mounts[tE[2]:sub(1,3)] = component.proxy(tE[2])
|
||||
end
|
||||
elseif tE[1] == "component_removed" and tE[3] == "filesystem" then
|
||||
fs.umount("/mnt/"..tE[2]:sub(1,3))
|
||||
fs.mounts[tE[2]:sub(1,3)] = nil
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user