diff --git a/Src/Hyperion-core/lib/sys/fs b/Src/Hyperion-core/lib/fs similarity index 100% rename from Src/Hyperion-core/lib/sys/fs rename to Src/Hyperion-core/lib/fs diff --git a/Src/Hyperion-core/lib/io b/Src/Hyperion-core/lib/io index 9a94a48..e0eb470 100644 --- a/Src/Hyperion-core/lib/io +++ b/Src/Hyperion-core/lib/io @@ -1,5 +1,5 @@ local io = {} -local fs = require("sys.fs") +local fs = require("fs") function io.open(path, mode) return fs.open(path, mode) diff --git a/Src/Hyperion-core/lib/snip b/Src/Hyperion-core/lib/snip deleted file mode 100644 index e69de29..0000000 diff --git a/Src/Hyperion-core/lib/sys/hpv b/Src/Hyperion-core/lib/sys/hpv deleted file mode 100644 index b6ad280..0000000 --- a/Src/Hyperion-core/lib/sys/hpv +++ /dev/null @@ -1,6 +0,0 @@ -local sys = {} -local fs = require("sys.fs") - - - -return sys \ No newline at end of file diff --git a/Src/Hyperion-core/lib/sys/init b/Src/Hyperion-core/lib/sys/init deleted file mode 100644 index 3ce5639..0000000 --- a/Src/Hyperion-core/lib/sys/init +++ /dev/null @@ -1,5 +0,0 @@ -local sys = {} -sys.fs = require("sys.fs") -sys.hpv = require("sys.hpv") -sys.ipc = require("sys.ipc") -return sys \ No newline at end of file diff --git a/Src/Hyperion-core/lib/sys/ipc b/Src/Hyperion-core/lib/sys/ipc deleted file mode 100644 index bcc01b9..0000000 --- a/Src/Hyperion-core/lib/sys/ipc +++ /dev/null @@ -1,3 +0,0 @@ -local ipc = {} - -return ipc \ No newline at end of file diff --git a/Src/Hyperion-core/lib/sys/term b/Src/Hyperion-core/lib/sys/term deleted file mode 100644 index 88db99e..0000000 --- a/Src/Hyperion-core/lib/sys/term +++ /dev/null @@ -1,71 +0,0 @@ -local term = {} - -function term.clear() - coroutine.yield("VFS_write", 1, "\27C\25") -end - -function term.setCursorPos(x, y) - coroutine.yield("VFS_write", 1, "\27cs"..tostring(y)..";"..tostring(x).."\25") -end - -function term.size() - coroutine.yield("VFS_write", 1, "\27ts\25") - local ok, data = coroutine.yield("VFS_read", 0, 16) -- read response - if not ok then error("Failed to get terminal size") end - local x, y = string.match(data, "%R(%d+);(%d+)\25") - return tonumber(x), tonumber(y) -end - -function term.getCursorPos() - coroutine.yield("VFS_write", 1, "\27gc\25") - local ok, data = coroutine.yield("VFS_read", 0, 16) -- read response - if not ok then error("Failed to get cursor position") end - local y, x = string.match(data, "%R(%d+);(%d+)\25") - return tonumber(x), tonumber(y) -end - -function term.write(data) - coroutine.yield("VFS_write", 1, data) -end - -function term.setTextColor(color) - local ok, err = coroutine.yield("VFS_type", 1) - if not ok then error(err) end - if ok ~= "tty" then return end - coroutine.yield("VFS_write", 1, "\27f"..tostring(color).."\25") -end - -function term.setBackgroundColor(color) - local ok, err = coroutine.yield("VFS_type", 1) - if not ok then error(err) end - if ok ~= "tty" then return end - coroutine.yield("VFS_write", 1, "\27b"..tostring(color).."\25") -end - -function term.isColor() - local ok, err = coroutine.yield("VFS_type", 1) - if not ok then error(err) end - return ok == "tty" -end - -function term.scroll(n) - coroutine.yield("VFS_write", 1, "\27S"..tostring(n).."\25") -end - -function term.setDefault(color, layer) - if layer then - coroutine.yield("VFS_write", 1, "\27F"..tostring(color).."\25") - else - coroutine.yield("VFS_write", 1, "\27B"..tostring(color).."\25") - end -end - -function term.showCursor(show) - if show then - coroutine.yield("VFS_write", 1, "\27sc\25") - else - coroutine.yield("VFS_write", 1, "\27hc\25") - end -end - -return term \ No newline at end of file diff --git a/Src/Hyperion-kernel/boot/fstab b/Src/Hyperion-kernel/boot/fstab index ba670ab..0f7573d 100644 --- a/Src/Hyperion-kernel/boot/fstab +++ b/Src/Hyperion-kernel/boot/fstab @@ -1,3 +1,4 @@ U $;/ U devfs0000;/dev/ -U tmpfs0000;/tmp/ \ No newline at end of file +U tmpfs0000;/tmp/ +U procfs0000;/proc/ \ No newline at end of file diff --git a/Src/Hyperion-kernel/lib/modules/hyperion/01_stdlib.kmod b/Src/Hyperion-kernel/lib/modules/hyperion/01_stdlib.kmod index acec657..36fec1a 100644 --- a/Src/Hyperion-kernel/lib/modules/hyperion/01_stdlib.kmod +++ b/Src/Hyperion-kernel/lib/modules/hyperion/01_stdlib.kmod @@ -1,4 +1,5 @@ --:Minify:-- +--- @diagnostic disable: duplicate-set-field local kernel = ... kernel.allowGlobalOverwrites = true diff --git a/Src/Hyperion-kernel/lib/modules/hyperion/12_procfs.kmod b/Src/Hyperion-kernel/lib/modules/hyperion/12_procfs.kmod new file mode 100644 index 0000000..9690ba2 --- /dev/null +++ b/Src/Hyperion-kernel/lib/modules/hyperion/12_procfs.kmod @@ -0,0 +1,83 @@ +--:Minify:-- +local kernel = ... + +local proxy = {} +local data = {} + +proxy.address = "procfs0000" +proxy.isvirt = true +proxy.isReadOnly = function() return false end +proxy.spaceUsed = function() return 0 end +proxy.spaceTotal = function() return 0 end +proxy.makeDirectory = function() error("EACCES") end +proxy.remove = function() error("EACCES") end +proxy.setLabel = function() error("EACCES") end +proxy.getLabel = function() return "procfs" end +proxy.attributes = function(path) return { + size = 0, + modified = 0, + created = 0 +} end + +function proxy:open(path, mode) + local steps = kernel.vfs.splitPath(path) + local step = data + for i=1, #steps-1 do + local dat = step[steps[i]] + if type(dat) ~= "table" then error("ENFILE") end + step=dat + end + if type(step[steps[#steps]]) == "function" then + return step[steps[#steps]]("open", mode) + end + error("ENFILE") +end + +function proxy:type(path, mode) + local steps = kernel.vfs.splitPath(path) + local step = data + if #steps == 0 then + return "directory" + end + for i=1, #steps-1 do + local dat = step[steps[i]] + if type(dat) ~= "table" then error("ENFILE") end + step=dat + end + if type(step[steps[#steps]]) == "function" then + return step[steps[#steps]]("type", mode) + end + if type(step[steps[#steps]]) == "table" then + return "directory" + end + error("ENOENT") +end + +function proxy:list(path) + local steps = kernel.vfs.splitPath(path) + local step = data + if #steps == 0 then + return table.keys(data) + end + for i=1, #steps-1 do + local dat = step[steps[i]] + if type(dat) ~= "table" then error("ENOENT") end + step=dat + end + if type(step[steps[#steps]]) == "table" then + return table.keys(step[steps[#steps]]) + end + error("ENOENT") +end + +function proxy:fileExists(path) + local ok = pcall(function() + return self:type(path) + end) + return ok +end + +kernel.procfs={} +kernel.procfs.data=data +kernel.procfs.proxy=proxy +kernel.disks["procfs0000"]=proxy \ No newline at end of file diff --git a/Src/Hyperion-core/lib/bit32 b/Src/bit32/lib/bit32 similarity index 100% rename from Src/Hyperion-core/lib/bit32 rename to Src/bit32/lib/bit32 diff --git a/Src/Hyperion-core/lib/crypto/blake2s b/Src/blake2s/lib/crypto/blake2s similarity index 100% rename from Src/Hyperion-core/lib/crypto/blake2s rename to Src/blake2s/lib/crypto/blake2s diff --git a/Src/Hyperion-core/lib/LibDeflate b/Src/deflate/lib/LibDeflate similarity index 100% rename from Src/Hyperion-core/lib/LibDeflate rename to Src/deflate/lib/LibDeflate diff --git a/Src/Hyperion-core/lib/deflate b/Src/deflate/lib/deflate similarity index 100% rename from Src/Hyperion-core/lib/deflate rename to Src/deflate/lib/deflate diff --git a/Src/hysh/bin/hysh b/Src/hysh/bin/hysh index 0f41b2f..23ce7a5 100644 --- a/Src/hysh/bin/hysh +++ b/Src/hysh/bin/hysh @@ -5,7 +5,7 @@ syscall.open("/dev/null","w") --stderr (device 2) local success, errorMsg = xpcall(function() -local fs = require("sys.fs") +local fs = require("fs") syscall.devctl(1,"clear") syscall.devctl(1,"sfgc",1) diff --git a/Src/hysh/bin/loimgcreate b/Src/hysh/bin/loimgcreate index 76d9699..6fca0dc 100644 --- a/Src/hysh/bin/loimgcreate +++ b/Src/hysh/bin/loimgcreate @@ -43,7 +43,7 @@ if opts.help then return end -local fs = require("sys.fs") +local fs = require("fs") if opts.x then if #args < 2 then diff --git a/Src/hysh/bin/ls b/Src/hysh/bin/ls index 97c7126..be98f0e 100644 --- a/Src/hysh/bin/ls +++ b/Src/hysh/bin/ls @@ -45,7 +45,7 @@ if cloptions.help then return end -local fs = require("sys.fs") +local fs = require("fs") local dir = args[1] or "" if dir:sub(1, 1) ~= "/" then dir = syscall.getcwd() .. "/" .. dir @@ -84,7 +84,7 @@ local function humanSize(size) size = size / 1024 scale = scale + 1 end - if scale == 0 then return tostring(size) end + if scale == 0 then return tostring(size).."B" end if size < 10 then return string.format("%.1f%s", size, sizePrefixes[scale]) end diff --git a/Src/hysh/bin/sudo b/Src/hysh/bin/sudo index a843cba..6fc29eb 100644 --- a/Src/hysh/bin/sudo +++ b/Src/hysh/bin/sudo @@ -1,5 +1,5 @@ --:Minify:-- -local fs = require("sys.fs") +local fs = require("fs") local cmdArgs = {...} local targetUser = "root" diff --git a/Src/hysh/bin/userdel b/Src/hysh/bin/userdel index 8f4e798..e4d5842 100644 --- a/Src/hysh/bin/userdel +++ b/Src/hysh/bin/userdel @@ -29,7 +29,7 @@ if not ok then end if removeHome and pwent and pwent.homedir then - local fs = require("sys.fs") + local fs = require("fs") local ok2, err2 = pcall(function() local function rmdir(path) for _, f in ipairs(fs.list(path) or {}) do diff --git a/Src/Hyperion-core/lib/json b/Src/json/lib/json similarity index 100% rename from Src/Hyperion-core/lib/json rename to Src/json/lib/json diff --git a/Src/sysinit/$PKGCONFIG.ini b/Src/sysinit/$PKGCONFIG.ini new file mode 100644 index 0000000..c5153d4 --- /dev/null +++ b/Src/sysinit/$PKGCONFIG.ini @@ -0,0 +1 @@ +[symlinks] diff --git a/Src/sysinit/usr/lib/sysinit/sysinit b/Src/sysinit/usr/lib/sysinit/sysinit index 518774c..58be0c9 100644 --- a/Src/sysinit/usr/lib/sysinit/sysinit +++ b/Src/sysinit/usr/lib/sysinit/sysinit @@ -1,6 +1,6 @@ --:Minify:-- local kernel=... -local fs=require("sys.fs") +local fs=require("fs") for i,v in pairs(kernel.processes) do kernel.log("Spawning kernel task "..i) diff --git a/Test/HyperionOS-units/bin/hunit b/Test/HyperionOS-units/bin/hunit index 7e96c8d..cf6e040 100644 --- a/Test/HyperionOS-units/bin/hunit +++ b/Test/HyperionOS-units/bin/hunit @@ -1,4 +1,4 @@ -local fs=require("sys.fs") +local fs=require("fs") local units=fs.list("/usr/lib/hunit/") fs.mkdir("/tmp/hunit/") local errors={} diff --git a/Test/HyperionOS-units/usr/lib/hunit/dir.unit b/Test/HyperionOS-units/usr/lib/hunit/dir.unit index 78c5a3f..1d3c79e 100644 --- a/Test/HyperionOS-units/usr/lib/hunit/dir.unit +++ b/Test/HyperionOS-units/usr/lib/hunit/dir.unit @@ -1,3 +1,3 @@ -local fs = require("sys.fs") +local fs = require("fs") assert(fs.mkdir("/tmp/hunit/testdir"), "failed to make directory") assert(fs.isDir("/tmp/hunit/testdir"), "directory does not exist") \ No newline at end of file diff --git a/build.py b/build.py index 43a9177..c110788 100644 --- a/build.py +++ b/build.py @@ -90,6 +90,9 @@ def process_root(src_root: Path, out_root: Path, minify: bool, micro: bool): continue rel = src.relative_to(pkg_dir) + if rel=="$PKGCONFIG.ini": + continue + dst = out_root / rel dst.parent.mkdir(parents=True, exist_ok=True)