NC firmware update (thanks spsf). opencomputers now uses mutiple gpus to speed up rendering and now has net drivers. currently working on kernel memory protections to prevent malicious kernel drivers. spm does not work on opencomputers, this is a known issue i am working on fixing it :D sorry for the slow development.

This commit is contained in:
Astronand committed 2026-11-04 14:19:15 -05:00
1 parent fbaafc7cff
commit ef4b856ee6
89 files changed
+3955 -563

No files matched your search

@@ -1,102 +1,283 @@
--:Minify:--
local kernel = ...
local os = os
if not kernel.config.tmpToDisk then
local proxy = {}
local data = {}
local timestamps = {}
local now = function() return kernel.EFI:getEpochMs() end
local function touch(path, created)
local time = now()
timestamps[path] = timestamps[path] or {
created = created or time,
modified = time,
}
timestamps[path].modified = time
end
local function getTimestamp(path)
if not timestamps[path] then
local time = now()
timestamps[path] = {
created = time,
modified = time,
}
end
return timestamps[path]
end
proxy.address = "tmpfs0000"
proxy.isvirt = true
proxy.isReadOnly = function() return false end
proxy.isReadOnly = function()
return false
end
proxy.spaceUsed = function() return 0 end
proxy.spaceTotal = function() return 0 end
proxy.spaceUsed = function()
local function size(step)
local total = 0
for _, value in pairs(step) do
if type(value) == "string" then
total = total + #value
elseif type(value) == "table" then
total = total + size(value)
end
end
return total
end
return size(data)
end
proxy.spaceTotal = function()
return math.huge
end
proxy.makeDirectory = function(_, path)
local steps = kernel.vfs.splitPath(path)
local step = data
for i=1,#steps do
local current = ""
for i = 1, #steps do
current = current == "" and steps[i]
or current .. "/" .. steps[i]
if not step[steps[i]] then
step[steps[i]] = {}
touch(current)
elseif type(step[steps[i]]) ~= "table" then
error("ENOTDIR")
end
step = step[steps[i]]
end
end
proxy.remove = function(_, path)
local steps = kernel.vfs.splitPath(path)
local step = data
for i=1,#steps-1 do
step = step[steps[i]]
if not step then error("ENOENT") end
if #steps == 0 then
error("EACCES")
end
step[steps[#steps]] = nil
local step = data
local current = ""
for i = 1, #steps - 1 do
current = current == "" and steps[i]
or current .. "/" .. steps[i]
step = step[steps[i]]
if not step then
error("ENOENT")
end
if type(step) ~= "table" then
error("ENOTDIR")
end
end
local name = steps[#steps]
if step[name] == nil then
error("ENOENT")
end
local function clearTimestamps(value, pathPrefix)
timestamps[pathPrefix] = nil
if type(value) == "table" then
for key, child in pairs(value) do
clearTimestamps(child, pathPrefix .. "/" .. key)
end
end
end
clearTimestamps(step[name], path)
step[name] = nil
end
proxy.setLabel = function(_, label) end
proxy.getLabel = function() return "tmpfs" end
proxy.setLabel = function(_, label)
end
proxy.getLabel = function()
return "tmpfs"
end
proxy.attributes = function(_, path)
local steps = kernel.vfs.splitPath(path)
local step = data
for i=1,#steps do
local current = ""
for i = 1, #steps do
current = current == "" and steps[i]
or current .. "/" .. steps[i]
step = step[steps[i]]
if not step then error("ENOENT") end
if step == nil then
error("ENOENT")
end
end
local time = getTimestamp(current)
return {
size = type(step) == "string" and #step or 0,
modified = 0,
created = 0,
modified = time.modified,
created = time.created,
}
end
function proxy:open(path, mode)
local steps = kernel.vfs.splitPath(path)
if #steps == 0 then
error("EISDIR")
end
local step = data
for i=1,#steps-1 do
local current = ""
for i = 1, #steps - 1 do
current = current == "" and steps[i]
or current .. "/" .. steps[i]
if not step[steps[i]] then
if mode == "w" then step[steps[i]] = {} else error("ENOENT") end
if mode == "w" then
step[steps[i]] = {}
touch(current)
else
error("ENOENT")
end
elseif type(step[steps[i]]) ~= "table" then
error("ENOTDIR")
end
step = step[steps[i]]
end
local filename = steps[#steps]
local filepath = current == "" and filename
or current .. "/" .. filename
if mode == "r" then
if type(step[filename]) ~= "string" then error("ENOENT") end
if type(step[filename]) ~= "string" then
if type(step[filename]) == "table" then
error("EISDIR")
end
error("ENOENT")
end
local content = step[filename]
local pos = 1
return {
read = function(amount)
read = function(amount)
amount = amount or #content
local chunk = content:sub(pos, pos+amount-1)
local chunk = content:sub(pos, pos + amount - 1)
pos = pos + #chunk
if chunk == "" then
return nil
end
return chunk
end,
close = function() end,
}
elseif mode == "w" then
step[filename] = ""
local buf = {}
return {
write = function(str)
buf[#buf + 1] = str
end,
close = function()
step[filename] = table.concat(buf)
end,
}
elseif mode == "a" then
if type(step[filename]) ~= "string" then step[filename] = "" end
elseif mode == "w" then
if type(step[filename]) == "table" then
error("EISDIR")
end
local buf = {}
local closed = false
return {
write = function(str)
step[filename] = step[filename] .. str
if closed then
error("EBADF")
end
buf[#buf + 1] = tostring(str)
end,
close = function()
if closed then
return
end
closed = true
local existed = type(step[filename]) == "string"
step[filename] = table.concat(buf)
if not existed then
local time = now()
timestamps[filepath] = {
created = time,
modified = time,
}
else
touch(filepath)
end
end,
close = function() end,
}
elseif mode == "a" then
if type(step[filename]) == "table" then
error("EISDIR")
end
local buf = {
type(step[filename]) == "string" and step[filename] or ""
}
local closed = false
return {
write = function(str)
if closed then
error("EBADF")
end
buf[#buf + 1] = tostring(str)
end,
close = function()
if closed then
return
end
closed = true
local existed = type(step[filename]) == "string"
step[filename] = table.concat(buf)
if not existed then
local time = now()
timestamps[filepath] = {
created = time,
modified = time,
}
else
touch(filepath)
end
end,
}
else
error("EACCES")
end
@@ -105,25 +286,57 @@ if not kernel.config.tmpToDisk then
function proxy:type(path)
local steps = kernel.vfs.splitPath(path)
local step = data
if #steps == 0 then return "directory" end
for i=1,#steps do
if #steps == 0 then
return "directory"
end
for i = 1, #steps do
if type(step) ~= "table" then
return false
end
step = step[steps[i]]
if not step then return false end
if step == nil then
return false
end
end
if type(step) == "table" then
return "directory"
end
if type(step) == "string" then
return "file"
end
if type(step) == "table" then return "directory" end
if type(step) == "string" then return "file" end
end
function proxy:list(path)
local steps = kernel.vfs.splitPath(path)
local step = data
for i=1,#steps do
local current = ""
for i = 1, #steps do
current = current == "" and steps[i]
or current .. "/" .. steps[i]
if type(step) ~= "table" then
error("ENOTDIR")
end
step = step[steps[i]]
if not step then error("ENOENT") end
if step == nil then
error("ENOENT")
end
end
if type(step) ~= "table" then error("ENOTDIR") end
if type(step) ~= "table" then
error("ENOTDIR")
end
local keys = {}
for k,_ in pairs(step) do table.insert(keys, k) end
for k in pairs(step) do
keys[#keys + 1] = k
end
return keys
end
@@ -133,9 +346,11 @@ if not kernel.config.tmpToDisk then
end
kernel.disks["tmpfs0000"] = proxy
kernel.tmpfs={data=data,proxy=proxy}
else
kernel.log("tmpToDisk enabled, skipping tmpfs module")
kernel.log("tmpfs0000 will passthrough to /tmp on the disk")
kernel.runWhenLoaded(function()
kernel.vfs.remove("/tmp")
kernel.vfs.mkdir("/tmp")