Compare commits

..

10 Commits

9 changed files with 38 additions and 14 deletions

View File

@ -63,6 +63,7 @@ end
function ct.append(np)
ct.sp(np)
p=p+1
if #ft < 1 then p = 1 end
ct.insert()
end
function ct.delete(np,n)

View File

@ -1,5 +1,5 @@
print("PID# Parent | Name")
for k,v in pairs(os.tasks()) do
local t = os.taskInfo(v)
print(string.format("%4d %4d | %s",k,t.parent,t.name))
print(string.format("%4d %4d | %s",v,t.parent,t.name))
end

View File

@ -4,6 +4,7 @@ function shenv.quit()
os.setenv("run",nil)
end
shenv.cd = os.chdir
shenv.mkdir = fs.makeDirectory
setmetatable(shenv,{__index=function(_,k)
if _G[k] then
return _G[k]

View File

@ -7,10 +7,13 @@ devfs.component = {}
local function rfalse()
return false
end
local function rzero()
return 0
end
function devfs.component.getLabel()
return "devfs"
end
devfs.component.spaceUsed, devfs.component.spaceTotal, devfs.component.isReadOnly, devfs.component.isDirectory,devfs.component.size, devfs.component.setLabel = function() return computer.totalMemory()-computer.freeMemory() end, computer.totalMemory, rfalse, rfalse, rfalse, rfalse
devfs.component.spaceUsed, devfs.component.spaceTotal, devfs.component.isReadOnly, devfs.component.isDirectory,devfs.component.size, devfs.component.setLabel = rzero, rzero, rfalse, rfalse, rzero, rfalse
function devfs.component.exists(fname)
return devfs.files[fname] ~= nil

View File

@ -15,11 +15,8 @@ function fs.resolve(path) -- resolves *path* to a specific filesystem mount and
if path:sub(1,1) ~= "/" then path=(os.getenv("PWD") or "").."/"..path end
local segments, rpath, rfs= fs.segments(path)
local rc = #segments
dprint(rc)
for i = #segments, 1, -1 do
dprint("testing "..table.concat(segments, "/", 1, i),tostring(fsmounts[table.concat(segments, "/", 1, i)]))
if fsmounts[table.concat(segments, "/", 1, i)] ~= nil then
dprint("ret",table.concat(segments, "/", 1, i), table.concat(segments, "/", i+1))
return table.concat(segments, "/", 1, i), table.concat(segments, "/", i+1)
end
end
@ -27,7 +24,7 @@ function fs.resolve(path) -- resolves *path* to a specific filesystem mount and
end
-- generate some simple functions
for k,v in pairs({"makeDirectory","exists","isDirectory","list","lastModified","remove","size","spaceUsed","isReadOnly","getLabel"}) do
for k,v in pairs({"makeDirectory","exists","isDirectory","list","lastModified","remove","size","spaceUsed","spaceTotal","isReadOnly","getLabel"}) do
fs[v] = function(path)
local fsi,path = fs.resolve(path)
return fsmounts[fsi][v](path)
@ -99,7 +96,7 @@ function fs.rename(from,to) -- moves file *from* to *to*
return true
end
function fs.mount(path,proxy)
function fs.mount(path,proxy) -- mounts the filesystem *proxy* to the mount point *path* if it is a directory. BYO proxy.
if fs.isDirectory(path) then
fsmounts[table.concat(fs.segments(path),"/")] = proxy
return true
@ -107,6 +104,23 @@ function fs.mount(path,proxy)
return false, "path is not a directory"
end
function fs.mounts() -- returns a table containing the mount points of all mounted filesystems
local rt = {}
for k,v in pairs(fsmounts) do
rt[#rt+1] = k,v.address or "unknown"
end
return rt
end
function fs.address(path) -- returns the address of the filesystem at a given path, if applicable
local fsi,_ = fs.resolve(path)
return fsmounts[fsi].address
end
function fs.type(path) -- returns the component type of the filesystem at a given path, if applicable
local fsi,_ = fs.resolve(path)
return fsmounts[fsi].type
end
fsmounts["/"] = component.proxy(computer.tmpAddress())
fs.makeDirectory("temp")
if computer.getBootAddress then

View File

@ -8,7 +8,6 @@ function runfile(p,...) -- runs file *p* with arbitrary arguments in the current
return loadfile(p)(...)
end
function os.spawnfile(p,n) -- spawns a new process from file *p* with name *n*
dprint(p,n)
return os.spawn(function() xpcall(loadfile(p),function(e) dprint(e.."\n"..debug.traceback()) end) end,n or p)
end
function require(f) -- searches for a library with name *f* and returns what the library returns, if possible

View File

@ -30,6 +30,7 @@ function os.tasks()
return rt
end
function os.taskInfo(pid)
if not tTasks[pid] then return false end
return {name=tTasks[pid].n,parent=tTasks[pid].P}
end
function os.sched() -- the actual scheduler function

View File

@ -1,5 +1,4 @@
dprint=dprint or function() end
do
syslog = {}
syslog.emergency = 0
syslog.alert = 1
@ -10,8 +9,15 @@ syslog.notice = 5
syslog.info = 6
syslog.debug = 7
local rdprint=dprint or function() end
setmetatable(syslog,{__call = function(_,msg, level, service)
level, service = level or syslog.info, service or os.taskInfo(os.pid()).name or "unknown"
dprint(string.format("syslog: [%s:%d/%d] %s",service,os.pid(),level,msg))
level, service = level or syslog.info, service or (os.taskInfo(os.pid()) or {}).name or "unknown"
rdprint(string.format("syslog: [%s:%d/%d] %s",service,os.pid(),level,msg))
computer.pushSignal("syslog",msg, level, service)
end})
function dprint(...)
for k,v in pairs({...}) do
syslog(v,syslog.debug)
end
end
end

View File

@ -31,8 +31,7 @@ function vtemu(gpua,scra) -- creates a process to handle the GPU and screen addr
coroutine.yield()
end
local n = buf:find("\n")
r, buf = buf:sub(1,n), buf:sub(n+1)
dprint("bread",r)
r, buf = buf:sub(1,n-1), buf:sub(n+1)
return r
end
return bread, write, function() io.write("\27[2J\27[H") end