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

+108 -25
View File
@@ -1,41 +1,73 @@
local args = {...}
local apis = args[1]
local bootdrive = args[2]
local bootaddr = args[3]
local disks = {}
local internal = {}
local function normalize(path)
if type(path) ~= "string" then
return path
end
-- Preserve root directory.
if path == "/" then
return "/"
end
-- Remove trailing slashes.
path = path:gsub("/+$", "")
return path == "" and "/" or path
end
local function createDisk(id, hw)
local disk = {
address = id,
isReadOnly = function() return hw.isReadOnly() end
isReadOnly = function()
return hw.isReadOnly()
end
}
function disk:spaceUsed() return hw.spaceUsed() end
function disk:spaceTotal() return hw.spaceTotal() end
function disk:spaceUsed()
return hw.spaceUsed()
end
function disk:spaceTotal()
return hw.spaceTotal()
end
function disk:list(path)
path = normalize(path)
if not hw.exists(path) or not hw.isDirectory(path) then
return nil, "not directory"
end
local ret={}
for i,v in ipairs(hw.list(path)) do
if v:sub(-1)=="/" then
ret[i]=v:sub(1,#v-1)
else ret[i]=v end
local ret = {}
for i, v in ipairs(hw.list(path)) do
ret[i] = normalize(v)
end
return ret
end
function disk:fileExists(path)
path = normalize(path)
return hw.exists(path) and not hw.isDirectory(path)
end
function disk:directoryExists(path)
path = normalize(path)
return hw.exists(path) and hw.isDirectory(path)
end
function disk:type(path)
path = normalize(path)
if not hw.exists(path) then
return nil
elseif hw.isDirectory(path) then
@@ -46,17 +78,29 @@ local function createDisk(id, hw)
end
function disk:makeDirectory(path)
hw.makeDirectory(path)
path = normalize(path)
return hw.makeDirectory(path)
end
function disk:remove(path)
if hw.exists(path) then hw.remove(path) end
path = normalize(path)
if hw.exists(path) then
return hw.remove(path)
end
end
function disk:setLabel(label) hw.setLabel(label) end
function disk:getLabel() return hw.getLabel() end
function disk:setLabel(label)
return hw.setLabel(label)
end
function disk:getLabel()
return hw.getLabel()
end
function disk:attributes(path)
path = normalize(path)
return {
size = hw.size(path),
isDir = hw.isDirectory(path),
@@ -67,6 +111,8 @@ local function createDisk(id, hw)
end
function disk:open(path, mode)
path = normalize(path)
local fd = hw.open(path, mode)
if not fd then
@@ -74,43 +120,67 @@ local function createDisk(id, hw)
if dir and not hw.exists(dir) then
local ok, err = hw.makeDirectory(dir)
if not ok then
return nil, err or "could not create parent directory"
end
end
fd = hw.open(path, mode)
if not fd then
return nil, "file not found or access denied"
end
end
return {
read = function(num) return hw.read(fd, num) end,
read = function(num)
return hw.read(fd, num)
end,
readAll = function()
local data = {}
while true do
local chunk = hw.read(fd, math.huge)
if not chunk then break end
local chunk, err = hw.read(fd, 2048)
if chunk == nil then
if err then
return nil, err
end
break
end
if #chunk == 0 then
break
end
data[#data + 1] = chunk
end
return table.concat(data)
end,
write = function(data) return hw.write(fd, data) end,
write = function(data)
return hw.write(fd, data)
end,
seek = function(whence, offset)
return hw.seek(fd, whence, offset)
end,
flush = function()
hw.close(fd)
fd = hw.open(path, mode)
if fd then
hw.close(fd)
fd = hw.open(path, mode)
end
end,
close = function()
hw.close(fd)
fd = nil
if fd then
hw.close(fd)
fd = nil
end
end
}
end
@@ -122,21 +192,34 @@ internal["$"] = createDisk("$", bootdrive)
local function refresh()
disks = {}
for addr in apis.component.list("filesystem") do
if addr ~= bootaddr then
disks[addr] = createDisk(addr, apis.component.proxy(addr))
disks[addr] = createDisk(
addr,
apis.component.proxy(addr)
)
end
end
end
local function iter()
refresh()
local combined = {}
for id, obj in pairs(internal) do combined[id] = obj end
for id, obj in pairs(disks) do combined[id] = obj end
for id, obj in pairs(internal) do
combined[id] = obj
end
for id, obj in pairs(disks) do
combined[id] = obj
end
return pairs(combined)
end
return {refresh = refresh, list = iter}
return {
refresh = refresh,
list = iter
}