working on api docs

This commit is contained in:
Astronand committed 2026-11-26 21:06:36 -05:00
1 parent 56d8fb2016
commit 38d56ced19
43 files changed
+5669 -618

No files matched your search

@@ -258,7 +258,7 @@ internal["root"] = createDisk("root", "/root", false, {
end,
getLabel = function()
local h = fs.open("/.rootlabel", "r")
if not h then return "$" end
if not h then return "root" end
local label = h.readAll()
h.close()
return label
@@ -266,14 +266,23 @@ internal["root"] = createDisk("root", "/root", false, {
})
local function refresh()
local exclude = {root=true,rom=true,["$"]=true}
disks={}
for _, disk in ipairs({peripheral.find("drive")}) do
if disk.isDiskPresent() then
disks[tostring(disk.getDiskID())]=createDisk("cctdisk"..tostring(disk.getDiskID()), disk.getMountPath(), false, fs)
for i,v in ipairs(fs.list("/")) do
if fs.isDir("/"..v) and not exclude[v] then
local uid=""
local h=fs.open("/"..v.."/.fsid", "r")
if not h then
uid=string.format("%X",math.random(0,2^32))
local h2=fs.open("/"..v.."/.fsid", "w")
h2.write(uid)
h2.close()
else uid=h.readAll(); h.close() end
disks[uid]=createDisk(uid,"/"..v,false,{})
end
end
end
local function iter()
refresh()
local combined = {}
+15 -6
View File
@@ -27,19 +27,19 @@ kernel.sleep=sleep
_G.sleep=nil
local windowsExp = false
function kernel.log(msg, level, c, nopanic)
function kernel.log(msg, tag, c, nopanic)
local f=function()
c=c or 0x6D6D6D
kernel.LOG_Text = kernel.LOG_Text..tostring(EFI:date()).." "..kernel.users[kernel.uid].." "..kernel.process.."["..tostring(level or "INFO").."]: "..msg.."\n"
kernel.LOG_Text = kernel.LOG_Text..tostring(EFI:date()).." "..kernel.users[kernel.uid].." "..kernel.process.."["..tostring(tag or "INFO").."]: "..msg.."\n"
if kernel.status == "start" then
screen:setTextColor(c)
screen:print(tostring(EFI:date()).." "..kernel.users[kernel.uid].." "..kernel.process.."["..tostring(level or "INFO").."]: "..msg)
screen:print(tostring(EFI:date()).." "..kernel.users[kernel.uid].." "..kernel.process.."["..tostring(tag or "INFO").."]: "..msg)
elseif kernel.status == "term" then
kernel.standbyTask=kernel.currentTask
kernel.currentTask=kernel.kernelTask
local file=kernel.vfs.open("/dev/console", "w")
kernel.vfs.devctl(file,"sfgc",c)
kernel.vfs.write(file,tostring(EFI:date()).." "..kernel.users[kernel.uid].." "..kernel.process.."["..tostring(level or "INFO").."]: "..msg.."\n")
kernel.vfs.write(file,tostring(EFI:date()).." "..kernel.users[kernel.uid].." "..kernel.process.."["..tostring(tag or "INFO").."]: "..msg.."\n")
kernel.vfs.close(file)
kernel.currentTask=kernel.standbyTask
end
@@ -379,7 +379,16 @@ function kernel.runWhenLoaded(func)
kernel.runhooks[#kernel.runhooks+1] = func
return #kernel.runhooks
end
--[[
function kernel.loadModule(data)
if kernel.vfs.exists(data) then
local f=kernel.vfs.open(data,"r")
data=kernel.vfs.read(1024*1024*4)
kernel.vfs.close(f)
end
local func=load(data, "RuntimeModule")
end
]]
kernel.kernelTask = {
name="kernel",
status="R",
@@ -518,4 +527,4 @@ elseif kernel.status=="halt" then
else
EFI.status="shutdown"
return true
end
end
@@ -1,9 +1,13 @@
--:Minify:--
---@type HyperionOS.kernel
local kernel = ...
---@type HyperionOS.kernel.vfs
local vfs = {}
kernel.vfs = vfs
vfs.mounts = {}
vfs.disks = kernel.disks
vfs.openfiles = {}
-- Metafile format (version 2)
-- File header: 1 byte = version (0x02)
@@ -1229,4 +1233,4 @@ end
sys["getOpenFds"]= vfs.getOpenFds
sys["fsinfo"] = vfs.fsinfo
kernel.log("VFS module loaded")
kernel.log("VFS module loaded")
@@ -301,11 +301,70 @@ for i,v in pairs(kernel.vfs.mounts) do
end
local function newdev(path, device)
if kernel.uid ~= 0 then error("EACCES") end
if type(path) ~= "string" or path == "" then
error("EINVAL")
end
if type(device) ~= "function" then
error("EINVAL")
end
-- Normalize path
path = path:gsub("^/+", ""):gsub("/+$", "")
if path == "" then error("EINVAL") end
local steps = kernel.vfs.splitPath(path)
if #steps == 0 then error("EINVAL") end
local step = data
-- Create intermediate directories
for i = 1, #steps - 1 do
local name = steps[i]
if name == "." or name == ".." then
error("EINVAL")
end
local entry = step[name]
if entry == nil then
entry = {}
step[name] = entry
elseif type(entry) ~= "table" then
error("ENOTDIR")
end
step = entry
end
local name = steps[#steps]
if name == "." or name == ".." then
error("EINVAL")
end
-- Don't overwrite existing devices or directories
if step[name] ~= nil then
error("EEXIST")
end
-- Register device
step[name] = device
return true
end
data["raw"]={["by-type"]={}}
data["gfx"]={}
data["input"]={}
data["tty"]={}
kernel.devfs={}
kernel.devfs.newdev=newdev
kernel.syscalls.newdev=kernel.devfs.newdev
kernel.devfs.data=data
kernel.devfs.proxy=proxy
kernel.disks["devfs0000"]=proxy
@@ -230,7 +230,6 @@ function sys.getTask(pid)
siblings = siblings,
parent = task.parent.pid,
cwd = task.cwd,
term = task.term,
}
end
@@ -21,22 +21,25 @@ function printInline(...)
syscall.write(1, output)
end
function userinput(fd, helpstr, replacestr, fdo)
fd = fd or 0
fdo = fdo or 1
local str = ""
if helpstr then print(helpstr) end
while true do
local inp = syscall.read(fd)
if inp~="" and inp~=nil then
if inp~="\n" then
if replacestr then
syscall.write(fdo, replacestr)
else
syscall.write(fdo, inp)
end
str = inp
else
if inp and inp ~= "" then
if inp == "\n" then
break
end
if replacestr then
syscall.write(fdo, replacestr)
else
syscall.write(fdo, inp)
end
str = str .. inp
end
end
return str
@@ -7,6 +7,8 @@ kernel.processes.kgc = function()
-- kernel.reqcache[i] = nil
-- end
--end
sleep(5)
end
end
+8 -1
View File
@@ -103,7 +103,14 @@ local function spawnShell(username, uid, shell, homedir)
local shellfunc, err = load(fs.readAllText(shell))
local ok, err = pcall(syscall.spawn, shellfunc, username .. ":shell", nil,nil,nil,true)
local function loader()
syscall.open("/dev/input/keyboard1", "r")
syscall.open("/dev/tty/1", "w")
syscall.open("/dev/null", "w")
shellfunc()
end
local ok, err = pcall(syscall.spawn, loader, username .. ":shell", nil,nil,nil,true)
if not ok then
syscall.write(1, "login: failed to launch shell: " .. tostring(err) .. "\n")
sleep(2)
+8 -1
View File
@@ -103,7 +103,14 @@ local function spawnShell(username, uid, shell, homedir)
local shellfunc, err = load(fs.readAllText(shell))
local ok, err = pcall(syscall.spawn, shellfunc, username .. ":shell", nil,nil,nil,true)
local function loader()
syscall.open("/dev/input/keyboard1", "r")
syscall.open("/dev/tty/1", "w")
syscall.open("/dev/null", "w")
shellfunc()
end
local ok, err = pcall(syscall.spawn, loader, username .. ":shell", nil,nil,nil,true)
if not ok then
syscall.write(1, "login: failed to launch shell: " .. tostring(err) .. "\n")
sleep(2)
+1 -1
View File
@@ -147,4 +147,4 @@ for i = 2, #args do
end
end
syscall.exit(exitCode)
syscall.exit(exitCode)
+9 -4
View File
@@ -1,11 +1,16 @@
--:Minify:--
local success, errorMsg = xpcall(function()
syscall.open("/dev/input/keyboard1","r") --stdin (Device 0)
syscall.open("/dev/tty/1","w") --stdout (Device 1)
syscall.open("/dev/null","w") --stderr (device 2)
local fs = require("fs")
local fds=syscall.getOpenFds()
syscall.log(table.serialize(fds))
if not fds[0] or not fds[1] then
syscall.log("opening fds")
syscall.open("/dev/input/keyboard1", "r")
syscall.open("/dev/tty/1", "w")
end
local gfx = syscall.devctl(1,"gfx")
syscall.devctl(1,"clear")
+2
View File
@@ -0,0 +1,2 @@
Hyperion
Astronand
+10
View File
@@ -0,0 +1,10 @@
--:Minify:--
local args={...}
if type(args[1])~="string" then print("Usage: wget [url]"); syscall.exit() end
local http = require("http")
local fs = require("fs")
print("GET: "..args[1])
local resp = http.get(args[1])
local clean_url = args[1]:match("^([^?#]+)")
local filename = clean_url:match("^.+/(.+)$")
fs.writeAllText(filename, resp.body)
+1
View File
@@ -0,0 +1 @@
Hyperion-core
+1
View File
@@ -0,0 +1 @@
simple wget command
+1
View File
@@ -0,0 +1 @@
1.0.0