made newer installer that does not require tar stuff

This commit is contained in:
2026-03-21 00:54:39 -04:00
parent df62414229
commit 7deefc83ca
107 changed files with 648 additions and 353 deletions

View File

@@ -249,6 +249,14 @@ local ok, err = xpcall(function()
return value
end
local allscreens = {apis.peripheral.find("monitor")}
for i=1, #allscreens do
allscreens[i].setTextScale(.5)
allscreens[i].clear()
allscreens[i].setCursorPos(1,1)
allscreens[i].write("Initializing...")
end
local EFI = {
getEpochMs = function() return apis.os.epoch("utc") end,
getUptime = function() return apis.os.clock() * 1000 end,
@@ -303,7 +311,8 @@ local ok, err = xpcall(function()
h.close()
end,
firmware=apis,
reboot=false
reboot=false,
beep=function() end
}
apis.term.setBackgroundColor(0x8000)
@@ -340,7 +349,7 @@ local ok, err = xpcall(function()
end
end
write("Loaded in " .. tostring(apis.os.clock()) .. " seconds.\n")
EFI.screenCtl:print("Loaded in " .. tostring(apis.os.clock()) .. " seconds.\n")
while true do
local status, err = coroutine.resumeWithTimeout(kernelCoro, 50)

View File

@@ -1,7 +1,6 @@
--:Minify:--
local kernel = ...
local peripheral=kernel.cct.peripheral
local keys=kernel.apis.keys
local colors = {
[0xFFFFFF]=0x0001,
@@ -146,7 +145,7 @@ local function write(text, term)
end
kernel.devfs.data.tty={}
local ctrl,alt = false, false
kernel.cct.ctrl,kernel.cct.alt = false, false
local function serializeBool(bool)
if bool then
@@ -222,7 +221,7 @@ local function newtty(obj, id, ev)
return bg
end,
gctrl=function()
return serializeBool(ctrl)..";"..serializeBool(alt)
return serializeBool(kernel.cct.ctrl)..";"..serializeBool(kernel.cct.alt)
end,
gplt=function()
return plt
@@ -242,83 +241,7 @@ local function newtty(obj, id, ev)
end
local fifo = kernel.newFifo()
kernel.processes.cctmond = function()
local timeout = false
while true do
local event = {kernel.EFI:getMachineEvent()}
if event[1] then
local eventType = event[1]
local charOrKey = event[3]
local ctrlKeyMap = {
[keys.a]=1, [keys.b]=2, [keys.c]=3,
[keys.d]=4, [keys.e]=5, [keys.f]=6,
[keys.g]=7, [keys.h]=8, [keys.i]=9,
[keys.j]=10, [keys.k]=11, [keys.l]=12,
[keys.m]=13, [keys.n]=14, [keys.o]=15,
[keys.p]=16, [keys.q]=17, [keys.r]=18,
[keys.s]=19, [keys.t]=20, [keys.u]=21,
[keys.v]=22, [keys.w]=23, [keys.x]=24,
[keys.y]=25, [keys.z]=26,
}
if eventType == "keyPressed" then
if charOrKey == keys.leftCtrl or charOrKey == keys.rightCtrl then
ctrl = true
elseif charOrKey == keys.leftAlt or charOrKey == keys.rightAlt then
alt = true
end
if ctrl then
local ctrlByte = ctrlKeyMap[charOrKey]
if ctrlByte then
if ctrlByte == 3 then
for _, task in ipairs(syscall.getTasks()) do
syscall.sigsend(task, 1)
end
else
fifo.push(string.char(ctrlByte))
end
end
else
local specialKeyMap = {
[keys.up] = "",
[keys.down] = "",
[keys.right] = "",
[keys.left] = "",
[keys.home] = "",
[keys["end"]] = "",
[keys.pageUp] = "[5~",
[keys.pageDown] = "[6~",
[keys.delete] = "[3~",
}
local special = specialKeyMap[charOrKey]
if special then fifo.push(special) end
end
elseif eventType == "keyReleased" then
if charOrKey == keys.leftCtrl or charOrKey == keys.rightCtrl then
ctrl = false
elseif charOrKey == keys.leftAlt or charOrKey == keys.rightAlt then
alt = false
end
elseif eventType == "keyTyped" then
if charOrKey then fifo.push(charOrKey) end
end
timeout = false
else
timeout = true
end
if timeout then
sleep(0.05)
end
end
end
kernel.cct.fifo=fifo
newtty(kernel.apis.term, "1", fifo.pop)

View File

@@ -0,0 +1,86 @@
--:Minify:--
local kernel=...
local keys=kernel.apis.keys
kernel.processes.cctdeamon = function()
local timeout = false
while true do
local event = {kernel.EFI:getMachineEvent()}
if event[1] then
local eventType = event[1]
local charOrKey = event[3]
local ctrlKeyMap = {
[keys.a]=1, [keys.b]=2, [keys.c]=3,
[keys.d]=4, [keys.e]=5, [keys.f]=6,
[keys.g]=7, [keys.h]=8, [keys.i]=9,
[keys.j]=10, [keys.k]=11, [keys.l]=12,
[keys.m]=13, [keys.n]=14, [keys.o]=15,
[keys.p]=16, [keys.q]=17, [keys.r]=18,
[keys.s]=19, [keys.t]=20, [keys.u]=21,
[keys.v]=22, [keys.w]=23, [keys.x]=24,
[keys.y]=25, [keys.z]=26,
}
if eventType == "keyPressed" then
if charOrKey == keys.leftCtrl or charOrKey == keys.rightCtrl then
kernel.cct.ctrl = true
elseif charOrKey == keys.leftAlt or charOrKey == keys.rightAlt then
kernel.cct.alt = true
end
if kernel.cct.ctrl then
local ctrlByte = ctrlKeyMap[charOrKey]
if ctrlByte then
if ctrlByte == 3 then
for _, task in ipairs(syscall.getTasks()) do
syscall.sigsend(task, 1)
end
else
kernel.cct.fifo.push(string.char(ctrlByte))
end
end
else
local specialKeyMap = {
[keys.up] = "",
[keys.down] = "",
[keys.right] = "",
[keys.left] = "",
[keys.home] = "",
[keys["end"]] = "",
[keys.pageUp] = "[5~",
[keys.pageDown] = "[6~",
[keys.delete] = "[3~",
}
local special = specialKeyMap[charOrKey]
if special then kernel.cct.fifo.push(special) end
end
elseif eventType == "keyReleased" then
if charOrKey == keys.leftCtrl or charOrKey == keys.rightCtrl then
kernel.cct.ctrl = false
elseif charOrKey == keys.leftAlt or charOrKey == keys.rightAlt then
kernel.cct.alt = false
end
elseif eventType == "keyTyped" then
if charOrKey then kernel.cct.fifo.push(charOrKey) end
elseif eventType == "http_success" then
kernel.cct.httpqueue[event[2]]=nil
kernel.cct.httpresponse[event[2]]=event[3]
elseif eventType == "http_failure" then
kernel.cct.httpqueue[event[2]]=nil
kernel.cct.httperror[event[2]]=event[3]
end
timeout = false
else
timeout = true
end
if timeout then
sleep(0.05)
end
end
end

View File

@@ -1,5 +1,6 @@
--:Minify:--
local EFI=...
EFI.beep(440, 500)
local screen=EFI.screenCtl
local ifs=EFI.initfs
local disks=EFI.disks

View File

@@ -499,7 +499,7 @@ local function checkperms(meta, mode)
local bitmap = {
r = {owner = 5, group = 3, everyone = 1},
w = {owner = 4, group = 2, everyone = 0},
a = {owner = 4, group = 2, everyone = 0},
a = {owner = 4, group = 2, everyone = 0}
}
local m = bitmap[mode]
if not m then error("EINVAL") end
@@ -544,7 +544,6 @@ local function newFileObj(handle, mode, path, meta, ftype)
end
function vfs.newfd(fdobj)
checkSystemLimit(); total = total + 1
local fd = allocFD(kernel.currentTask)
kernel.currentTask.fd[fd] = fdobj
return fd
@@ -595,6 +594,21 @@ function vfs.open(path, mode)
local fd = allocFD(task)
local disk, diskPath = resolvePath(path)
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.uid~=0 or kernel.uid~=meta.owner then
local groups = (task and task.groups) or kernel.groups or {}
local access=false
for _, gid in ipairs(groups) do
if gid == meta.group then access=true end
end
if not access then error("EACCES") end
end
task[fd]=kernel.unixSockets[normalizePath(path)]
return fd
end
local meta = getFileMeta(path)
local isNew = (mode == "w" or mode == "a") and not disk:fileExists(diskPath)
@@ -696,10 +710,18 @@ function vfs.sendfile(outfd, infd, count)
end
function vfs.stat(path)
local disk, diskPath = resolvePath(path)
local meta = getFileMeta(path)
local ok, attrs = pcall(disk.attributes, disk, diskPath)
if not ok then attrs = { size=0, modified=0, created=0 } end
local attrs
local meta
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
end
return {
size = attrs.size,
modified = attrs.modified,
@@ -714,15 +736,15 @@ end
function vfs.lstat(path)
local meta = getFileMeta(path, true)
local attrs
if meta.etype == 0x01 then
if meta.etype == 0x01 or meta.etype == 0x02 then
attrs = { size=0, modified=0, created=0 }
else
local disk, diskPath = resolvePath(path, true)
local ok, a = pcall(disk.attributes, disk, diskPath)
attrs = ok and a or { size=0, modified=0, created=0 }
end
return {
size = attrs.size,
modified = attrs.modified,
@@ -739,8 +761,15 @@ end
function vfs.fstat(fd)
local file = kernel.currentTask.fd[fd]
if not file then error("EBADF") end
local disk, diskPath = resolvePath(file.path)
local attrs = disk:attributes(diskPath)
local attrs
if file.meta.etype == 0x02 then
attrs = { size=0, modified=0, created=0 }
else
local disk, diskPath = resolvePath(file.path, true)
local ok, a = pcall(disk.attributes, disk, diskPath)
attrs = ok and a or { size=0, modified=0, created=0 }
end
return {
size = attrs.size,
modified = attrs.modified,
@@ -769,6 +798,14 @@ function vfs.listdir(path)
end
end
for k,v in pairs(kernel.unixSockets) do
local p=normalizePath(path)
if k:match("^(.*)/[^/]+$")==p then
seen[v.name]=true
table.insert(out, v.name)
end
end
local mp
if diskPath == "/" then
mp = ".meta"
@@ -797,6 +834,7 @@ function vfs.mkdir(path)
local parentMeta = getFileMeta(parent)
checkperms(parentMeta, "w")
local disk, diskPath = resolvePath(path)
if disk:isReadOnly() then error("ERDONLY") end
disk:makeDirectory(diskPath)
local task = kernel.currentTask
local euid = (task and (task.euid or task.uid)) or kernel.uid
@@ -818,8 +856,13 @@ function vfs.remove(path)
local meta = getFileMeta(path, true)
if kernel.unixSockets and kernel.unixSockets[path] then
kernel.unixSockets[path] = nil
if kernel.unixSockets and kernel.unixSockets[normalizePath(path)] then
if kernel.uid ~= 0 then
if kernel.unixSockets[normalizePath(path)].meta.owner~=kernel.uid then
error("EACCES")
end
end
kernel.unixSockets[normalizePath(path)] = nil
end
if meta.etype == 0x01 then
@@ -828,6 +871,7 @@ function vfs.remove(path)
if parent == "" then parent = "/" end
local name = norm:match("[^/]+$")
local disk, parentDiskPath = resolveMount(parent)
if disk:isReadOnly() then error("ERDONLY") end
local mp
if parentDiskPath == "/" then mp = ".meta"
else mp = parentDiskPath:gsub("^/+", "") .. "/.meta" end
@@ -844,6 +888,7 @@ function vfs.remove(path)
if f2.close then f2.close() end
else
local disk, diskPath = resolvePath(path)
if disk:isReadOnly() then error("ERDONLY") end
disk:remove(diskPath)
end
end
@@ -852,6 +897,8 @@ function vfs.symlink(target, linkPath)
if type(target) ~= "string" or type(linkPath) ~= "string" then error("EINVAL") end
local norm = normalizePath(linkPath)
local parent = norm:match("^(.*)/[^/]+$") or "/"
local disk = resolveMount(linkPath)
if disk:isReadOnly() then error("ERDONLY") end
if parent == "" then parent = "/" end
local name = norm:match("[^/]+$")
if not name then error("EINVAL") end
@@ -881,7 +928,13 @@ function vfs.readlink(path)
end
function vfs.access(path, mode)
local meta = getFileMeta(path)
local meta
if kernel.unixSockets[normalizePath(path)] then
meta = kernel.unixSockets[normalizePath(path)].meta
else
meta = getFileMeta(path)
end
for i = 1, #mode do
checkperms(meta, mode:sub(i,i))
end
@@ -892,6 +945,8 @@ local function updateMeta(path, fn, noFollow)
local real = namei(path, noFollow)
local norm = real
local parent = norm:match("^(.*)/[^/]+$") or "/"
local disk = resolveMount(path)
if disk:isReadOnly() then error("ERDONLY") end
if parent == "" then parent = "/" end
local name = norm:match("[^/]+$")
if not name then error("EINVAL") end
@@ -918,6 +973,9 @@ local function updateMeta(path, fn, noFollow)
end
function vfs.chmod(path, perms)
if kernel.unixSockets[normalizePath(path)] then error("EINVAL") end
local disk = resolveMount(path)
if disk:isReadOnly() then error("ERDONLY") end
local meta = getFileMeta(path)
local euid = (kernel.currentTask and (kernel.currentTask.euid or kernel.currentTask.uid)) or kernel.uid
if euid ~= 0 and euid ~= meta.owner then error("EACCES") end
@@ -927,10 +985,14 @@ 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
vfs.chmod(file.path, perms)
end
function vfs.chown(path, uid, gid)
if kernel.unixSockets[normalizePath(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
if _euid ~= 0 then error("EPERM") end
updateMeta(path, function(e) e.owner = uid; e.group = gid end)
@@ -939,10 +1001,12 @@ 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
vfs.chown(file.path, uid, gid)
end
function vfs.exists(path)
if kernel.unixSockets[normalizePath(path)] then return true end
local meta = getFileMeta(path, true)
if meta.etype == 0x01 then return true end
local ok, disk, diskPath = pcall(resolvePath, path)
@@ -957,6 +1021,9 @@ end
function vfs.type(path)
local meta = getFileMeta(path, true)
if meta.etype == 0x01 then return "symlink" end
if kernel.unixSockets[normalizePath(path)] then
return "socket"
end
local ok, disk, diskPath = pcall(resolvePath, path)
if not ok then return nil end
return disk:type(diskPath)

View File

@@ -6,7 +6,7 @@ local data = {}
proxy.address = "procfs0000"
proxy.isvirt = true
proxy.isReadOnly = function() return false end
proxy.isReadOnly = function() return true end
proxy.spaceUsed = function() return 0 end
proxy.spaceTotal = function() return 0 end
proxy.makeDirectory = function() error("EACCES") end

View File

@@ -12,13 +12,24 @@ function signal.sigsend(pid, sig)
end
function signal.sigcatch(handler)
kernel.currentTask.sigh=handler
if not kernel.currentTask.sigq then kernel.currentTask.sigq={} end
local task=kernel.currentTask
task.sigh=handler
if not task.sigq then task.sigq={} end
local handle={
error="",
active=true
}
if task.sigd then task.sigd.active=false; end
task.sigd=handle
return handle
end
function signal.sigignore()
kernel.currentTask.sigh=nil
kernel.currentTask.sigq=nil
local task=kernel.currentTask
task.sigh=nil
task.sigq=nil
if task.sigd then task.sigd.active=false end
task.sigd=nil
end
local s=kernel.syscalls

View File

@@ -17,7 +17,42 @@
local kernel=...
local socket={}
socket.handlers={}
kernel.socket=socket
function socket.registerProtocal(protocal, handler)
socket.handlers[protocal] = handler
end
function socket.socket()
local P=kernel.vfs.P
local data=kernel.newFifo()
local isClosed=false
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,
close=function() isClosed = true end
},
type="socket",
refcount=1,
meta={
owner=kernel.currentTask.uid,
group=kernel.currentTask.uid,
etype=2,
perms=P.OWNER_R+P.OWNER_W+P.GROUP_R+P.GROUP_W
},
isvirt=true
})
end
function socket.connect(fd, address)
end
function socket.listen(fd, backlog)
end
kernel.log("Loaded socket module")

View File

@@ -0,0 +1,3 @@
--:Minify:--
local kernel=...
kernel.unixSockets={}

View File

@@ -156,7 +156,6 @@ end
function sys.sleep(s)
kernel.currentTask.status = "S"
kernel.currentTask.sleep = kernel.EFI:getEpochMs() + s * 1000
coroutine.yield()
end
function sys.getTask(pid)
@@ -343,40 +342,42 @@ function kernel.main()
local taskTimes = {}
for pid, task in pairs(tasks) do
kernel.currentTask = task
kernel.uid = task.euid or task.uid
kernel.process = task.name
if task.status == "S" and kernel.EFI:getEpochMs() >= task.sleep then
task.status = "R"
task.sleep = 0
end
if task.status == "R" then
kernel.currentTask = task
if task.status == "D" then
if task.ksh then
coroutine.resume(task.ksh)
end
end
kernel.uid = task.euid or task.uid
kernel.process = task.name
if task.status == "R" then
N = N + 1
task.timeSlice = math.min(Tmax, math.max(Tmin, B / (N ^ alpha)))
if task.sigq and #task.sigq ~= 0 and task.sigh then
local coro = coroutine.create(task.sigh)
local sigret = { coroutine.resume(coro, table.remove(task.sigq, 1)) }
while coroutine.status(coro) ~= "dead" do
if sigret[1] == false then break end
if sigret[2] == "syscall" then
local scname = sigret[3]
local sysret
if kernel.syscalls[scname] then
sysret = { xpcall(kernel.syscalls[scname], debug.traceback, table.unpack(sigret, 4)) }
else
sysret = { false, "Unknown syscall: " .. tostring(scname) }
end
if not sysret[1] then
sigret = { coroutine.resume(coro, false, sysret[2]) }
else
sigret = { coroutine.resume(coro, true, table.unpack(sysret, 2)) }
end
else
sigret = { coroutine.resume(coro) }
local status,err=coroutine.resumeWithTimeout(coro, 100, table.remove(task.sigq, 1))
if status=="error" then
task.sigd.error=err
task.sigd.active=false
task.sigh=nil
task.sigq=nil
task.sigd=nil
elseif status=="success" then
if err=="syscall" then
task.sigd.error="Cannot execute syscalls from signals"
task.sigd.active=false
task.sigh=nil
task.sigq=nil
task.sigd=nil
end
end
end
@@ -386,7 +387,11 @@ function kernel.main()
local ret
if kernel.config.preempt then
ret = { resumeWithTimeout(task.coro, task.timeSlice, table.unpack(task.syscallReturn)) }
if not task.debugger then
ret = { resumeWithTimeout(task.coro, task.timeSlice, table.unpack(task.syscallReturn)) }
else
ret = { coroutine.resume(task.coro, table.unpack(task.syscallReturn)) }
end
else
ret = { coroutine.resume(task.coro, table.unpack(task.syscallReturn)) }
end

View File

@@ -110,10 +110,12 @@ if cloptions.l then
local stat = syscall.lstat and syscall.lstat(fullPath) or syscall.stat(fullPath)
local isDir = fs.isDir(fullPath)
local isSym = stat and stat.etype == 0x01
local isSock = stat and stat.etype == 0x02
local typeChar
if isSym then typeChar = "l"
if isSym then typeChar = "l"
elseif isDir then typeChar = "d"
elseif isSock then typeChar = "s"
else typeChar = "-" end
local pstr
@@ -136,14 +138,14 @@ if cloptions.l then
printInline(tostring(mtime) .. " ")
if isSym then
syscall.devctl(1, "sfgc", 0xFF00FF)
syscall.devctl(1, "sfgc", 0x00FFFF)
printInline(v)
syscall.devctl(1, "sfgc", 0xFFFFFF)
local ok, target = pcall(syscall.readlink, fullPath)
if ok then
printInline(" -> ")
local targetExists = pcall(syscall.stat, fullPath)
syscall.devctl(1, "sfgc", targetExists and 0xFF00FF or 0xFF0000)
syscall.devctl(1, "sfgc", targetExists and 0x00FFFF or 0xFF0000)
printInline(target)
syscall.devctl(1, "sfgc", 0xFFFFFF)
end
@@ -151,6 +153,10 @@ if cloptions.l then
syscall.devctl(1, "sfgc", 0x6D00FF)
printInline(v)
syscall.devctl(1, "sfgc", 0xFFFFFF)
elseif isSock then
syscall.devctl(1, "sfgc", 0xFF00FF)
printInline(v)
syscall.devctl(1, "sfgc", 0xFFFFFF)
else
local isExec = stat and stat.perms and (math.floor(stat.perms / (2^9)) % 2 == 1)
syscall.devctl(1, "sfgc", isExec and 0x00FF00 or 0xFFFFFF)
@@ -175,9 +181,11 @@ for i, v in ipairs(list) do
local isSym = stat and stat.etype == 0x01
if isSym then
syscall.devctl(1, "sfgc", 0xFF00FF)
syscall.devctl(1, "sfgc", 0x00FFFF)
elseif isDir then
syscall.devctl(1, "sfgc", 0x6D00FF)
elseif isSock then
syscall.devctl(1, "sfgc", 0xFF00FF)
else
local isExec = stat and stat.perms and (math.floor(stat.perms / (2^9)) % 2 == 1)
syscall.devctl(1, "sfgc", isExec and 0x00FF00 or 0xFFFFFF)

3
Src/install.json Normal file
View File

@@ -0,0 +1,3 @@
[
""
]