forked from Hyperion/HyperionOS
more reorganizeing and $PKGCONFIG.ini files added B to ls -lh for "Bytes"
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
local sys = {}
|
||||
local fs = require("sys.fs")
|
||||
|
||||
|
||||
|
||||
return sys
|
||||
@@ -1,5 +0,0 @@
|
||||
local sys = {}
|
||||
sys.fs = require("sys.fs")
|
||||
sys.hpv = require("sys.hpv")
|
||||
sys.ipc = require("sys.ipc")
|
||||
return sys
|
||||
@@ -1,3 +0,0 @@
|
||||
local ipc = {}
|
||||
|
||||
return ipc
|
||||
@@ -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
|
||||
@@ -1,3 +1,4 @@
|
||||
U $;/
|
||||
U devfs0000;/dev/
|
||||
U tmpfs0000;/tmp/
|
||||
U tmpfs0000;/tmp/
|
||||
U procfs0000;/proc/
|
||||
@@ -1,4 +1,5 @@
|
||||
--:Minify:--
|
||||
--- @diagnostic disable: duplicate-set-field
|
||||
local kernel = ...
|
||||
kernel.allowGlobalOverwrites = true
|
||||
|
||||
|
||||
83
Src/Hyperion-kernel/lib/modules/hyperion/12_procfs.kmod
Normal file
83
Src/Hyperion-kernel/lib/modules/hyperion/12_procfs.kmod
Normal file
@@ -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
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
--:Minify:--
|
||||
local fs = require("sys.fs")
|
||||
local fs = require("fs")
|
||||
|
||||
local cmdArgs = {...}
|
||||
local targetUser = "root"
|
||||
|
||||
@@ -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
|
||||
|
||||
1
Src/sysinit/$PKGCONFIG.ini
Normal file
1
Src/sysinit/$PKGCONFIG.ini
Normal file
@@ -0,0 +1 @@
|
||||
[symlinks]
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user