From 3d89bbd9879c1b6b04cf54fccf8e52ce2fa11afb Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Sun, 14 May 2017 22:29:45 +1000 Subject: [PATCH 01/56] Added a passthrough-to-data-card version of the base64 library. Compatible with the normal implementation, in theory faster, and smaller as far as code goes. --- modules/library/base64-passthrough.lua | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 modules/library/base64-passthrough.lua diff --git a/modules/library/base64-passthrough.lua b/modules/library/base64-passthrough.lua new file mode 100644 index 0000000..fcce931 --- /dev/null +++ b/modules/library/base64-passthrough.lua @@ -0,0 +1,8 @@ +do +function b64(data) + component.invoke(component.list("data")(),"encode64",data) +end + +function ub64(data) + component.invoke(component.list("data")(),"decode64",data) +end From bcbea6facdf35a0c443ad84890779b484d5a46d4 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Sun, 14 May 2017 22:31:03 +1000 Subject: [PATCH 02/56] Forgot to return it x_x --- modules/library/base64-passthrough.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/library/base64-passthrough.lua b/modules/library/base64-passthrough.lua index fcce931..b86c2f6 100644 --- a/modules/library/base64-passthrough.lua +++ b/modules/library/base64-passthrough.lua @@ -1,8 +1,8 @@ do function b64(data) - component.invoke(component.list("data")(),"encode64",data) + return component.invoke(component.list("data")(),"encode64",data) end function ub64(data) - component.invoke(component.list("data")(),"decode64",data) + return component.invoke(component.list("data")(),"decode64",data) end From a138a02d61a85b8b273e5448983d4c1606e8862f Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Sun, 14 May 2017 22:32:15 +1000 Subject: [PATCH 03/56] Reminder not to code before or after midnight --- modules/library/base64-passthrough.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/library/base64-passthrough.lua b/modules/library/base64-passthrough.lua index b86c2f6..6f552b6 100644 --- a/modules/library/base64-passthrough.lua +++ b/modules/library/base64-passthrough.lua @@ -1,8 +1,6 @@ -do function b64(data) return component.invoke(component.list("data")(),"encode64",data) end - function ub64(data) return component.invoke(component.list("data")(),"decode64",data) end From b02997bd85d2ff7e21c780408ffd0ac5c2cfc5e5 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Mon, 15 May 2017 01:46:40 +1000 Subject: [PATCH 04/56] Added build time recording to listmods --- build.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.lua b/build.lua index 45e519a..125bdc6 100755 --- a/build.lua +++ b/build.lua @@ -77,13 +77,13 @@ print(tostring(#tm).." modules loaded.\n") -- Generate source print("Generating source") if cfg.listmods == "yes" then - ss=ss.."modules,_OSVERSION={" + ss=ss.."_MOD,_OSVERSION,_BD={" for k,v in ipairs(tm) do ss=ss..'"'..v..'",' end ss=ss.."}," if _OSVERSION == nil then - ss=ss..'"MultICE '..io.popen("git rev-parse HEAD"):read("*a"):sub(1,7)..'"\n' + ss=ss..'"MultICE '..io.popen("git rev-parse HEAD"):read("*a"):sub(1,7)..'","'..os.date("%Y/%m/%d %H:%M %z")..'"\n' else ss=ss..'"MultICE DR0"\n' end From 52248755b18c5c8912c5c58910b87358beec84cd Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Mon, 15 May 2017 17:16:20 +1000 Subject: [PATCH 05/56] Added a basic init system. --- modules/util/sinit.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 modules/util/sinit.lua diff --git a/modules/util/sinit.lua b/modules/util/sinit.lua new file mode 100644 index 0000000..a093ab0 --- /dev/null +++ b/modules/util/sinit.lua @@ -0,0 +1,17 @@ +do + if _OSVERSION and _BD then + print("Starting ".._OSVERSION.." built at ".._BD) + end + local f=fopen("boot:/init.cfg","rb") + if f then + local c="" + local nc=fread(f,2048) + while nc ~= nil and nc ~= "" do + c=c..nc + nc=fread(f,2048) + end + for l in c:gmatch("[^\n]+") do + print("[init] "..l) + end + end +end From 669e87751368e9a45efd2a8ca9f86a149fb6d9d8 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Mon, 15 May 2017 17:18:15 +1000 Subject: [PATCH 06/56] Maybe actually added it? --- modules/util/sinit.lua | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/modules/util/sinit.lua b/modules/util/sinit.lua index a093ab0..0e7a3f9 100644 --- a/modules/util/sinit.lua +++ b/modules/util/sinit.lua @@ -1,17 +1,20 @@ -do - if _OSVERSION and _BD then - print("Starting ".._OSVERSION.." built at ".._BD) - end +s("init",function() local f=fopen("boot:/init.cfg","rb") + write("") if f then - local c="" - local nc=fread(f,2048) - while nc ~= nil and nc ~= "" do - c=c..nc - nc=fread(f,2048) + local c="" + local nc=fread(f,2048) + while nc ~= nil and nc ~= "" do + c=c..nc + nc=fread(f,2048) + end + for l in c:gmatch("[^\n]+") do + write("[init] "..l..": ") + local pf=fload(l) + print(pcall(pf)) + end end - for l in c:gmatch("[^\n]+") do - print("[init] "..l) + if _OSVERSION and _BD then + print("Started ".._OSVERSION.." (built at ".._BD..")") end - end -end +end) From 080af72ca612456f27419e089bd7d892c2e8e5d5 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Mon, 15 May 2017 17:19:24 +1000 Subject: [PATCH 07/56] general fixes --- modules/applications/luash.lua | 2 +- modules/library/fs-util.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/applications/luash.lua b/modules/applications/luash.lua index f41fbbd..13113fe 100644 --- a/modules/applications/luash.lua +++ b/modules/applications/luash.lua @@ -1,7 +1,7 @@ s("lua shell",function() print(_VERSION) while true do - h("display","> ") + write("> ") print(pcall(load(readln()))) end end) diff --git a/modules/library/fs-util.lua b/modules/library/fs-util.lua index a7b5ea5..2ab6bc5 100644 --- a/modules/library/fs-util.lua +++ b/modules/library/fs-util.lua @@ -24,7 +24,7 @@ function fload(i) s=s..c c=fread(f,math.huge) until c == nil - load(s) + return load(s) end return false end From be1534124bfea776f694ed7a0857224640fbe3c9 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Mon, 15 May 2017 21:14:44 +1000 Subject: [PATCH 08/56] Made ps() from shutil a little nicer --- modules/applications/shutil.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/applications/shutil.lua b/modules/applications/shutil.lua index 84f397e..a6713d9 100644 --- a/modules/applications/shutil.lua +++ b/modules/applications/shutil.lua @@ -1,6 +1,8 @@ function ps() for k,v in pairs(tT) do - print(v[1]) + write("pid: "..tostring(k)..", process name: "..tostring(v[1])..", env={") + for l,w in ipairs(v[3]) do write(tostring(l).." = "..tostring(w)..", ") end + print("}") end end function mem() From 95a5a16e0f85046eb1514335e08f3cd14f2214b7 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Tue, 16 May 2017 02:26:28 +1000 Subject: [PATCH 09/56] hopeful multisession support --- build.cfg | 4 ++-- modules.cfg | 12 +----------- modules/base/header.lua | 7 +++++-- modules/drivers/kbd.lua | 10 ++++++++++ modules/drivers/tty.lua | 34 ++++++++++++++++++++++++++++++++++ modules/library/print.lua | 12 ++++++------ modules/library/readline.lua | 19 +++++++++++++++++++ modules/util/autogpu.lua | 5 +++++ modules/util/sinit.lua | 2 +- 9 files changed, 83 insertions(+), 22 deletions(-) create mode 100644 modules/drivers/kbd.lua create mode 100644 modules/drivers/tty.lua create mode 100644 modules/library/readline.lua create mode 100644 modules/util/autogpu.lua diff --git a/build.cfg b/build.cfg index 2b35d82..fabb30b 100644 --- a/build.cfg +++ b/build.cfg @@ -1,5 +1,5 @@ -optimise no -listmods no +optimise yes +listmods yes test no log no opath kernel.lua diff --git a/modules.cfg b/modules.cfg index f72ea91..aa5d7c7 100644 --- a/modules.cfg +++ b/modules.cfg @@ -1,18 +1,8 @@ base/header.lua -drivers/dterm.lua library/print.lua -drivers/keyboard.lua -library/net.lua library/fs-min.lua library/fs-std.lua -library/fs-ext.lua library/fs-util.lua -library/base64.lua util/fs-automount.lua -net/ping.lua -applications/shutil.lua -applications/evproxy-srv.lua -applications/evproxy-client.lua -applications/ircbridge.lua -applications/luash.lua +util/sinit.lua base/footer.lua diff --git a/modules/base/header.lua b/modules/base/header.lua index 2670606..4fe3dca 100644 --- a/modules/base/header.lua +++ b/modules/base/header.lua @@ -1,6 +1,6 @@ tT,p,C,T={},1,coroutine,table -function s(n,f,e) - T.insert(tT,{n,C.create(f),(e or {})}) +function E() + if tT[cT] ~= nil then return tT[cT][3] end end function l() return eV @@ -8,3 +8,6 @@ end function h(...) computer.pushSignal(...) end +function s(n,f,e) + T.insert(tT,{n,C.create(f),(e or E() or {})}) +end diff --git a/modules/drivers/kbd.lua b/modules/drivers/kbd.lua new file mode 100644 index 0000000..898a8ae --- /dev/null +++ b/modules/drivers/kbd.lua @@ -0,0 +1,10 @@ +function kbd(kA,sI) + s("kbd: "..kA..","..tostring(si),function() + while true do + if ev[1] == "key_down" and ev[2] == kA then + h("key",sI,ev[3],ev[4]) + end + C.yield() + end + end) +end diff --git a/modules/drivers/tty.lua b/modules/drivers/tty.lua new file mode 100644 index 0000000..62cce56 --- /dev/null +++ b/modules/drivers/tty.lua @@ -0,0 +1,34 @@ +function tty(gA,sA,sI,fg,bg) + local gP,cx,cy = component.proxy(gA),1,1 + gP.bind(sA) + local sx, sy = gP.getResolution() + gP.setResolution(sx,sy) + gP.setForeground(bg or 0xFFFFFF) + gP.setBackground(bg or 0x000000) + gP.fill(1,1,sx,sy," ") + local function cv() + if cx > sx then cx,cy=1,cy+1 end + if cx < 1 then cx,cy=1,cy-1 end + if cy < 1 then cx,cy=1,1 end + if cy > sy then gP.copy(1,2,sx,sy-1,1,1) gP.fill(1,sx,sy,1," ") cx,cy=1,sy end + end + local function wl(str) + for c in str:gmatch(".") do + if c == "\n" then cx,cy=1,cy+1 + elseif c == "\r" then cx=1 + elseif c == "\f" then cx=1 cy=1 gP.fill(1, 1, sx, sy, " ") + elseif c == "\127" then cx=cx-1 gP.set(cx,cy," ") + else gP.set(cx,cy,c) cx=cx+1 + end cv() + end + end + s("display: "..gA..","..sA,function() + while true do + eT = ev + if eT[1] == "display" and eT[3] == sI then + wl(tostring(eT[2])) + end + C.yield() + end + end) +end diff --git a/modules/library/print.lua b/modules/library/print.lua index fc167bf..f27f84e 100644 --- a/modules/library/print.lua +++ b/modules/library/print.lua @@ -1,10 +1,10 @@ -function print(...) - for k,v in pairs({...}) do - h("display",tostring(v).."\n") - end -end function write(...) for k,v in pairs({...}) do - h("display",tostring(v)) + h("display",tostring(v),E().sI) + end +end +function print(...) + for k,v in pairs({...}) do + write(tostring(v).."\n") end end diff --git a/modules/library/readline.lua b/modules/library/readline.lua new file mode 100644 index 0000000..d5657e8 --- /dev/null +++ b/modules/library/readline.lua @@ -0,0 +1,19 @@ +function readln() + local s="" + write("|") + while true do + if ev[1] == "key" and ev[2] == E().sI then + if ev[3] == 13 then + write("\127\n") + C.yield() + return s + elseif ev[3] == 8 then + if s:len()>0 then s=s:sub(1,-2) write("\127\127|") end + elseif ev[3] > 31 and ev[3] < 127 then + s=s..string.char(ev[3]) write("\127"..string.char(ev[3]).."|") + end + end + C.yield() + end +end + diff --git a/modules/util/autogpu.lua b/modules/util/autogpu.lua new file mode 100644 index 0000000..314dc27 --- /dev/null +++ b/modules/util/autogpu.lua @@ -0,0 +1,5 @@ +print("","GPU: "..component.list("gpu")(),"Screen: "..component.list("screen")(),"Keyboard:"..component.list("keyboard")()) +print("Starting tty") +tty(component.list("gpu")(),component.list("screen")(),1) +print("Starting kbd") +kbd(component.list("keyboard")(),1) diff --git a/modules/util/sinit.lua b/modules/util/sinit.lua index 0e7a3f9..8af4ae3 100644 --- a/modules/util/sinit.lua +++ b/modules/util/sinit.lua @@ -17,4 +17,4 @@ s("init",function() if _OSVERSION and _BD then print("Started ".._OSVERSION.." (built at ".._BD..")") end -end) +end,{["sI"]=1}) From 936712b60910b780b5ff79714492b145b48efd78 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Tue, 16 May 2017 02:36:16 +1000 Subject: [PATCH 10/56] General fixes of stuff. --- modules/applications/shutil.lua | 2 +- modules/drivers/tty.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/applications/shutil.lua b/modules/applications/shutil.lua index a6713d9..0f25ed3 100644 --- a/modules/applications/shutil.lua +++ b/modules/applications/shutil.lua @@ -1,7 +1,7 @@ function ps() for k,v in pairs(tT) do write("pid: "..tostring(k)..", process name: "..tostring(v[1])..", env={") - for l,w in ipairs(v[3]) do write(tostring(l).." = "..tostring(w)..", ") end + for l,w in pairs(v[3]) do write(tostring(l).." = "..tostring(w)..", ") end print("}") end end diff --git a/modules/drivers/tty.lua b/modules/drivers/tty.lua index 62cce56..16a0df2 100644 --- a/modules/drivers/tty.lua +++ b/modules/drivers/tty.lua @@ -10,7 +10,7 @@ function tty(gA,sA,sI,fg,bg) if cx > sx then cx,cy=1,cy+1 end if cx < 1 then cx,cy=1,cy-1 end if cy < 1 then cx,cy=1,1 end - if cy > sy then gP.copy(1,2,sx,sy-1,1,1) gP.fill(1,sx,sy,1," ") cx,cy=1,sy end + if cy > sy then gP.copy(1,2,sx,sy-1,0,-1) gP.fill(1,sy,sx,1," ") cx,cy=1,sy end end local function wl(str) for c in str:gmatch(".") do From 8698abf08a0fcafefc89cc9a2c4623fd40ff208a Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Tue, 16 May 2017 02:40:36 +1000 Subject: [PATCH 11/56] tidying up --- modules/drivers/kbd.lua | 2 +- modules/drivers/tty.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/drivers/kbd.lua b/modules/drivers/kbd.lua index 898a8ae..04bbf06 100644 --- a/modules/drivers/kbd.lua +++ b/modules/drivers/kbd.lua @@ -1,5 +1,5 @@ function kbd(kA,sI) - s("kbd: "..kA..","..tostring(si),function() + s("kbd: "..kA:sub(1,8)..","..tostring(si),function() while true do if ev[1] == "key_down" and ev[2] == kA then h("key",sI,ev[3],ev[4]) diff --git a/modules/drivers/tty.lua b/modules/drivers/tty.lua index 16a0df2..c546875 100644 --- a/modules/drivers/tty.lua +++ b/modules/drivers/tty.lua @@ -22,7 +22,7 @@ function tty(gA,sA,sI,fg,bg) end cv() end end - s("display: "..gA..","..sA,function() + s("tty: "..gA:sub(1,8)..","..sA:sub(1,8),function() while true do eT = ev if eT[1] == "display" and eT[3] == sI then From 5814140245859297ebd35f65826902fb90f83466 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Fri, 19 May 2017 20:43:09 +0000 Subject: [PATCH 12/56] fix a typo --- doc/build.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/build.md b/doc/build.md index 63500cf..6840c43 100644 --- a/doc/build.md +++ b/doc/build.md @@ -1,7 +1,7 @@ # Building MultICE MultICE uses a relatively simple build system. It has been tested on Arch Linux, Debian Linux, OpenOS and Plan9k. ## 1. Choose modules. -The system is made out of modules from the `modules/` directory. When you run the build script, it assembles them, and optionally optomises the code for space. +The system is made out of modules from the `modules/` directory. When you run the build script, it assembles them, and optionally optimises the code for space. There are a number of preconfigured module sets in the `config/` directory, and you can of course you can write your own. The build system defaults to a file called `modules.cfg` in the current directory. You can specify a config file using `--modconfig=file.cfg`. From 4552888f8b5a7be5bfc7f5ecaa1a845015d48637 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Fri, 19 May 2017 20:55:11 +0000 Subject: [PATCH 13/56] some fancy remote shell related stuff. it works in the background now. currently breaks all stable builds. --- modules/applications/autoluash.lua | 1 + modules/applications/luash.lua | 4 +++- .../applications/{evproxy-client.lua => nshc.lua} | 5 ++--- modules/applications/{evproxy-srv.lua => nshd.lua} | 13 +++++++------ 4 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 modules/applications/autoluash.lua rename modules/applications/{evproxy-client.lua => nshc.lua} (77%) rename modules/applications/{evproxy-srv.lua => nshd.lua} (57%) diff --git a/modules/applications/autoluash.lua b/modules/applications/autoluash.lua new file mode 100644 index 0000000..4b2e155 --- /dev/null +++ b/modules/applications/autoluash.lua @@ -0,0 +1 @@ +luash() diff --git a/modules/applications/luash.lua b/modules/applications/luash.lua index 13113fe..8099f66 100644 --- a/modules/applications/luash.lua +++ b/modules/applications/luash.lua @@ -1,7 +1,9 @@ +function luash(si) s("lua shell",function() print(_VERSION) while true do write("> ") print(pcall(load(readln()))) end -end) +end,si) +end diff --git a/modules/applications/evproxy-client.lua b/modules/applications/nshc.lua similarity index 77% rename from modules/applications/evproxy-client.lua rename to modules/applications/nshc.lua index c08f668..f97e039 100644 --- a/modules/applications/evproxy-client.lua +++ b/modules/applications/nshc.lua @@ -5,13 +5,12 @@ function nshc(evPP,nid) local V,msg=false,tostring(ev[4]) if ev[3] == evPP and ev[2] == nid then if msg:sub(1,3) == "dis" then - h("display",msg:sub(4)) + write(msg:sub(4)) end end - elseif ev[1] == "key_down" then + elseif ev[1] == "key" and ev[2] == tT[cT][3].sI then ns(nid,evPP,"key"..tostring(ev[3])) end C.yield() end end - diff --git a/modules/applications/evproxy-srv.lua b/modules/applications/nshd.lua similarity index 57% rename from modules/applications/evproxy-srv.lua rename to modules/applications/nshd.lua index f567b09..51cdb90 100644 --- a/modules/applications/evproxy-srv.lua +++ b/modules/applications/nshd.lua @@ -1,20 +1,21 @@ -evPP,tEPs="nsh",{} -s("netsh daemon",function() +function nshd(evPP,tEPs,sI) +s("netsh daemon",function() print(pcall(function() while true do if ev[1] == "net_msg" then local V,msg=false,tostring(ev[4]) for k,v in ipairs(tEPs) do if ev[2] == v then V=true end end if ev[3] == evPP and V then if msg:sub(1,3) == "key" then - h("key_down",ev[2],tonumber(msg:sub(4)),0) + h("key",tT[cT][3].sI,tonumber(msg:sub(4)),0) end end - elseif ev[1] == "display" then + elseif ev[1] == "display" and ev[3] == tT[cT][3].sI then for k,v in ipairs(tEPs) do ns(v,evPP,"dis"..tostring(ev[2])) end end C.yield() end -end) - +end)) end,{["sI"]=sI}) +luash({["sI"]=sI}) +end From 295314cc4e89f01f672c7af68e97c84740116816 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Sun, 21 May 2017 10:19:53 +0000 Subject: [PATCH 14/56] Automated negotiation of nsh sessions. Fancy stuff. --- modules/applications/nshc.lua | 15 ++++++++++++++- modules/applications/nshd.lua | 33 ++++++++++++++++++++++++--------- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/modules/applications/nshc.lua b/modules/applications/nshc.lua index f97e039..375c549 100644 --- a/modules/applications/nshc.lua +++ b/modules/applications/nshc.lua @@ -1,4 +1,4 @@ -function nshc(evPP,nid) +function nshc_w(evPP,nid) write("\f") while true do if ev[1] == "net_msg" then @@ -14,3 +14,16 @@ function nshc(evPP,nid) C.yield() end end + +function nshc(P,nid) + ns(nid,P,"initnsh") + while true do + if ev[1] == "net_msg" then + print(T.unpack(ev)) + end + if ev[1] == "net_msg" and ev[2] == nid and ev[3] == P then + nshc_w(ev[4],nid) + end + C.yield() + end +end diff --git a/modules/applications/nshd.lua b/modules/applications/nshd.lua index 51cdb90..acb452e 100644 --- a/modules/applications/nshd.lua +++ b/modules/applications/nshd.lua @@ -1,21 +1,36 @@ -function nshd(evPP,tEPs,sI) -s("netsh daemon",function() print(pcall(function() +function nshd_w(evPP,cA,sI) +s("netsh daemon - "..tostring(sI),function() print(pcall(function() while true do if ev[1] == "net_msg" then - local V,msg=false,tostring(ev[4]) - for k,v in ipairs(tEPs) do if ev[2] == v then V=true end end - if ev[3] == evPP and V then + local msg=tostring(ev[4]) + if ev[3] == evPP and ev[2] == cA then if msg:sub(1,3) == "key" then h("key",tT[cT][3].sI,tonumber(msg:sub(4)),0) end end elseif ev[1] == "display" and ev[3] == tT[cT][3].sI then - for k,v in ipairs(tEPs) do - ns(v,evPP,"dis"..tostring(ev[2])) - end + ns(cA,evPP,"dis"..tostring(ev[2])) end C.yield() end end)) end,{["sI"]=sI}) -luash({["sI"]=sI}) +end + +function nshd(P) + s("nshd",function() print(pcall(function() + local Cc=1 + while true do + if ev[1] == "net_msg" and ev[3] == P then + if ev[4] == "initnsh" then + nnID="nsh-"..tostring(Cc) + Cc=Cc+1 + ns(ev[2],P,nnID) + nshd_w(nnID,ev[2],nnID) + luash({["sI"]=nnID}) + print("[nshd]Spawned "..nnID.." for "..tostring(ev[2])) + end + end + C.yield() + end end)) + end,{["sI"]="log"}) end From 6f94ad19ba0a8cecc5d69dc1856720def27ba127 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Sun, 21 May 2017 13:21:09 +0000 Subject: [PATCH 15/56] config changes I guess --- build.cfg | 2 +- configs/desktop.cfg | 7 ++----- configs/headless.cfg | 13 +++++++++++++ configs/network-terminal.cfg | 10 ++++++---- modules.cfg | 12 ++++++++++++ 5 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 configs/headless.cfg diff --git a/build.cfg b/build.cfg index fabb30b..93be19e 100644 --- a/build.cfg +++ b/build.cfg @@ -1,4 +1,4 @@ -optimise yes +optimise no listmods yes test no log no diff --git a/configs/desktop.cfg b/configs/desktop.cfg index d12b4d2..ab95031 100644 --- a/configs/desktop.cfg +++ b/configs/desktop.cfg @@ -1,14 +1,11 @@ base/header.lua -drivers/dterm.lua library/print.lua -drivers/keyboard.lua -library/net.lua library/fs-min.lua library/fs-std.lua library/fs-ext.lua +library/fs-util.lua util/fs-automount.lua +util/sinit.lua applications/shutil.lua -applications/evproxy-srv.lua -applications/evproxy-client.lua applications/luash.lua base/footer.lua diff --git a/configs/headless.cfg b/configs/headless.cfg new file mode 100644 index 0000000..4848e64 --- /dev/null +++ b/configs/headless.cfg @@ -0,0 +1,13 @@ +base/header.lua +library/print.lua +library/net.lua +library/readline.lua +applications/nshd.lua +applications/luash.lua +applications/shutil.lua +library/fs-min.lua +library/fs-std.lua +library/fs-ext.lua +util/fs-automount-min.lua +util/loadeeprom.lua +base/footer.lua diff --git a/configs/network-terminal.cfg b/configs/network-terminal.cfg index 6f5c71b..734d11b 100644 --- a/configs/network-terminal.cfg +++ b/configs/network-terminal.cfg @@ -1,10 +1,12 @@ base/header.lua -drivers/dterm.lua library/print.lua -drivers/keyboard.lua +drivers/tty.lua +drivers/kbd.lua +util/autogpu.lua library/net.lua -applications/shutil.lua -applications/evproxy-client.lua +library/readline.lua +applications/nshc.lua applications/luash.lua +applications/autoluash.lua util/loadeeprom.lua base/footer.lua diff --git a/modules.cfg b/modules.cfg index aa5d7c7..bf32d91 100644 --- a/modules.cfg +++ b/modules.cfg @@ -5,4 +5,16 @@ library/fs-std.lua library/fs-util.lua util/fs-automount.lua util/sinit.lua +drivers/tty.lua +drivers/kbd.lua +util/autogpu.lua +library/net.lua +library/fs-ext.lua +library/readline.lua +applications/nshd.lua +applications/nshc.lua +applications/shutil.lua +applications/luash.lua +applications/ircbridge.lua +applications/autoluash.lua base/footer.lua From 507fe49984d6e8ae77437b95653b743a737832ee Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Tue, 23 May 2017 14:38:33 +0000 Subject: [PATCH 16/56] added tabs to the tty --- modules/drivers/tty.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/drivers/tty.lua b/modules/drivers/tty.lua index c546875..7f31c89 100644 --- a/modules/drivers/tty.lua +++ b/modules/drivers/tty.lua @@ -17,6 +17,7 @@ function tty(gA,sA,sI,fg,bg) if c == "\n" then cx,cy=1,cy+1 elseif c == "\r" then cx=1 elseif c == "\f" then cx=1 cy=1 gP.fill(1, 1, sx, sy, " ") + elseif c == "\t" then cx=cx+4-((cx+4)%4) elseif c == "\127" then cx=cx-1 gP.set(cx,cy," ") else gP.set(cx,cy,c) cx=cx+1 end cv() From 5d94afe751430d55f2557573757e7d4f55ddaba9 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Tue, 23 May 2017 14:39:28 +0000 Subject: [PATCH 17/56] fixed a bug in the spawning of keyboard drivers --- modules/drivers/kbd.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/drivers/kbd.lua b/modules/drivers/kbd.lua index 04bbf06..4562b91 100644 --- a/modules/drivers/kbd.lua +++ b/modules/drivers/kbd.lua @@ -1,5 +1,5 @@ function kbd(kA,sI) - s("kbd: "..kA:sub(1,8)..","..tostring(si),function() + s("kbd: "..kA:sub(1,8)..","..tostring(sI),function() while true do if ev[1] == "key_down" and ev[2] == kA then h("key",sI,ev[3],ev[4]) From c5d0662a7c4d273f4c2108869bcd5891f86ed2b3 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Tue, 23 May 2017 14:41:28 +0000 Subject: [PATCH 18/56] removed some debug text --- modules/util/autogpu.lua | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/util/autogpu.lua b/modules/util/autogpu.lua index 314dc27..1789539 100644 --- a/modules/util/autogpu.lua +++ b/modules/util/autogpu.lua @@ -1,5 +1,2 @@ -print("","GPU: "..component.list("gpu")(),"Screen: "..component.list("screen")(),"Keyboard:"..component.list("keyboard")()) -print("Starting tty") tty(component.list("gpu")(),component.list("screen")(),1) -print("Starting kbd") kbd(component.list("keyboard")(),1) From c10058e49073f872ef6f30a5bc0749083ea5de1e Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Tue, 23 May 2017 14:44:46 +0000 Subject: [PATCH 19/56] changed some formatting and stuff for ps() and mem() --- modules/applications/shutil.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/applications/shutil.lua b/modules/applications/shutil.lua index 0f25ed3..e66dce3 100644 --- a/modules/applications/shutil.lua +++ b/modules/applications/shutil.lua @@ -1,12 +1,12 @@ function ps() for k,v in pairs(tT) do - write("pid: "..tostring(k)..", process name: "..tostring(v[1])..", env={") + write("pid: "..tostring(k).."\tname: "..tostring(v[1]).."\tenv={") for l,w in pairs(v[3]) do write(tostring(l).." = "..tostring(w)..", ") end print("}") end end function mem() - print("Total: "..tostring(computer.totalMemory()/1024).."K") - print("Free: "..tostring(computer.freeMemory()/1024).."K") - print("Used: "..tostring((computer.totalMemory()-computer.freeMemory())/1024).."K") + print("Total:\t"..tostring(computer.totalMemory()/1024).."K") + print("Free:\t"..tostring(computer.freeMemory()/1024).."K") + print("Used:\t"..tostring((computer.totalMemory()-computer.freeMemory())/1024).."K") end From 1994d25f5fb8352e8226bb70b3f7eb7c62f7b582 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Tue, 23 May 2017 14:46:50 +0000 Subject: [PATCH 20/56] should stop crashing with print() before processes start running --- modules/base/header.lua | 2 +- modules/library/print.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/base/header.lua b/modules/base/header.lua index 4fe3dca..5e25ac8 100644 --- a/modules/base/header.lua +++ b/modules/base/header.lua @@ -1,4 +1,4 @@ -tT,p,C,T={},1,coroutine,table +tT,p,cT,C,T={},1,1,coroutine,table function E() if tT[cT] ~= nil then return tT[cT][3] end end diff --git a/modules/library/print.lua b/modules/library/print.lua index f27f84e..5eee2d4 100644 --- a/modules/library/print.lua +++ b/modules/library/print.lua @@ -1,6 +1,6 @@ function write(...) for k,v in pairs({...}) do - h("display",tostring(v),E().sI) + h("display",tostring(v),E().sI or 1) end end function print(...) From f6c61622bcc1a5362c1a2bf25206b658179b55ad Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Tue, 23 May 2017 14:48:26 +0000 Subject: [PATCH 21/56] add a way to quit nsh sessions, ^] --- modules/applications/nshc.lua | 12 ++++++------ modules/applications/nshd.lua | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/applications/nshc.lua b/modules/applications/nshc.lua index 375c549..ef8be1f 100644 --- a/modules/applications/nshc.lua +++ b/modules/applications/nshc.lua @@ -1,5 +1,4 @@ function nshc_w(evPP,nid) - write("\f") while true do if ev[1] == "net_msg" then local V,msg=false,tostring(ev[4]) @@ -8,22 +7,23 @@ function nshc_w(evPP,nid) write(msg:sub(4)) end end - elseif ev[1] == "key" and ev[2] == tT[cT][3].sI then + elseif ev[1] == "key" and ev[2] == E().sI and ev[3] == 29 and ev[4] == 27 then + break + elseif ev[1] == "key" and ev[2] == E().sI then ns(nid,evPP,"key"..tostring(ev[3])) end C.yield() end + ns(nid,evPP,"exit") end function nshc(P,nid) ns(nid,P,"initnsh") while true do - if ev[1] == "net_msg" then - print(T.unpack(ev)) - end if ev[1] == "net_msg" and ev[2] == nid and ev[3] == P then - nshc_w(ev[4],nid) + break end C.yield() end + nshc_w(ev[4],nid) end diff --git a/modules/applications/nshd.lua b/modules/applications/nshd.lua index acb452e..f6a13ae 100644 --- a/modules/applications/nshd.lua +++ b/modules/applications/nshd.lua @@ -6,6 +6,7 @@ s("netsh daemon - "..tostring(sI),function() print(pcall(function() if ev[3] == evPP and ev[2] == cA then if msg:sub(1,3) == "key" then h("key",tT[cT][3].sI,tonumber(msg:sub(4)),0) + elseif msg == "exit" then break end end elseif ev[1] == "display" and ev[3] == tT[cT][3].sI then From 1c2da6090b2f7fd51221df4f249cb7b684a3bca8 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Tue, 23 May 2017 15:14:23 +0000 Subject: [PATCH 22/56] made default network addresses a bit more usable --- modules/library/net.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/library/net.lua b/modules/library/net.lua index 527ce77..fd79abe 100644 --- a/modules/library/net.lua +++ b/modules/library/net.lua @@ -1,4 +1,4 @@ -tM,nP,nID,nVL = {}, 4096, computer.address(), 1 +tM,nP,nID,nVL = {}, 4096, computer.address():sub(1,8), 1 for a,t in component.list("modem") do table.insert(tM,component.proxy(a)) component.proxy(a).open(nVL) From 4c5ae1d393537f6f7f9ef28eac330f1ce441821b Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Tue, 23 May 2017 15:14:50 +0000 Subject: [PATCH 23/56] readline should work without a .sI environment variable again --- modules/library/readline.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/library/readline.lua b/modules/library/readline.lua index d5657e8..7ca4433 100644 --- a/modules/library/readline.lua +++ b/modules/library/readline.lua @@ -1,8 +1,8 @@ function readln() - local s="" + local s,si="",E().sI or 1 write("|") while true do - if ev[1] == "key" and ev[2] == E().sI then + if ev[1] == "key" and ev[2] == si then if ev[3] == 13 then write("\127\n") C.yield() From 304a08ae511c6ed2f547f3ace7f168530d95b603 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Tue, 23 May 2017 15:18:18 +0000 Subject: [PATCH 24/56] switched to fs-ext-gen for headless configurations --- configs/headless.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/headless.cfg b/configs/headless.cfg index 4848e64..14b1be4 100644 --- a/configs/headless.cfg +++ b/configs/headless.cfg @@ -7,7 +7,7 @@ applications/luash.lua applications/shutil.lua library/fs-min.lua library/fs-std.lua -library/fs-ext.lua +library/fs-ext-gen.lua util/fs-automount-min.lua util/loadeeprom.lua base/footer.lua From 9ae5e5417677757c03e7b89c9615cab2de6d3e43 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Tue, 23 May 2017 17:09:54 +0000 Subject: [PATCH 25/56] so something broke fs-ext-gen. --- configs/headless.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/headless.cfg b/configs/headless.cfg index 14b1be4..4848e64 100644 --- a/configs/headless.cfg +++ b/configs/headless.cfg @@ -7,7 +7,7 @@ applications/luash.lua applications/shutil.lua library/fs-min.lua library/fs-std.lua -library/fs-ext-gen.lua +library/fs-ext.lua util/fs-automount-min.lua util/loadeeprom.lua base/footer.lua From 2249062214abcab707e93726c047e27cfa5073e0 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Tue, 23 May 2017 17:10:12 +0000 Subject: [PATCH 26/56] no longer depends on E().sI --- modules/applications/nshc.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/applications/nshc.lua b/modules/applications/nshc.lua index ef8be1f..b4324be 100644 --- a/modules/applications/nshc.lua +++ b/modules/applications/nshc.lua @@ -1,4 +1,5 @@ function nshc_w(evPP,nid) + local sI = E().sI or 1 while true do if ev[1] == "net_msg" then local V,msg=false,tostring(ev[4]) @@ -7,9 +8,9 @@ function nshc_w(evPP,nid) write(msg:sub(4)) end end - elseif ev[1] == "key" and ev[2] == E().sI and ev[3] == 29 and ev[4] == 27 then + elseif ev[1] == "key" and ev[2] == sI and ev[3] == 29 and ev[4] == 27 then break - elseif ev[1] == "key" and ev[2] == E().sI then + elseif ev[1] == "key" and ev[2] == sI then ns(nid,evPP,"key"..tostring(ev[3])) end C.yield() From 603ee1c869bd4ffce609451f1d5fc6441ab9c100 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Wed, 24 May 2017 09:33:42 +0000 Subject: [PATCH 27/56] added a --quiet option to build.lua --- build.lua | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/build.lua b/build.lua index 125bdc6..f892c3a 100755 --- a/build.lua +++ b/build.lua @@ -1,9 +1,23 @@ #!/usr/bin/env lua5.2 -- Initialization log = "" +tA = {...} +for k,v in ipairs(tA) do + if type(v) == "string" then + if v:sub(1,10) == "--cfgfile=" then + cfgfile = v:sub(11) + elseif v:sub(1,10) == "--modfile=" then + modfile = v:sub(11) + elseif v == "--quiet" then + quiet = true + end + end +end oldprint=print function print(...) - oldprint(...) + if not quiet then + oldprint(...) + end logline = "" if #{...} > 0 then if #{...} > 1 then @@ -19,16 +33,6 @@ function print(...) end print("Initializing and reading configuration") ts={} -tA = {...} -for k,v in ipairs(tA) do - if type(v) == "string" then - if v:sub(1,10) == "--cfgfile=" then - cfgfile = v:sub(11) - elseif v:sub(1,10) == "--modfile=" then - modfile = v:sub(11) - end - end -end ss="" cfgfile = cfgfile or "build.cfg" modfile = modfile or "modules.cfg" @@ -117,7 +121,11 @@ if cfg.test == "yes" then print("Checking for errors...") err={pcall(load,ss)} if err[1] ~= true then - print(table.unpack(err)) + if quiet then + io.write(table.unpack(err),"\n") + else + print(table.unpack(err)) + end else print("No errors detected by load()") end From 7e0d963af38b58d4e30f305dee1db3c4130a88e7 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Wed, 24 May 2017 09:35:03 +0000 Subject: [PATCH 28/56] added a config with all the bells and whistles --- configs/everything.cfg | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 configs/everything.cfg diff --git a/configs/everything.cfg b/configs/everything.cfg new file mode 100644 index 0000000..a80d987 --- /dev/null +++ b/configs/everything.cfg @@ -0,0 +1,20 @@ +base/header.lua +library/print.lua +library/fs-min.lua +library/fs-std.lua +library/fs-util.lua +util/fs-automount.lua +drivers/tty.lua +drivers/kbd.lua +util/autogpu.lua +util/sinit.lua +library/net.lua +library/fs-ext.lua +library/readline.lua +applications/nshd.lua +applications/nshc.lua +applications/shutil.lua +applications/luash.lua +applications/ircbridge.lua +applications/autoluash.lua +base/footer.lua From c945736ae16701d7c02a7c844f56337ca5bfac9a Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Wed, 24 May 2017 22:36:47 +0000 Subject: [PATCH 29/56] some general optomisations --- modules/applications/nshd.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/applications/nshd.lua b/modules/applications/nshd.lua index f6a13ae..2e58b6f 100644 --- a/modules/applications/nshd.lua +++ b/modules/applications/nshd.lua @@ -1,12 +1,12 @@ function nshd_w(evPP,cA,sI) -s("netsh daemon - "..tostring(sI),function() print(pcall(function() +s("netsh daemon - "..tostring(sI),function() while true do if ev[1] == "net_msg" then local msg=tostring(ev[4]) if ev[3] == evPP and ev[2] == cA then if msg:sub(1,3) == "key" then h("key",tT[cT][3].sI,tonumber(msg:sub(4)),0) - elseif msg == "exit" then break + elseif msg == "exit" then pcall(killsession,sI) break end end elseif ev[1] == "display" and ev[3] == tT[cT][3].sI then @@ -14,11 +14,11 @@ s("netsh daemon - "..tostring(sI),function() print(pcall(function() end C.yield() end -end)) end,{["sI"]=sI}) +end,{["sI"]=sI}) end function nshd(P) - s("nshd",function() print(pcall(function() + s("nshd",function() local Cc=1 while true do if ev[1] == "net_msg" and ev[3] == P then @@ -32,6 +32,6 @@ function nshd(P) end end C.yield() - end end)) + end end,{["sI"]="log"}) end From 51e5c68d9f42eeaf01dc9e5d74bc357d3bf5c216 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Wed, 24 May 2017 22:37:42 +0000 Subject: [PATCH 30/56] added a proc-utils library. note to self: move shit like shutil and proc-utils to library/ --- modules/applications/proc-utils.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 modules/applications/proc-utils.lua diff --git a/modules/applications/proc-utils.lua b/modules/applications/proc-utils.lua new file mode 100644 index 0000000..c59eec9 --- /dev/null +++ b/modules/applications/proc-utils.lua @@ -0,0 +1,11 @@ +function killsession(sI) + local rt={} + for k,v in ipairs(tT) do + if v[3].sI == sI then + T.insert(rt,1,k) + end + end + for k,v in ipairs(rt) do + T.remove(tT,v) + end +end From 9d57e69523b1612ffa8b92fac4f050ea454b6cbe Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Wed, 24 May 2017 23:03:14 +0000 Subject: [PATCH 31/56] as it turns out --quiet breaks basically everything. never mind. --- build.lua | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/build.lua b/build.lua index f892c3a..125bdc6 100755 --- a/build.lua +++ b/build.lua @@ -1,23 +1,9 @@ #!/usr/bin/env lua5.2 -- Initialization log = "" -tA = {...} -for k,v in ipairs(tA) do - if type(v) == "string" then - if v:sub(1,10) == "--cfgfile=" then - cfgfile = v:sub(11) - elseif v:sub(1,10) == "--modfile=" then - modfile = v:sub(11) - elseif v == "--quiet" then - quiet = true - end - end -end oldprint=print function print(...) - if not quiet then - oldprint(...) - end + oldprint(...) logline = "" if #{...} > 0 then if #{...} > 1 then @@ -33,6 +19,16 @@ function print(...) end print("Initializing and reading configuration") ts={} +tA = {...} +for k,v in ipairs(tA) do + if type(v) == "string" then + if v:sub(1,10) == "--cfgfile=" then + cfgfile = v:sub(11) + elseif v:sub(1,10) == "--modfile=" then + modfile = v:sub(11) + end + end +end ss="" cfgfile = cfgfile or "build.cfg" modfile = modfile or "modules.cfg" @@ -121,11 +117,7 @@ if cfg.test == "yes" then print("Checking for errors...") err={pcall(load,ss)} if err[1] ~= true then - if quiet then - io.write(table.unpack(err),"\n") - else - print(table.unpack(err)) - end + print(table.unpack(err)) else print("No errors detected by load()") end From 375b4259117f944044b4b7fc98f1c6ee1eea4ecd Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Thu, 25 May 2017 00:07:36 +0000 Subject: [PATCH 32/56] fixed l() --- modules/base/header.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/base/header.lua b/modules/base/header.lua index 5e25ac8..be6546d 100644 --- a/modules/base/header.lua +++ b/modules/base/header.lua @@ -3,7 +3,7 @@ function E() if tT[cT] ~= nil then return tT[cT][3] end end function l() - return eV + return ev end function h(...) computer.pushSignal(...) From 85dbe20f9f18bd979dbcd0e5cece27585ceb41d7 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Thu, 25 May 2017 00:45:13 +0000 Subject: [PATCH 33/56] made process IDs static hopefully --- modules/base/footer.lua | 2 +- modules/base/header.lua | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/base/footer.lua b/modules/base/footer.lua index 3da2acd..1cacb73 100644 --- a/modules/base/footer.lua +++ b/modules/base/footer.lua @@ -5,7 +5,7 @@ while #tT > 0 do if C.status(v[2])~="dead" then C.resume(v[2],table.unpack(ev)) else - T.remove(tT,k) + tT[k] = nil end end end diff --git a/modules/base/header.lua b/modules/base/header.lua index be6546d..a9ee54e 100644 --- a/modules/base/header.lua +++ b/modules/base/header.lua @@ -1,4 +1,4 @@ -tT,p,cT,C,T={},1,1,coroutine,table +tT,p,cT,pC,C,T={},1,1,1,coroutine,table function E() if tT[cT] ~= nil then return tT[cT][3] end end @@ -9,5 +9,6 @@ function h(...) computer.pushSignal(...) end function s(n,f,e) - T.insert(tT,{n,C.create(f),(e or E() or {})}) + tT[pC]={n,C.create(f),(e or E() or {})} + pC=pC+1 end From 4fb2fc0e0e09905fae220594fc4e1bd509e0000a Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Thu, 25 May 2017 00:55:24 +0000 Subject: [PATCH 34/56] change proc-utils for proper support of static pids --- modules/applications/proc-utils.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/applications/proc-utils.lua b/modules/applications/proc-utils.lua index c59eec9..a925114 100644 --- a/modules/applications/proc-utils.lua +++ b/modules/applications/proc-utils.lua @@ -1,11 +1,10 @@ +function pkill(P) + tT[P] = nil +end function killsession(sI) - local rt={} for k,v in ipairs(tT) do if v[3].sI == sI then - T.insert(rt,1,k) + pkill(k) end end - for k,v in ipairs(rt) do - T.remove(tT,v) - end end From 45abd567de4d840b2f541065ff1b1e8d6fea46a2 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Thu, 25 May 2017 00:57:10 +0000 Subject: [PATCH 35/56] added a minifier rule for tostring and tonumber, should reduce code size a fair bit --- modules/base/header.lua | 2 +- strip.lua | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/base/header.lua b/modules/base/header.lua index a9ee54e..05bc074 100644 --- a/modules/base/header.lua +++ b/modules/base/header.lua @@ -1,4 +1,4 @@ -tT,p,cT,pC,C,T={},1,1,1,coroutine,table +tT,p,cT,pC,C,T,TS,TN={},1,1,1,coroutine,table,tostring,tonumber function E() if tT[cT] ~= nil then return tT[cT][3] end end diff --git a/strip.lua b/strip.lua index cb8e3db..4428a89 100644 --- a/strip.lua +++ b/strip.lua @@ -25,6 +25,8 @@ replacements={ {"%-%-.-\n",""}, {"coroutine%.","C."}, {"table%.","T."}, +{"tostring","TS"}, +{"tonumber","TN"}, } for k,v in ipairs(replacements) do while ss:find(v[1]) ~= nil do From 4a10645316c11a14cae2293a4c60097ec1d07729 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Fri, 26 May 2017 13:01:15 +0000 Subject: [PATCH 36/56] fixed the IRC bridge - I forgot base64 --- configs/everything.cfg | 1 + modules.cfg | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/configs/everything.cfg b/configs/everything.cfg index a80d987..783826a 100644 --- a/configs/everything.cfg +++ b/configs/everything.cfg @@ -9,6 +9,7 @@ drivers/kbd.lua util/autogpu.lua util/sinit.lua library/net.lua +library/base64.lua library/fs-ext.lua library/readline.lua applications/nshd.lua diff --git a/modules.cfg b/modules.cfg index bf32d91..e481b38 100644 --- a/modules.cfg +++ b/modules.cfg @@ -4,13 +4,13 @@ library/fs-min.lua library/fs-std.lua library/fs-util.lua util/fs-automount.lua -util/sinit.lua drivers/tty.lua drivers/kbd.lua util/autogpu.lua library/net.lua library/fs-ext.lua library/readline.lua +library/base64.lua applications/nshd.lua applications/nshc.lua applications/shutil.lua From 9d0848b8ec61fe64ba486e72f0237634f5f7f62c Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Sat, 27 May 2017 17:26:57 +0000 Subject: [PATCH 37/56] added an initless everything configuration --- configs/everything-noinit.cfg | 20 ++++++++++++++++++++ configs/everything.cfg | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 configs/everything-noinit.cfg diff --git a/configs/everything-noinit.cfg b/configs/everything-noinit.cfg new file mode 100644 index 0000000..8275e79 --- /dev/null +++ b/configs/everything-noinit.cfg @@ -0,0 +1,20 @@ +base/header.lua +library/print.lua +library/fs-min.lua +library/fs-std.lua +library/fs-util.lua +util/fs-automount.lua +drivers/tty.lua +drivers/kbd.lua +util/autogpu.lua +library/net.lua +library/base64.lua +library/fs-ext.lua +library/readline.lua +applications/nshd.lua +applications/nshc.lua +applications/shutil.lua +applications/luash.lua +applications/ircbridge.lua +applications/autoluash.lua +base/footer.lua diff --git a/configs/everything.cfg b/configs/everything.cfg index 783826a..2f0295a 100644 --- a/configs/everything.cfg +++ b/configs/everything.cfg @@ -7,7 +7,6 @@ util/fs-automount.lua drivers/tty.lua drivers/kbd.lua util/autogpu.lua -util/sinit.lua library/net.lua library/base64.lua library/fs-ext.lua @@ -18,4 +17,5 @@ applications/shutil.lua applications/luash.lua applications/ircbridge.lua applications/autoluash.lua +util/sinit.lua base/footer.lua From 04246a63c6ad3f38fbff7c3d3600c0d34ea7a23f Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Sat, 27 May 2017 17:44:27 +0000 Subject: [PATCH 38/56] fixed a bug that had been annoying for me a bit with tab spacing --- modules/drivers/tty.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/drivers/tty.lua b/modules/drivers/tty.lua index 7f31c89..937a3ca 100644 --- a/modules/drivers/tty.lua +++ b/modules/drivers/tty.lua @@ -17,7 +17,7 @@ function tty(gA,sA,sI,fg,bg) if c == "\n" then cx,cy=1,cy+1 elseif c == "\r" then cx=1 elseif c == "\f" then cx=1 cy=1 gP.fill(1, 1, sx, sy, " ") - elseif c == "\t" then cx=cx+4-((cx+4)%4) + elseif c == "\t" then cx=(cx+4-((cx+4)%4))+1 elseif c == "\127" then cx=cx-1 gP.set(cx,cy," ") else gP.set(cx,cy,c) cx=cx+1 end cv() From 833b5f55048153aa5b771a46181fdffa51a77f43 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Sat, 27 May 2017 18:24:44 +0000 Subject: [PATCH 39/56] added a mediocre line editor, skex (2) --- configs/everything-noinit.cfg | 1 + configs/everything.cfg | 1 + modules/applications/skex2.lua | 63 ++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 modules/applications/skex2.lua diff --git a/configs/everything-noinit.cfg b/configs/everything-noinit.cfg index 8275e79..fc81ac6 100644 --- a/configs/everything-noinit.cfg +++ b/configs/everything-noinit.cfg @@ -14,6 +14,7 @@ library/readline.lua applications/nshd.lua applications/nshc.lua applications/shutil.lua +applications/skex2.lua applications/luash.lua applications/ircbridge.lua applications/autoluash.lua diff --git a/configs/everything.cfg b/configs/everything.cfg index 2f0295a..fc057cb 100644 --- a/configs/everything.cfg +++ b/configs/everything.cfg @@ -14,6 +14,7 @@ library/readline.lua applications/nshd.lua applications/nshc.lua applications/shutil.lua +applications/skex2.lua applications/luash.lua applications/ircbridge.lua applications/autoluash.lua diff --git a/modules/applications/skex2.lua b/modules/applications/skex2.lua new file mode 100644 index 0000000..1f3e2ac --- /dev/null +++ b/modules/applications/skex2.lua @@ -0,0 +1,63 @@ +function skex(s,f) + local c,cs,cT,lT,lP="","",{},{},1 + if s then + if f then + c=s + else + local f=fopen(s,"rb") + local nc=fread(f,2048) + while nc ~= nil and nc ~= "" do + c=c..nc + nc=fread(f,2048) + end + end + for l in c:gmatch("(.-)\n") do lT[#lT+1]=l end + end + while true do + cs=readln() + cT={} + for w in cs:gmatch("%S+") do cT[#cT+1]=w end + if cT[1] == "q" then break + elseif cT[1] == "l" then + for i = (TN(cT[2]) or 1), (TN(cT[3]) or #lT) do + print(TS(i).."\t"..(lT[i] or "")) + end + elseif cT[1] == "a" or cT[1] == "i" or cT[1] == "s" then + if TN(cT[2]) then lP=TN(cT[2]) end + if cT[1] == "s" then for i = 1,TN(cT[3]) do T.remove(lT,i+(TN(cT[2])-1)) end end + if cT[1] == "a" then lP=lP+1 end + while true do + cs=readln() + if cs~="." then + T.insert(lT,lP,cs) + lP=lP+1 + else break end + end + elseif cT[1] == "f" then + s=cT[2] or s + print(s) + elseif cT[1] == "e" then + c="" + for k,v in ipairs(lT) do c=c..v.."\n" end + print(pcall(load(c))) + elseif cT[1] == "w" then + f=fopen(s,"wb") + c="" + for k,v in ipairs(lT) do fwrite(f,v.."\n") end + fclose(f) + elseif cT[1] == "d" then + for i = 1, TN(cT[3])-TN(cT[2]) do + T.remove(lT,cT[2]) + end + elseif cT[1] == "p" then + nPT=TN(cT[2]) + if nPT then + lP=nPT + else + print(lP) + end + else + print("?") + end + end +end From cff032643e8478fb1b606898e524549108615fca Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Sun, 28 May 2017 11:58:53 +0000 Subject: [PATCH 40/56] added a module added before the other base stuff to load MultICE from OpenOS --- configs/everything-noinit.cfg | 1 + configs/everything.cfg | 1 + modules/base/loadlin.lua | 10 ++++++++++ 3 files changed, 12 insertions(+) create mode 100644 modules/base/loadlin.lua diff --git a/configs/everything-noinit.cfg b/configs/everything-noinit.cfg index fc81ac6..c018120 100644 --- a/configs/everything-noinit.cfg +++ b/configs/everything-noinit.cfg @@ -1,3 +1,4 @@ +base/loadlin.lua base/header.lua library/print.lua library/fs-min.lua diff --git a/configs/everything.cfg b/configs/everything.cfg index fc057cb..7df1420 100644 --- a/configs/everything.cfg +++ b/configs/everything.cfg @@ -1,3 +1,4 @@ +base/loadlin.lua base/header.lua library/print.lua library/fs-min.lua diff --git a/modules/base/loadlin.lua b/modules/base/loadlin.lua new file mode 100644 index 0000000..9e37a15 --- /dev/null +++ b/modules/base/loadlin.lua @@ -0,0 +1,10 @@ +if pcall(require,"computer") then + print("OpenOS detected.") + print("Please note that if you didn't call this with its full name, this will not work.") + print("eg: kernel.lua rather than just kernel") + local computer = require "computer" + local process = require "process" + os.execute("cp "..process.info().path.." /tmp/init.lua") + computer.setBootAddress(computer.tmpAddress()) + computer.shutdown(true) +end From 8b2d6778dc2332a1cd5180213ec83dce08f28254 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Sun, 28 May 2017 17:29:23 +0000 Subject: [PATCH 41/56] better detection for the path --- modules/base/loadlin.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/base/loadlin.lua b/modules/base/loadlin.lua index 9e37a15..cdd7938 100644 --- a/modules/base/loadlin.lua +++ b/modules/base/loadlin.lua @@ -1,10 +1,9 @@ if pcall(require,"computer") then print("OpenOS detected.") - print("Please note that if you didn't call this with its full name, this will not work.") - print("eg: kernel.lua rather than just kernel") + print(os.getenv("_")) local computer = require "computer" local process = require "process" - os.execute("cp "..process.info().path.." /tmp/init.lua") + os.execute("cp "..os.getenv("_").." /tmp/init.lua") computer.setBootAddress(computer.tmpAddress()) computer.shutdown(true) end From ed85e857ff2bff846a6cedabf95a210cc7df7555 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Mon, 12 Jun 2017 11:56:22 +0000 Subject: [PATCH 42/56] skex2 updates and documentation --- doc/skex2.md | 57 ++++++++++++++++++++++++++++++++++ modules/applications/skex2.lua | 47 +++++++++++++++------------- 2 files changed, 83 insertions(+), 21 deletions(-) create mode 100644 doc/skex2.md diff --git a/doc/skex2.md b/doc/skex2.md new file mode 100644 index 0000000..cdfc376 --- /dev/null +++ b/doc/skex2.md @@ -0,0 +1,57 @@ +# skex2 + +## interactive line editor + +skex2 is a simple but functional line editor for MultICE. + +### invocation + +To start skex2, simply run skex(filename) from the Lua prompt. + +### usage + +Generally, commands and arguments are entered in the form of `command argument1 argument2 argument3` with the exception of inline execution, which is in the form of `!lua code here`. + +If skex does not understand what you mean, it will output a line with a question mark. + +### commands + +#### q - quit skex2 + +Exits the program. + +#### l \[start\] \[end\] - list contents + +Output the lines from start to end, inclusive. + +#### f \[filename\] - set the filename + +This sets the filename to be used for I/O, or prints the current one. + +#### r \[filename\] - load file + +Reads from *filename* or the current set via **f** + +#### w \[filename\] - write to file + +Writes to *filename* or the current set via **f** + +#### p \[line\] - print or set current line + +As skex2 is a line editor, your pointer is a line, and this either prints the current one or sets a new one. + +#### a \[line\] - append to buffer + +Appends lines after the current line or *line* until a line with only . is entered. + +#### i \[line\] - insert into buffer + +Inserts lines before the current line or *line* until a line with only . is entered. + +#### s \[line\] - replace line + +Removes the current line or *line* and enters insert mode + +#### e - executes the contents of the buffer + +Basically converts it into one big string and loads it. diff --git a/modules/applications/skex2.lua b/modules/applications/skex2.lua index 1f3e2ac..95f5240 100644 --- a/modules/applications/skex2.lua +++ b/modules/applications/skex2.lua @@ -1,16 +1,20 @@ -function skex(s,f) +function skex(s) local c,cs,cT,lT,lP="","",{},{},1 - if s then - if f then - c=s - else - local f=fopen(s,"rb") - local nc=fread(f,2048) - while nc ~= nil and nc ~= "" do - c=c..nc - nc=fread(f,2048) - end + local function lf(s) + local f=fopen(s,"rb") + local nc=fread(f,2048) + while nc ~= nil and nc ~= "" do + c=c..nc + nc=fread(f,2048) end + end + local function wf(s) + local f,c=fopen(s,"wb"),"" + for k,v in ipairs(lT) do fwrite(f,v.."\n") end + fclose(f) + end + if s then + lf(s) for l in c:gmatch("(.-)\n") do lT[#lT+1]=l end end while true do @@ -40,22 +44,23 @@ function skex(s,f) c="" for k,v in ipairs(lT) do c=c..v.."\n" end print(pcall(load(c))) + elseif cT[1] == "r" then + s=cT[2] or s + wf(s) elseif cT[1] == "w" then - f=fopen(s,"wb") - c="" - for k,v in ipairs(lT) do fwrite(f,v.."\n") end - fclose(f) + s=cT[2] or s + wf(s) elseif cT[1] == "d" then for i = 1, TN(cT[3])-TN(cT[2]) do T.remove(lT,cT[2]) end elseif cT[1] == "p" then - nPT=TN(cT[2]) - if nPT then - lP=nPT - else - print(lP) - end + lP=TN(cT[2]) or lP + print(lP) + elseif cs:sub(1,1) == "!" then + c="" + for k,v in ipairs(lT) do c=c..v.."\n" end + print(pcall(load(cs:sub(2)))) else print("?") end From eaa4eb7d86bffc82d85c74db06757beed7c0938f Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Mon, 12 Jun 2017 14:28:15 +0000 Subject: [PATCH 43/56] FS library updates --- modules/library/fs-std.lua | 8 ++++++++ modules/library/fs-util.lua | 9 ++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/library/fs-std.lua b/modules/library/fs-std.lua index 5fec249..8988f32 100644 --- a/modules/library/fs-std.lua +++ b/modules/library/fs-std.lua @@ -21,6 +21,14 @@ function fread(h,n) end return false end +function freadall(f) + local s="" + repeat + c=fread(f,2048) + s=s..c + until c=="" + return s +end function fwrite(h,d) if hT[h] then return hT[h][1].write(hT[h][2],d) diff --git a/modules/library/fs-util.lua b/modules/library/fs-util.lua index 2ab6bc5..408b0ce 100644 --- a/modules/library/fs-util.lua +++ b/modules/library/fs-util.lua @@ -17,14 +17,9 @@ function fmove(i,o) frm(i) end function fload(i) - local f,s = fopen(i,"rb"),"" + local f = fopen(i,"rb") if f then - local c=fread(f,math.huge) - repeat - s=s..c - c=fread(f,math.huge) - until c == nil - return load(s) + return load(freadall(f)) end return false end From b54a2c0390c16c9eb02233d226eaf30e52fe736c Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Mon, 12 Jun 2017 14:35:56 +0000 Subject: [PATCH 44/56] Fix the IRC bridge to work with OETF#7, properly this time. --- modules/applications/ircbridge.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/applications/ircbridge.lua b/modules/applications/ircbridge.lua index bd5022e..716aa3d 100644 --- a/modules/applications/ircbridge.lua +++ b/modules/applications/ircbridge.lua @@ -29,7 +29,7 @@ function ircb(h,p,n) -- host, port if t and f and p and ms then t,f,p,ms = ub64(t),n..":"..ub64(f),ub64(p),ub64(ms) for k,v in ipairs(tM) do - v.broadcast(nP,t,f,p,ms) + v.broadcast(nVL,nP,t,f,p,ms) end end else From c1e9e31cf019926947f6b7ca3c4578dc32ea3103 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Mon, 12 Jun 2017 14:39:06 +0000 Subject: [PATCH 45/56] changed shutil to return strings rather than straight-up print stuff --- modules/applications/shutil.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/applications/shutil.lua b/modules/applications/shutil.lua index e66dce3..7ad4641 100644 --- a/modules/applications/shutil.lua +++ b/modules/applications/shutil.lua @@ -1,12 +1,12 @@ function ps() + local S="" for k,v in pairs(tT) do - write("pid: "..tostring(k).."\tname: "..tostring(v[1]).."\tenv={") - for l,w in pairs(v[3]) do write(tostring(l).." = "..tostring(w)..", ") end - print("}") + S=S..("pid: "..tostring(k).."\tname: "..tostring(v[1]).."\tenv={") + for l,w in pairs(v[3]) do S=S..(tostring(l).." = "..tostring(w)..", ") end + S=S.."}\n" end + return S end function mem() - print("Total:\t"..tostring(computer.totalMemory()/1024).."K") - print("Free:\t"..tostring(computer.freeMemory()/1024).."K") - print("Used:\t"..tostring((computer.totalMemory()-computer.freeMemory())/1024).."K") + return "Total:\t"..tostring(computer.totalMemory()/1024).."K\nFree:\t"..tostring(computer.freeMemory()/1024).."K\nUsed:\t"..tostring((computer.totalMemory()-computer.freeMemory())/1024).."K" end From 36442751b9603db5cd82e82c12284fd4f0b8cf27 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Mon, 12 Jun 2017 23:40:56 +0000 Subject: [PATCH 46/56] added some ocemu-related debug modules --- modules/debug/ocemu-display.lua | 7 +++++++ modules/debug/ocemu-heartbeat.lua | 9 +++++++++ 2 files changed, 16 insertions(+) create mode 100644 modules/debug/ocemu-display.lua create mode 100644 modules/debug/ocemu-heartbeat.lua diff --git a/modules/debug/ocemu-display.lua b/modules/debug/ocemu-display.lua new file mode 100644 index 0000000..ccc75f6 --- /dev/null +++ b/modules/debug/ocemu-display.lua @@ -0,0 +1,7 @@ +s("ocemu display server",function() + while true do + if ev[1] == "display" then + component.invoke(component.list("ocemu")(),"log",ev[2] or "") + end + end +end) diff --git a/modules/debug/ocemu-heartbeat.lua b/modules/debug/ocemu-heartbeat.lua new file mode 100644 index 0000000..1753748 --- /dev/null +++ b/modules/debug/ocemu-heartbeat.lua @@ -0,0 +1,9 @@ +_G.DEBUG=true +s("heartbeat",function() + while true do + if _G.DEBUG then + component.invoke(component.list("ocemu")(),"log","heartbeat:"..tostring(computer.uptime())) + end + C.yield() + end +end) From e7ad19730761017f6b7e54ec04a826f921726e77 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Mon, 12 Jun 2017 23:42:00 +0000 Subject: [PATCH 47/56] cleaned up sinit a bit. Still sucks. --- modules/util/sinit.lua | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/modules/util/sinit.lua b/modules/util/sinit.lua index 8af4ae3..9132c67 100644 --- a/modules/util/sinit.lua +++ b/modules/util/sinit.lua @@ -2,19 +2,12 @@ s("init",function() local f=fopen("boot:/init.cfg","rb") write("") if f then - local c="" - local nc=fread(f,2048) - while nc ~= nil and nc ~= "" do - c=c..nc - nc=fread(f,2048) - end + c=freadall(f) for l in c:gmatch("[^\n]+") do write("[init] "..l..": ") local pf=fload(l) print(pcall(pf)) + C.yield() end end - if _OSVERSION and _BD then - print("Started ".._OSVERSION.." (built at ".._BD..")") - end -end,{["sI"]=1}) +end) From a89ff3f6cdf7bb73032ce5ea0b7c6e60adcab0a3 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Mon, 12 Jun 2017 23:47:05 +0000 Subject: [PATCH 48/56] fixed a stupid bug --- modules/debug/ocemu-display.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/debug/ocemu-display.lua b/modules/debug/ocemu-display.lua index ccc75f6..f40a72a 100644 --- a/modules/debug/ocemu-display.lua +++ b/modules/debug/ocemu-display.lua @@ -3,5 +3,6 @@ s("ocemu display server",function() if ev[1] == "display" then component.invoke(component.list("ocemu")(),"log",ev[2] or "") end + C.yield() end end) From d122d67c51a69316a3e1d6b3b3dcd6fe92e657ff Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Mon, 12 Jun 2017 23:54:21 +0000 Subject: [PATCH 49/56] applied same fix to embedded version --- modules/applications/ircbridge-embedded.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/applications/ircbridge-embedded.lua b/modules/applications/ircbridge-embedded.lua index e56715a..45f01e2 100644 --- a/modules/applications/ircbridge-embedded.lua +++ b/modules/applications/ircbridge-embedded.lua @@ -26,7 +26,7 @@ function ircb(h,p,n) -- host, port if t and f and p and ms then t,f,p,ms = ub64(t),n..":"..ub64(f),ub64(p),ub64(ms) for k,v in ipairs(tM) do - v.broadcast(nP,t,f,p,ms) + v.broadcast(nVL,nP,t,f,p,ms) end end else From 6361815eeb7c4e4d8e2bdeeb3f060aee4bbbd37a Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Mon, 12 Jun 2017 23:55:13 +0000 Subject: [PATCH 50/56] added a banner to luash, also prints _G.motd now --- modules/applications/luash.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/applications/luash.lua b/modules/applications/luash.lua index 8099f66..fd7b534 100644 --- a/modules/applications/luash.lua +++ b/modules/applications/luash.lua @@ -1,5 +1,9 @@ function luash(si) s("lua shell",function() + if _OSVERSION and _BD then + write(_OSVERSION.." (built at ".._BD..")\t") + end + print(tostring(computer.freeMemory()/1024).."K free.",_G.motd) print(_VERSION) while true do write("> ") From fdeba4f8acd2f2318fe3b9d1e7e39b87a176b7f6 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Mon, 12 Jun 2017 23:58:10 +0000 Subject: [PATCH 51/56] added recent changes to everything configs --- configs/everything-noinit.cfg | 2 ++ configs/everything.cfg | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/configs/everything-noinit.cfg b/configs/everything-noinit.cfg index c018120..89a75bc 100644 --- a/configs/everything-noinit.cfg +++ b/configs/everything-noinit.cfg @@ -1,6 +1,8 @@ base/loadlin.lua base/header.lua library/print.lua +debug/ocemu-display.lua +debug/ocemu-heartbeat.lua library/fs-min.lua library/fs-std.lua library/fs-util.lua diff --git a/configs/everything.cfg b/configs/everything.cfg index 7df1420..27c129d 100644 --- a/configs/everything.cfg +++ b/configs/everything.cfg @@ -1,6 +1,8 @@ base/loadlin.lua base/header.lua library/print.lua +debug/ocemu-display.lua +debug/ocemu-heartbeat.lua library/fs-min.lua library/fs-std.lua library/fs-util.lua @@ -18,6 +20,6 @@ applications/shutil.lua applications/skex2.lua applications/luash.lua applications/ircbridge.lua -applications/autoluash.lua util/sinit.lua +applications/autoluash.lua base/footer.lua From 508b7d0d232eba7251d2f7866368c2efa3b55c46 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Tue, 13 Jun 2017 00:08:58 +0000 Subject: [PATCH 52/56] switched on logging by default --- build.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cfg b/build.cfg index 93be19e..cb8f480 100644 --- a/build.cfg +++ b/build.cfg @@ -1,5 +1,5 @@ optimise no listmods yes test no -log no +log yes opath kernel.lua From 22f9d7c299d7a4c7383e56da1da49a4a12161a5a Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Tue, 13 Jun 2017 00:34:48 +0000 Subject: [PATCH 53/56] added ping.lua to the everything configs --- configs/everything-noinit.cfg | 1 + configs/everything.cfg | 1 + 2 files changed, 2 insertions(+) diff --git a/configs/everything-noinit.cfg b/configs/everything-noinit.cfg index 89a75bc..7c47d43 100644 --- a/configs/everything-noinit.cfg +++ b/configs/everything-noinit.cfg @@ -11,6 +11,7 @@ drivers/tty.lua drivers/kbd.lua util/autogpu.lua library/net.lua +net/ping.lua library/base64.lua library/fs-ext.lua library/readline.lua diff --git a/configs/everything.cfg b/configs/everything.cfg index 27c129d..2cfe9ea 100644 --- a/configs/everything.cfg +++ b/configs/everything.cfg @@ -11,6 +11,7 @@ drivers/tty.lua drivers/kbd.lua util/autogpu.lua library/net.lua +net/ping.lua library/base64.lua library/fs-ext.lua library/readline.lua From 1eadd5ef3c8bd7ac742bdec16dc3c94a156c7fab Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Tue, 13 Jun 2017 14:51:01 +0000 Subject: [PATCH 54/56] general improvements to ocemu-heartbeat and sinit. for reasons. --- modules/debug/ocemu-heartbeat.lua | 2 ++ modules/util/sinit.lua | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/debug/ocemu-heartbeat.lua b/modules/debug/ocemu-heartbeat.lua index 1753748..d2a7e29 100644 --- a/modules/debug/ocemu-heartbeat.lua +++ b/modules/debug/ocemu-heartbeat.lua @@ -3,6 +3,8 @@ s("heartbeat",function() while true do if _G.DEBUG then component.invoke(component.list("ocemu")(),"log","heartbeat:"..tostring(computer.uptime())) + component.invoke(component.list("ocemu")(),"log",T.unpack(ev)) + component.invoke(component.list("ocemu")(),"log","processes:\n"..ps()) end C.yield() end diff --git a/modules/util/sinit.lua b/modules/util/sinit.lua index 9132c67..4616be6 100644 --- a/modules/util/sinit.lua +++ b/modules/util/sinit.lua @@ -2,7 +2,7 @@ s("init",function() local f=fopen("boot:/init.cfg","rb") write("") if f then - c=freadall(f) + local c=freadall(f) for l in c:gmatch("[^\n]+") do write("[init] "..l..": ") local pf=fload(l) From cfa2899f066d31635153ad3b66e35b1e4720fc34 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Tue, 13 Jun 2017 14:52:32 +0000 Subject: [PATCH 55/56] removed the ocemu stuff from normal builds and into their own debug build. --- configs/everything-debug.cfg | 25 +++++++++++++++++++++++++ configs/everything-noinit.cfg | 2 -- configs/everything.cfg | 2 -- 3 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 configs/everything-debug.cfg diff --git a/configs/everything-debug.cfg b/configs/everything-debug.cfg new file mode 100644 index 0000000..0bae616 --- /dev/null +++ b/configs/everything-debug.cfg @@ -0,0 +1,25 @@ +base/loadlin.lua +base/header.lua +debug/ocemu-display.lua +debug/ocemu-heartbeat.lua +library/print.lua +library/fs-min.lua +library/fs-std.lua +library/fs-util.lua +util/fs-automount.lua +drivers/tty.lua +drivers/kbd.lua +util/autogpu.lua +library/net.lua +net/ping.lua +library/base64.lua +library/fs-ext.lua +library/readline.lua +applications/nshd.lua +applications/nshc.lua +applications/shutil.lua +applications/skex2.lua +applications/luash.lua +applications/ircbridge.lua +applications/autoluash.lua +base/footer.lua diff --git a/configs/everything-noinit.cfg b/configs/everything-noinit.cfg index 7c47d43..c2fd437 100644 --- a/configs/everything-noinit.cfg +++ b/configs/everything-noinit.cfg @@ -1,8 +1,6 @@ base/loadlin.lua base/header.lua library/print.lua -debug/ocemu-display.lua -debug/ocemu-heartbeat.lua library/fs-min.lua library/fs-std.lua library/fs-util.lua diff --git a/configs/everything.cfg b/configs/everything.cfg index 2cfe9ea..b89a40c 100644 --- a/configs/everything.cfg +++ b/configs/everything.cfg @@ -1,8 +1,6 @@ base/loadlin.lua base/header.lua library/print.lua -debug/ocemu-display.lua -debug/ocemu-heartbeat.lua library/fs-min.lua library/fs-std.lua library/fs-util.lua From b203f01973c1ad956e4b6cc38497825eb363880b Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Tue, 13 Jun 2017 14:54:42 +0000 Subject: [PATCH 56/56] made build.lua test by default. --- build.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cfg b/build.cfg index cb8f480..6a49090 100644 --- a/build.cfg +++ b/build.cfg @@ -1,5 +1,5 @@ optimise no listmods yes -test no +test yes log yes opath kernel.lua