write documentation for netutil

This commit is contained in:
Izaya 2020-03-18 14:06:40 +11:00
parent 90afc8d18d
commit 4606620583

View File

@ -4,16 +4,15 @@ local event = require "event"
local rpc = require "rpc"
local netutil = {}
function netutil.importfs(host,rpath,lpath)
function netutil.importfs(host,rpath,lpath) -- import filesystem *rpath* from *host* and attach it to *lpath*
local px = rpc.proxy(host,rpath.."_")
function px.getLabel()
return host..":"..rpath
end
fs.mount(lpath,px)
return true
return fs.mount(lpath,px)
end
function netutil.exportfs(path)
function netutil.exportfs(path) -- export the directory *path* over RPC
local path = "/"..table.concat(fs.segments(path),"/")
local px = ufs.create(path)
for k,v in pairs(px) do
@ -23,7 +22,7 @@ function netutil.exportfs(path)
return true
end
function netutil.ping(addr,times,timeout, silent)
function netutil.ping(addr,times,timeout, silent) -- Request acknowledgment from *addr*, waiting *timeout* seconds each try, and try *times* times. If *silent* is true, don't print status. Returns true if there was at least one successful ping, the number of successes, the number of failures, and the average round trip time.
local times, timeout = times or 5, timeout or 30
local success, fail, time, avg = 0, 0, 0, 0
for i = 1, times do