Compare commits

..

3 Commits

Author SHA1 Message Date
3266c66fc4 updated fserv to fit the new (and next) service system 2020-06-06 12:55:02 +10:00
3fed8a5985 fixed fs.copy
oops
2020-06-06 12:54:10 +10:00
f132c2349f made pkgfs auto-mount when loaded 2020-06-06 12:50:50 +10:00
3 changed files with 26 additions and 9 deletions

View File

@ -111,4 +111,6 @@ function pkgfs.add(fname,comp) -- string boolean -- -- Add a package as specifie
f:close()
end
fs.makeDirectory("/pkg")
fs.mount("/pkg",pkgfs.component)
return pkgfs

View File

@ -68,7 +68,11 @@ function fs.copy(from,to) -- string string -- boolean -- copies a file from *fro
if not of or not df then
return false
end
df:write(of:read("*a"))
local tmp
repeat
tmp = of:read(2048)
df:write(tmp or "")
until not tmp
df:close()
of:close()
return true

View File

@ -3,13 +3,15 @@ local serial = require "serialization"
local cfg = {["path"]="/boot/srv/frequest",["port"]=70}
f=io.open("/boot/cfg/fserv.cfg","rb")
if f then
local function loadConfig(cfgpath)
local f=io.open(cfgpath or "/boot/cfg/fserv.cfg","rb")
if f then
local ncfg = serial.unserialize(f:read("*a"))
f:close()
for k,v in pairs(ncfg) do
cfg[k] = v
end
end
end
local function fileHandler(socket,rtype,path)
@ -90,6 +92,15 @@ local function socketHandler(socket)
end
end
while true do
local function fileServer()
while true do
os.spawn(socketHandler(minitel.listen(70)),"fserv worker process")
end
end
function start(cfgpath)
loadConfig(cfgpath)
return os.spawn(fileServer,"fserv")
end
return {start=start}