Compare commits

...

3 Commits

3 changed files with 14 additions and 0 deletions

View File

@ -16,6 +16,14 @@ end
function netutil.exportfs(path) -- string -- boolean -- Export the directory *path* over RPC. function netutil.exportfs(path) -- string -- boolean -- Export the directory *path* over RPC.
local path = "/"..table.concat(fs.segments(path),"/") local path = "/"..table.concat(fs.segments(path),"/")
local px = require("unionfs").create(path) local px = require("unionfs").create(path)
function px.dirstat(p)
local rt = {}
for k,v in ipairs(px.list(p)) do
local fp = p.."/"..v
rt[v] = {px.isDirectory(fp), px.size(fp), px.lastModified(fp)}
end
return rt
end
for k,v in pairs(px) do for k,v in pairs(px) do
rpc.register("fs_"..path.."_"..k,v) rpc.register("fs_"..path.."_"..k,v)
print("fs_"..path.."_"..k) print("fs_"..path.."_"..k)

View File

@ -107,6 +107,7 @@ function fs.mounts() -- -- table -- Returns a table containing the mount points
for k,v in pairs(fsmounts) do for k,v in pairs(fsmounts) do
rt[#rt+1] = k,v.address or "unknown" rt[#rt+1] = k,v.address or "unknown"
end end
table.sort(rt)
return rt return rt
end end

View File

@ -3,6 +3,11 @@ fsmanager.filesystems = {}
local run = true local run = true
function fsmanager.mount(addr) function fsmanager.mount(addr)
for k,v in ipairs(fs.mounts()) do
if fs.address(v) == addr then
return
end
end
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)