more reorganizeing and $PKGCONFIG.ini files added B to ls -lh for "Bytes"

This commit is contained in:
2026-03-09 11:28:09 -04:00
parent a69f945b91
commit 1590e1f3f7
25 changed files with 100 additions and 96 deletions

View File

@@ -1,5 +1,5 @@
local io = {} local io = {}
local fs = require("sys.fs") local fs = require("fs")
function io.open(path, mode) function io.open(path, mode)
return fs.open(path, mode) return fs.open(path, mode)

View File

@@ -1,6 +0,0 @@
local sys = {}
local fs = require("sys.fs")
return sys

View File

@@ -1,5 +0,0 @@
local sys = {}
sys.fs = require("sys.fs")
sys.hpv = require("sys.hpv")
sys.ipc = require("sys.ipc")
return sys

View File

@@ -1,3 +0,0 @@
local ipc = {}
return ipc

View File

@@ -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

View File

@@ -1,3 +1,4 @@
U $;/ U $;/
U devfs0000;/dev/ U devfs0000;/dev/
U tmpfs0000;/tmp/ U tmpfs0000;/tmp/
U procfs0000;/proc/

View File

@@ -1,4 +1,5 @@
--:Minify:-- --:Minify:--
--- @diagnostic disable: duplicate-set-field
local kernel = ... local kernel = ...
kernel.allowGlobalOverwrites = true kernel.allowGlobalOverwrites = true

View 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

View File

@@ -5,7 +5,7 @@ syscall.open("/dev/null","w") --stderr (device 2)
local success, errorMsg = xpcall(function() local success, errorMsg = xpcall(function()
local fs = require("sys.fs") local fs = require("fs")
syscall.devctl(1,"clear") syscall.devctl(1,"clear")
syscall.devctl(1,"sfgc",1) syscall.devctl(1,"sfgc",1)

View File

@@ -43,7 +43,7 @@ if opts.help then
return return
end end
local fs = require("sys.fs") local fs = require("fs")
if opts.x then if opts.x then
if #args < 2 then if #args < 2 then

View File

@@ -45,7 +45,7 @@ if cloptions.help then
return return
end end
local fs = require("sys.fs") local fs = require("fs")
local dir = args[1] or "" local dir = args[1] or ""
if dir:sub(1, 1) ~= "/" then if dir:sub(1, 1) ~= "/" then
dir = syscall.getcwd() .. "/" .. dir dir = syscall.getcwd() .. "/" .. dir
@@ -84,7 +84,7 @@ local function humanSize(size)
size = size / 1024 size = size / 1024
scale = scale + 1 scale = scale + 1
end end
if scale == 0 then return tostring(size) end if scale == 0 then return tostring(size).."B" end
if size < 10 then if size < 10 then
return string.format("%.1f%s", size, sizePrefixes[scale]) return string.format("%.1f%s", size, sizePrefixes[scale])
end end

View File

@@ -1,5 +1,5 @@
--:Minify:-- --:Minify:--
local fs = require("sys.fs") local fs = require("fs")
local cmdArgs = {...} local cmdArgs = {...}
local targetUser = "root" local targetUser = "root"

View File

@@ -29,7 +29,7 @@ if not ok then
end end
if removeHome and pwent and pwent.homedir then if removeHome and pwent and pwent.homedir then
local fs = require("sys.fs") local fs = require("fs")
local ok2, err2 = pcall(function() local ok2, err2 = pcall(function()
local function rmdir(path) local function rmdir(path)
for _, f in ipairs(fs.list(path) or {}) do for _, f in ipairs(fs.list(path) or {}) do

View File

@@ -0,0 +1 @@
[symlinks]

View File

@@ -1,6 +1,6 @@
--:Minify:-- --:Minify:--
local kernel=... local kernel=...
local fs=require("sys.fs") local fs=require("fs")
for i,v in pairs(kernel.processes) do for i,v in pairs(kernel.processes) do
kernel.log("Spawning kernel task "..i) kernel.log("Spawning kernel task "..i)

View File

@@ -1,4 +1,4 @@
local fs=require("sys.fs") local fs=require("fs")
local units=fs.list("/usr/lib/hunit/") local units=fs.list("/usr/lib/hunit/")
fs.mkdir("/tmp/hunit/") fs.mkdir("/tmp/hunit/")
local errors={} local errors={}

View File

@@ -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.mkdir("/tmp/hunit/testdir"), "failed to make directory")
assert(fs.isDir("/tmp/hunit/testdir"), "directory does not exist") assert(fs.isDir("/tmp/hunit/testdir"), "directory does not exist")

View File

@@ -90,6 +90,9 @@ def process_root(src_root: Path, out_root: Path, minify: bool, micro: bool):
continue continue
rel = src.relative_to(pkg_dir) rel = src.relative_to(pkg_dir)
if rel=="$PKGCONFIG.ini":
continue
dst = out_root / rel dst = out_root / rel
dst.parent.mkdir(parents=True, exist_ok=True) dst.parent.mkdir(parents=True, exist_ok=True)