GFX update :D
This commit is contained in:
1 parent
05ca0f10a2
commit
c1b4ef2644
70 files changed
+1398
-5174
No files matched your search
@@ -74,7 +74,7 @@ function kernel.PANIC(msg)
|
||||
break
|
||||
end
|
||||
end
|
||||
EFI.reboot=true
|
||||
EFI.status="reboot"
|
||||
error("KERNEL PANIC")
|
||||
end
|
||||
kernel.panic=kernel.PANIC
|
||||
@@ -179,7 +179,6 @@ if not root then
|
||||
if event[1]=="keyTyped" then
|
||||
if tonumber(event[3]) then
|
||||
if canadates[tonumber(event[3])] then
|
||||
ifs.writeAllText("/boot/fstab", "U "..canadates[tonumber(event[3])]..";/\n"..fstab)
|
||||
fstab="U "..canadates[tonumber(event[3])]..";/\n"..fstab
|
||||
ifs.mount(canadates[tonumber(event[3])], "/")
|
||||
break
|
||||
@@ -359,7 +358,7 @@ kernel.perTaskHooks={}
|
||||
kernel.mainHooks={}
|
||||
kernel.runhooks={}
|
||||
|
||||
-- args {taskobj}
|
||||
-- args {taskobj, pid}
|
||||
function kernel.execPerTask(func, prior)
|
||||
if not kernel.perTaskHooks[prior] then kernel.perTaskHooks[prior]={} end
|
||||
kernel.perTaskHooks[prior][#kernel.perTaskHooks[prior]+1] = func
|
||||
@@ -460,6 +459,7 @@ kernel.syscalls["saveLog"]=function()
|
||||
end
|
||||
end
|
||||
|
||||
ifs.writeAllText("/boot/fstab", fstab)
|
||||
kernel.saveLog()
|
||||
kernel.log("Running modules")
|
||||
for _,p in ipairs(modules) do
|
||||
@@ -471,7 +471,7 @@ for _,p in ipairs(modules) do
|
||||
if not code then
|
||||
kernel.panic("Failed to read module "..v)
|
||||
end
|
||||
local func,err=load(code,"@"..v)
|
||||
local func,err=load(code,"@"..v,"t",_G)
|
||||
if not func then kernel.panic("ModuLoadErr: "..tostring(err)) end
|
||||
local status, err = xpcall(func,debug.traceback, kernel)
|
||||
if not status then kernel.panic("ModuRunErr: "..tostring(err)) end
|
||||
@@ -502,10 +502,13 @@ if kernel.status=="panic" then
|
||||
kernel.panic(kernel.reason)
|
||||
end
|
||||
if kernel.status=="reboot" then
|
||||
EFI.reboot=true
|
||||
EFI.status="reboot"
|
||||
return true
|
||||
elseif kernel.status=="halt" then
|
||||
kernel.log("System halted.")
|
||||
kernel.saveLog()
|
||||
while true do end
|
||||
else
|
||||
EFI.status="shutdown"
|
||||
return true
|
||||
end
|
||||
@@ -2,6 +2,16 @@
|
||||
--- @diagnostic disable: duplicate-set-field
|
||||
local kernel = ...
|
||||
kernel.allowGlobalOverwrites = true
|
||||
local oldtype = type
|
||||
local oldgetmetatable = getmetatable
|
||||
|
||||
function math.round(x)
|
||||
if x>=0 then
|
||||
return math.floor(x+0.5)
|
||||
else
|
||||
return math.ceil(x-0.5)
|
||||
end
|
||||
end
|
||||
|
||||
function string.hasSuffix(str, suffix)
|
||||
return string.sub(str, #suffix + 1) == suffix
|
||||
@@ -70,6 +80,10 @@ function table.hasVal(tabl, query)
|
||||
return false
|
||||
end
|
||||
|
||||
function table.readOnly(tabl, typ)
|
||||
return setmetatable({},{__index=tabl,__newindex=function()error("Table is read-only")end,__usermeta=false,__type=typ})
|
||||
end
|
||||
|
||||
local function serialize(tbl, seen)
|
||||
seen = seen or {}
|
||||
|
||||
@@ -100,6 +114,8 @@ local function serialize(tbl, seen)
|
||||
output = output .. "\"" .. tostring(v) .. "\""
|
||||
elseif type(v) == "thread" then
|
||||
output = output .. "\"" .. tostring(v) .. "\""
|
||||
elseif oldgetmetatable(v) and oldgetmetatable(v).__tostring then
|
||||
output = output .. tostring(v)
|
||||
else
|
||||
error("serialization of type \"" .. type(v) .. "\" is not supported")
|
||||
end
|
||||
@@ -111,8 +127,6 @@ local function serialize(tbl, seen)
|
||||
return output
|
||||
end
|
||||
|
||||
local oldtype = type
|
||||
local oldgetmetatable = getmetatable
|
||||
function type(object, trueType)
|
||||
if trueType then return oldtype(object) end
|
||||
if oldtype(object) ~= "table" then
|
||||
@@ -131,7 +145,7 @@ end
|
||||
function getmetatable(object)
|
||||
if oldtype(object) ~= "table" then return end
|
||||
if oldtype(oldgetmetatable(object)) == "table" then
|
||||
if oldgetmetatable(object).__isuserdata then
|
||||
if oldgetmetatable(object).__usermeta then
|
||||
if oldtype(oldgetmetatable(object).__usermeta) == "function" then
|
||||
return oldgetmetatable(object).__usermeta()
|
||||
else
|
||||
@@ -251,8 +265,6 @@ local function makeSyscallProxy()
|
||||
local backing = {}
|
||||
return setmetatable(backing, {
|
||||
__index = function(self, name)
|
||||
local raw = rawget(self, name)
|
||||
if raw ~= nil then return raw end
|
||||
return function(...)
|
||||
local res = table.pack(coroutine.yield("syscall", name, ...))
|
||||
if res[1] then
|
||||
@@ -263,7 +275,7 @@ local function makeSyscallProxy()
|
||||
end
|
||||
end,
|
||||
__newindex = function(self, k, v)
|
||||
rawset(self, k, v)
|
||||
error("Table is read-only")
|
||||
end,
|
||||
__metatable=false
|
||||
})
|
||||
@@ -271,6 +283,5 @@ end
|
||||
|
||||
syscall = makeSyscallProxy()
|
||||
|
||||
_makeSyscallProxy = makeSyscallProxy
|
||||
|
||||
table.serialize = serialize
|
||||
|
||||
@@ -299,6 +299,7 @@ local function namei(path, noFollow, symDepth)
|
||||
if not target or target == "" then
|
||||
error("ENOENT: empty symlink target")
|
||||
end
|
||||
if kernel.config.logSymlinkTraverse then kernel.log(curPath .. " > " .. target) end
|
||||
|
||||
local symIsAbs, symTokens = tokenizePath(target)
|
||||
|
||||
@@ -1158,7 +1159,27 @@ function vfs.devlst(fd)
|
||||
return table.keys(kernel.currentTask.fd[fd].handle)
|
||||
end
|
||||
|
||||
function vfs.getOpenFds()
|
||||
local out={}
|
||||
for i,v in ipairs(kernel.currentTask.fd) do
|
||||
out[i]=v.path
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
function vfs.fsinfo()
|
||||
local out={mounts={},disks={}}
|
||||
for i,v in pairs(vfs.mounts) do
|
||||
out.mounts[i]=v
|
||||
end
|
||||
for i,v in pairs(vfs.disks) do
|
||||
out.disks[i]={size=vfs.disks[i].spaceTotal(),used=vfs.disks[i].spaceUsed(),label=vfs.disks[i].getLabel(),readOnly=vfs.disks[i].isReadOnly(),isVirt=vfs.disks[i].isvirt,address=vfs.disks[i].addressz}
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
vfs.resolveMount = resolveMount
|
||||
vfs.updateMeta = updateMeta
|
||||
|
||||
local sys = kernel.syscalls
|
||||
sys["open"] = vfs.open
|
||||
@@ -1198,5 +1219,7 @@ sys["fget_suid"] = function(fd)
|
||||
local fobj = kernel.currentTask and kernel.currentTask.fd[fd]
|
||||
return fobj and fobj.suid_owner or nil
|
||||
end
|
||||
sys["getOpenFds"]= vfs.getOpenFds
|
||||
sys["fsinfo"] = vfs.fsinfo
|
||||
|
||||
kernel.log("VFS module loaded")
|
||||
@@ -7,8 +7,12 @@ kernel.searchpaths = {
|
||||
}
|
||||
kernel.reqcache = cache
|
||||
|
||||
local function wrap(lib)
|
||||
return setmetatable({},{__index=lib,__newindex=function()error("Table is read-only")end,__usermeta=false,__call=function(s,...) return lib.new(...) end})
|
||||
end
|
||||
|
||||
local function require(module, ...)
|
||||
if cache[module] then return cache[module].ret end
|
||||
if cache[module] then return wrap(cache[module].ret) end
|
||||
local args = {...}
|
||||
for _, path in ipairs(kernel.searchpaths) do
|
||||
local filepath = path:gsub("?", module)
|
||||
@@ -36,8 +40,8 @@ local function require(module, ...)
|
||||
if not ok then
|
||||
error("Error running module "..module..": "..tostring(ret))
|
||||
end
|
||||
cache[module] = {ret = ret, expires = kernel.EFI:getEpochMs() + 120000}
|
||||
return ret
|
||||
cache[module] = {ret = ret}
|
||||
return wrap(ret)
|
||||
end
|
||||
coroutine.yield()
|
||||
end
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
--:Minify:--
|
||||
local kernel = ...
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
--:Minify:--
|
||||
local kernel = ...
|
||||
|
||||
local proxy = {}
|
||||
local data = {}
|
||||
|
||||
proxy.address = "devfs0000"
|
||||
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 "devfs" 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.sysfs={}
|
||||
kernel.sysfs.proxy=proxy
|
||||
kernel.disks["sysfs0000"]=proxy
|
||||
@@ -37,7 +37,7 @@ kernel.execPerTask(function(task)
|
||||
if task.sigq and #task.sigq ~= 0 and task.sigh then
|
||||
local coro = coroutine.create(task.sigh)
|
||||
local status,err=coroutine.resume(coro, table.remove(task.sigq, 1))
|
||||
EFI:yeild()
|
||||
kernel.EFI:yield()
|
||||
if status=="error" or status==false then
|
||||
task.sigd.error=err or "Unknown"
|
||||
task.sigd.active=false
|
||||
|
||||
@@ -2,3 +2,5 @@
|
||||
local kernel=...
|
||||
kernel.unixSockets={}
|
||||
local socket=kernel.socket
|
||||
|
||||
--socket.registerProtocal()
|
||||
@@ -58,10 +58,12 @@ kernel._U.load = function(a,b,c,d) return origLoad(a,b,c,d or kernel._U) end
|
||||
|
||||
function kernel.freshUserEnv()
|
||||
local locals = {}
|
||||
locals.syscall = _makeSyscallProxy()
|
||||
|
||||
local env = setmetatable(locals, {
|
||||
__index = kernel._U,
|
||||
__pairs = function(self)
|
||||
return pairs(kernel._U)
|
||||
end,
|
||||
__newindex = function(_, k, v) rawset(locals, k, v) end,
|
||||
__metatable=false
|
||||
})
|
||||
|
||||
@@ -33,7 +33,7 @@ local function createVt(id, width, height)
|
||||
end
|
||||
end
|
||||
|
||||
function vt.obj:write(content)
|
||||
function vt.obj.write(content)
|
||||
local x, y = vt.cursorX, vt.cursorY
|
||||
if x>vt.width then return end
|
||||
if y>vt.height then return end
|
||||
@@ -79,36 +79,36 @@ local function createVt(id, width, height)
|
||||
vt.cursorX, vt.cursorY = x, y
|
||||
end
|
||||
|
||||
function vt.obj:spos(x, y)
|
||||
function vt.obj.spos(x, y)
|
||||
vt.cursorX = tonumber(x)
|
||||
vt.cursorY = tonumber(y)
|
||||
end
|
||||
|
||||
function vt.obj:gpos()
|
||||
return tostring(vt.cursorX)..";"..tostring(vt.cursorY)
|
||||
function vt.obj.gpos()
|
||||
return vt.cursorX, vt.cursorY
|
||||
end
|
||||
|
||||
function vt.obj:sfgc(color)
|
||||
function vt.obj.sfgc(color)
|
||||
vt.fgColor = tonumber(color)
|
||||
end
|
||||
|
||||
function vt.obj:sbgc(color)
|
||||
function vt.obj.sbgc(color)
|
||||
vt.bgColor = tonumber(color)
|
||||
end
|
||||
|
||||
function vt.obj:gfgc()
|
||||
function vt.obj.gfgc()
|
||||
return vt.fgColor
|
||||
end
|
||||
|
||||
function vt.obj:gbgc()
|
||||
function vt.obj.gbgc()
|
||||
return vt.bgColor
|
||||
end
|
||||
|
||||
function vt.obj:gplt()
|
||||
function vt.obj.gplt()
|
||||
return 24
|
||||
end
|
||||
|
||||
function vt.obj:clear()
|
||||
function vt.obj.clear()
|
||||
for y = 1, vt.height do
|
||||
for x = 1, vt.width do
|
||||
vt.buffer[y][x] = {char = " ", fgColor = vt.fgColor, bgColor = vt.bgColor}
|
||||
@@ -117,12 +117,12 @@ local function createVt(id, width, height)
|
||||
vt.cursorX, vt.cursorY = 1, 1
|
||||
end
|
||||
|
||||
function vt.obj:isvirt()
|
||||
function vt.obj.isvirt()
|
||||
return true
|
||||
end
|
||||
|
||||
function vt.obj:gctrl()
|
||||
return serializeBool(vt.ctrl)..";"..serializeBool(vt.alt)
|
||||
function vt.obj.gfx()
|
||||
|
||||
end
|
||||
|
||||
return vt
|
||||
|
||||
@@ -108,7 +108,7 @@ function sys.spawn(func, name, envars, args, tgid, clearFds)
|
||||
end
|
||||
|
||||
function sys.execspawn(path, name, envars, args, tgid, keepFds)
|
||||
local func, euid, suid_active = loadExecutable(path, kernel._U)
|
||||
local func, euid, suid_active = loadExecutable(path)
|
||||
|
||||
local caller = kernel.currentTask
|
||||
local real_uid = caller and caller.uid or kernel.uid
|
||||
@@ -124,16 +124,19 @@ function sys.execspawn(path, name, envars, args, tgid, keepFds)
|
||||
return createTask(func, name or path, envars, args, tgid, real_uid, euid, not keepFds)
|
||||
end
|
||||
|
||||
function sys.exec(path, args, envars)
|
||||
function sys.exec(path, args, envars, clearFds)
|
||||
local task = kernel.currentTask
|
||||
local func, euid, _ = loadExecutable(path, kernel._U)
|
||||
local func, euid, _ = loadExecutable(path)
|
||||
|
||||
-- no idea why this is here?
|
||||
--if task.fd then
|
||||
-- for fd, _ in pairs(task.fd) do
|
||||
-- if fd > 2 then pcall(kernel.vfs.close, fd) end
|
||||
-- end
|
||||
--end
|
||||
-- Figured it out it is to close fds on su
|
||||
if clearFds then
|
||||
if task.fd then
|
||||
for fd, _ in pairs(task.fd) do
|
||||
if fd > 2 then pcall(kernel.vfs.close, fd) end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
task.euid = euid
|
||||
task.args = args or {}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--:Minify:--
|
||||
local kernel=...
|
||||
local debug=debug
|
||||
kernel.debug=debug
|
||||
kernel._G.debug={
|
||||
getinfo=debug.getinfo,
|
||||
traceback=debug.traceback
|
||||
getinfo=kernel.debug.getinfo,
|
||||
traceback=kernel.debug.traceback
|
||||
}
|
||||
@@ -14,7 +14,7 @@ local data = kernel.vfs.read(handle, 1024 * 1024 * 4)
|
||||
if not handle then kernel.panic("Failed to read "..kernel.config.initPath) end
|
||||
kernel.vfs.close(handle)
|
||||
|
||||
local initFunc, err = load(data, "@sysinit", "t", kernel._U)
|
||||
local initFunc, err = load(data, "@init", "t", kernel._U)
|
||||
if not initFunc then kernel.PANIC("Failed to load init system: " .. err) end
|
||||
|
||||
kernel.tasks["1"] = {
|
||||
@@ -28,7 +28,7 @@ kernel.tasks["1"] = {
|
||||
kernel.saveLog()
|
||||
end),
|
||||
|
||||
name = "sysinit",
|
||||
name = "init",
|
||||
status = "R",
|
||||
pid = 1,
|
||||
tgid = 1,
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
local kernel = ...
|
||||
kernel.processes.kgc = function()
|
||||
while true do
|
||||
for i,v in pairs(kernel.reqcache) do
|
||||
if v.expires and kernel.EFI:getEpochMs() > v.expires then
|
||||
kernel.reqcache[i] = nil
|
||||
end
|
||||
end
|
||||
--for i,v in pairs(kernel.reqcache) do
|
||||
-- if v.expires and kernel.EFI:getEpochMs() > v.expires then
|
||||
-- kernel.reqcache[i] = nil
|
||||
-- end
|
||||
--end
|
||||
sleep(5)
|
||||
end
|
||||
end
|
||||
@@ -1,7 +1,10 @@
|
||||
--:Minify:--
|
||||
local kernel = ...
|
||||
|
||||
if kernel.firstBoot then
|
||||
if kernel.firstBoot or kernel.config.resetPerms then
|
||||
if kernel.config.resetPerms then
|
||||
kernel.log("resetPerms is active, disable it in /boot/boot.cfg", "WARN", 0xFFFF00)
|
||||
end
|
||||
kernel.log("Seeding filesystem permissions...")
|
||||
|
||||
local P = kernel.vfs.P
|
||||
@@ -18,20 +21,23 @@ if kernel.firstBoot then
|
||||
|
||||
local function seed(root, data)
|
||||
for i=1,#data do
|
||||
local entry=data[1]
|
||||
kernel.vfs.chmod(root..entry[1],entry[2],entry[3])
|
||||
kernel.vfs.chown(root..entry[1],entry[4])
|
||||
local entry=data[i]
|
||||
if kernel.vfs.exists(root..entry[1]) then
|
||||
kernel.vfs.updateMeta(root..entry[1],function(e)
|
||||
e.perms=entry[4]
|
||||
e.group=entry[3]
|
||||
e.owner=entry[2]
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
seed("/", {
|
||||
{"bin", 0, 0, RWX_RX_RX},
|
||||
{"boot", 0, 0, RWX_RX_RX},
|
||||
{"dev", 0, 0, RWXRWXRWX},
|
||||
{"etc", 0, 0, RWX_RX_RX},
|
||||
{"home", 0, 0, RWX_RX_RX},
|
||||
{"lib", 0, 0, RWX_RX_RX},
|
||||
{"proc", 0, 0, RWXRWXRWX},
|
||||
{"root", 0, 0, RW____ },
|
||||
{"sbin", 0, 0, RWX_RX_RX},
|
||||
{"tmp", 0, 0, RWXRWXRWX},
|
||||
|
||||
Reference in new issue
Block a user