From d496ba127eac9d1211919be212e8d780ff7cad3a Mon Sep 17 00:00:00 2001 From: JakobCh Date: Mon, 23 Mar 2020 12:30:44 +0100 Subject: [PATCH 1/3] Make selfextract actually print out the "bad magic" error --- utils/selfextract.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/selfextract.lua b/utils/selfextract.lua index 29d76e8..d82bdee 100644 --- a/utils/selfextract.lua +++ b/utils/selfextract.lua @@ -118,13 +118,14 @@ local function read_header(dat) end local ent = {} ent.magic, ent.namesize, ent.mode, ent.uid, ent.gid, ent.filesize, ent.mtime = string.unpack(e..header_fmt, dat) - return ent + return ent, "" end local lname = "" while lname ~= "TRAILER!!!" do local dat = read(22) - local e = read_header(dat) + local e,r = read_header(dat) + if r ~= "" then print(r) return end e.name = read(e.namesize) e.pos = seek(e.namesize & 1) seek(e.filesize + (e.filesize & 1)) From 376ccc11a37aef1d0c34f3dafbb3d01c640cb70f Mon Sep 17 00:00:00 2001 From: JakobCh Date: Mon, 23 Mar 2020 13:33:27 +0100 Subject: [PATCH 2/3] Add support to boot from plan9k filesystems --- util/OpenOS/config.d/02_plan9k.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 util/OpenOS/config.d/02_plan9k.lua diff --git a/util/OpenOS/config.d/02_plan9k.lua b/util/OpenOS/config.d/02_plan9k.lua new file mode 100644 index 0000000..190da4c --- /dev/null +++ b/util/OpenOS/config.d/02_plan9k.lua @@ -0,0 +1,12 @@ +local cfgadd = ... +local comp = require("component") +for fs in comp.list("filesystem") do + if comp.invoke(fs, "getLabel") == "Plan9k" and comp.invoke(fs, "exists", "init.lua") then + print("Plan9k discovered on "..fs) + cfgadd(string.format([[ +menu.add("Plan9k on %s", function() + return loadmod("loader_openos")("%s") +end) +]], fs:sub(1, 3), fs)) + end +end \ No newline at end of file From 782c99df080f50de810285281f387b007b9b51fc Mon Sep 17 00:00:00 2001 From: Adorable-Catgirl Date: Mon, 23 Mar 2020 15:50:55 -0400 Subject: [PATCH 3/3] Use assert instead of print. --- utils/selfextract.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/utils/selfextract.lua b/utils/selfextract.lua index d82bdee..0a60787 100644 --- a/utils/selfextract.lua +++ b/utils/selfextract.lua @@ -118,14 +118,13 @@ local function read_header(dat) end local ent = {} ent.magic, ent.namesize, ent.mode, ent.uid, ent.gid, ent.filesize, ent.mtime = string.unpack(e..header_fmt, dat) - return ent, "" + return ent end local lname = "" while lname ~= "TRAILER!!!" do local dat = read(22) - local e,r = read_header(dat) - if r ~= "" then print(r) return end + local e = assert(read_header(dat)) e.name = read(e.namesize) e.pos = seek(e.namesize & 1) seek(e.filesize + (e.filesize & 1)) @@ -144,4 +143,4 @@ for i=1, #tbl do end end -error("Init not found.") \ No newline at end of file +error("Init not found.")