formating better for spm packages

This commit is contained in:
2026-03-26 08:12:37 -04:00
parent 22b5021e9d
commit ab0a10105c
193 changed files with 4228 additions and 464 deletions
@@ -7,7 +7,8 @@ local disks=EFI.disks
local arch=EFI.architecture
local kernel = {}
kernel.LOG_Text=""
kernel.version="HyperionOS V1.2.4"
kernel.version="HyperionOS V1.2.4-dev_5"
kernel.tag="1.2.4-dev_5"
kernel.process = "Kernel"
kernel.users={[0]="root",[1]="User"}
kernel.hostname = "hyperion"
@@ -22,7 +23,7 @@ kernel._G=_G
kernel.sleep=sleep
_G.sleep=nil
local windowsExp = false
local windowsExp = true
function kernel.log(msg, level, c)
c=c or 0x6D6D6D
@@ -51,7 +52,7 @@ function kernel.PANIC(msg)
screen:setTextColor(0xFF0000)
screen:setBackgroundColor(0x000000)
screen:clear()
screen:setCursorPos(1,1)
screen:resetCursor()
screen:print(kernel.LOG_Text)
screen:print("KERNEL PANIC!\n"..msg.."\nSystem halted.")
screen:print("Press any key to continue...")
@@ -72,17 +73,11 @@ if windowsExp then
screen:setTextColor(0xFFFFFF)
screen:setBackgroundColor(0x0000FF)
screen:clear()
local w,h = screen:getSize()
screen:setCursorPos(3,5)
screen:print(":(")
screen:setCursorPos(3,7)
screen:print("Your PC ran into a problem and needs to restart. We're just collecting some error")
screen:setCursorPos(3,8)
screen:print("info, and then we'll restart for you.\n")
screen:setCursorPos(3,h-5)
screen:print("Stop code: average windows experience")
screen:setCursorPos(1,h)
screen:print("Press any key to continue... jk reboot it yourself lazy")
screen:resetCursor()
screen:print("\n\n\n\n\n :(")
screen:print("\n Your PC ran into a problem and needs to restart. We're just collecting some error")
screen:print(" info, and then we'll restart for you.\n")
screen:print("\n\n\n Stop code: average windows experience")
while true do end
end
@@ -254,6 +249,7 @@ end
kernel.syscalls["time"]=function() return kernel.EFI:getEpochMs() end
kernel.syscalls["date"]=function() return kernel.EFI:date() end
kernel.syscalls["log"]=kernel.log
kernel.syscalls["tag"]=function() return kernel.tag end
kernel.syscalls["getUptime"]=function() return kernel.EFI:getUptime() end
kernel.syscalls["getUsername"]=function(uid) return kernel.users[uid or kernel.uid] end
kernel.syscalls["getHostname"]=function() return kernel.hostname end
@@ -7,6 +7,5 @@ return {
initPath = "/sbin/init",
maxOpenFiles = 128,
maxFilesPerTask = 16,
preempt=true,
logTaskExit=true
preempt=true
}
@@ -129,6 +129,8 @@ local function validateComponent(comp)
end
if lower == ".meta" then
error("EINVAL: reserved path component: .meta", 3)
elseif lower:sub(#lower) == "." then
error("Cannot have empty name extention: " .. comp, 3)
end
end
@@ -397,6 +399,10 @@ end
local function getFileMeta(path, noFollow)
local real = namei(path, noFollow)
if kernel.unixSockets[real] then
return kernel.unixSockets[real].meta
end
if real == "/" then
return { etype = 0x00, owner = 0, group = 0, perms = 62, cmeta = "" }
end
@@ -596,8 +602,8 @@ function vfs.open(path, mode)
if not disk then error("NODISK") end
if (mode=="w" or mode=="a") and disk:isReadOnly() then error("ERDONLY") end
if kernel.unixSockets[normalizePath(path)] then
local meta = kernel.unixSockets[normalizePath(path)].meta
if kernel.unixSockets[namei(path)] then
local meta = kernel.unixSockets[namei(path)].meta
if kernel.uid~=0 or kernel.uid~=meta.owner then
local groups = (task and task.groups) or kernel.groups or {}
local access=false
@@ -606,7 +612,7 @@ function vfs.open(path, mode)
end
if not access then error("EACCES") end
end
task[fd]=kernel.unixSockets[normalizePath(path)]
task[fd]=kernel.unixSockets[namei(path)]
return fd
end
@@ -711,12 +717,11 @@ end
function vfs.stat(path)
local attrs
local meta
local disk, diskPath = resolvePath(path)
local meta = getFileMeta(path)
if meta.etype == 0x02 then
attrs = { size=0, modified=0, created=0 }
else
local disk, diskPath = resolvePath(path)
meta = getFileMeta(path)
local ok
ok, attrs = pcall(disk.attributes, disk, diskPath)
if not ok then attrs = { size=0, modified=0, created=0 } end
@@ -856,13 +861,13 @@ function vfs.remove(path)
local meta = getFileMeta(path, true)
if kernel.unixSockets and kernel.unixSockets[normalizePath(path)] then
if kernel.unixSockets[namei(path)] then
if kernel.uid ~= 0 then
if kernel.unixSockets[normalizePath(path)].meta.owner~=kernel.uid then
if kernel.unixSockets[namei(path)].meta.owner~=kernel.uid then
error("EACCES")
end
end
kernel.unixSockets[normalizePath(path)] = nil
kernel.unixSockets[namei(path)] = nil
end
if meta.etype == 0x01 then
@@ -973,7 +978,7 @@ local function updateMeta(path, fn, noFollow)
end
function vfs.chmod(path, perms)
if kernel.unixSockets[normalizePath(path)] then error("EINVAL") end
if kernel.unixSockets[namei(path)] then error("EINVAL") end
local disk = resolveMount(path)
if disk:isReadOnly() then error("ERDONLY") end
local meta = getFileMeta(path)
@@ -985,12 +990,12 @@ end
function vfs.fchmod(fd, perms)
local file = kernel.currentTask.fd[fd]
if not file then error("EBADF") end
if file.etype==0x02 then error("EINVAL") end
if file.meta.etype==0x02 then error("EINVAL") end
vfs.chmod(file.path, perms)
end
function vfs.chown(path, uid, gid)
if kernel.unixSockets[normalizePath(path)] then error("EINVAL") end
if kernel.unixSockets[namei(path)] then error("EINVAL") end
local disk = resolveMount(path)
if disk:isReadOnly() then error("ERDONLY") end
local _euid = (kernel.currentTask and (kernel.currentTask.euid or kernel.currentTask.uid)) or kernel.uid
@@ -1001,14 +1006,14 @@ end
function vfs.fchown(fd, uid, gid)
local file = kernel.currentTask.fd[fd]
if not file then error("EBADF") end
if file.etype==0x02 then error("EINVAL") end
if file.meta.etype==0x02 then error("EINVAL") end
vfs.chown(file.path, uid, gid)
end
function vfs.exists(path)
if kernel.unixSockets[normalizePath(path)] then return true end
if kernel.unixSockets[namei(path)] then return true end
local meta = getFileMeta(path, true)
if meta.etype == 0x01 then return true end
if meta.etype == 0x01 or meta.etype == 0x02 then return true end
local ok, disk, diskPath = pcall(resolvePath, path)
if not ok then return false end
if disk:type(diskPath) then
@@ -1021,7 +1026,7 @@ end
function vfs.type(path)
local meta = getFileMeta(path, true)
if meta.etype == 0x01 then return "symlink" end
if kernel.unixSockets[normalizePath(path)] then
if kernel.unixSockets[namei(path)] then
return "socket"
end
local ok, disk, diskPath = pcall(resolvePath, path)
@@ -50,7 +50,7 @@ function proxy:type(path, mode)
if type(step[steps[#steps]]) == "table" then
return "directory"
end
error(type(step[steps[#steps]]))
error("ENOENT")
end
function proxy:list(path)
@@ -28,15 +28,15 @@ function socket.socket()
local P=kernel.vfs.P
local data=kernel.newFifo()
local isClosed=false
kernel.vfs.newfd({
return kernel.vfs.newfd({
handle={
read=function() if isClosed then error("ECCON") end return data.read() end,
write=function() if isClosed then error("ECCON") end return data.write() end,
read=function() if isClosed then error("ECCON") end return data.pop() end,
write=function(data) if isClosed then error("ECCON") end return data.push(data) end,
close=function() isClosed = true end
},
type="socket",
refcount=1,
socket={},
meta={
owner=kernel.currentTask.uid,
group=kernel.currentTask.uid,
@@ -48,11 +48,20 @@ function socket.socket()
end
function socket.connect(fd, address)
local handler
for k, v in pairs(socket.handlers) do
if string.hasPrefix(address, k) then
handler=v
end
end
handler.connect(kernel.currentTask.fd[fd], address)
end
function socket.listen(fd, backlog)
error("Not Implemented")
end
kernel.log("Loaded socket module")
local sys=kernel.syscalls
sys["socket"]=socket.socket
kernel.log("Loaded socket module")
@@ -0,0 +1,4 @@
--:Minify:--
local kernel=...
kernel.unixSockets={}
local socket=kernel.socket
@@ -203,12 +203,14 @@ function sys.collect(pid)
end
end
function sys.kill(pid)
function sys.kill(pid, force)
local task = tasks[tostring(pid)]
if not task then
return false, "Task does not exist"
elseif task.status == "Z" then
return false, "Task is already dead"
elseif task.status == "D" and not force then
return false, "Cannot kill task waiting for IO"
end
local caller = kernel.currentTask
local ceuid = caller and (caller.euid or caller.uid) or kernel.uid
@@ -223,10 +225,14 @@ function sys.stop(pid)
local task = tasks[tostring(pid)]
if not task then
return false, "Task does not exist"
elseif task.status ~= "R" then
elseif task.status ~= "R" and task.status ~= "S" then
return false, "Cannot stop non-running task"
else
task.status = "T"
if task.status == "S" then
task.status = "ST"
else
task.status = "T"
end
return true
end
end
@@ -235,10 +241,14 @@ function sys.continue(pid)
local task = tasks[tostring(pid)]
if not task then
return false, "Task does not exist"
elseif task.status ~= "T" then
elseif task.status ~= "T" and task.status ~= "ST" then
return false, "Task is not stopped"
else
task.status = "R"
if task.status == "ST" then
task.status = "S"
else
task.status = "R"
end
return true
end
end
@@ -351,6 +361,11 @@ function kernel.main()
task.sleep = 0
end
if task.status == "ST" and kernel.EFI:getEpochMs() >= task.sleep then
task.status = "T"
task.sleep = 0
end
if task.status == "D" then
if task.ksh then
coroutine.resume(task.ksh)
@@ -364,14 +379,19 @@ function kernel.main()
if task.sigq and #task.sigq ~= 0 and task.sigh then
local coro = coroutine.create(task.sigh)
local status,err=coroutine.resumeWithTimeout(coro, 100, table.remove(task.sigq, 1))
if status=="error" then
task.sigd.error=err
local status,err
if kernel.config.preempt then
status,err=coroutine.resumeWithTimeout(coro, 100, table.remove(task.sigq, 1))
else
status,err=coroutine.resume(coro, table.remove(task.sigq, 1))
end
if status=="error" or status==false then
task.sigd.error=err or "Unknown"
task.sigd.active=false
task.sigh=nil
task.sigq=nil
task.sigd=nil
elseif status=="success" then
elseif status=="success" or status==true then
if err=="syscall" then
task.sigd.error="Cannot execute syscalls from signals"
task.sigd.active=false
@@ -1,3 +0,0 @@
--:Minify:--
local kernel=...
kernel.unixSockets={}