Compare commits

..

No commits in common. "d23a25613dae8412f559e1de9097b0b5e925b0c3" and "b2d137912788a1e113242e3cdfbe0c01ab6987c6" have entirely different histories.

9 changed files with 14 additions and 38 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -15,8 +15,11 @@ 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 if path:sub(1,1) ~= "/" then path=(os.getenv("PWD") or "").."/"..path end
local segments, rpath, rfs= fs.segments(path) local segments, rpath, rfs= fs.segments(path)
local rc = #segments local rc = #segments
dprint(rc)
for i = #segments, 1, -1 do 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 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) return table.concat(segments, "/", 1, i), table.concat(segments, "/", i+1)
end end
end end
@ -24,7 +27,7 @@ function fs.resolve(path) -- resolves *path* to a specific filesystem mount and
end end
-- generate some simple functions -- generate some simple functions
for k,v in pairs({"makeDirectory","exists","isDirectory","list","lastModified","remove","size","spaceUsed","spaceTotal","isReadOnly","getLabel"}) do for k,v in pairs({"makeDirectory","exists","isDirectory","list","lastModified","remove","size","spaceUsed","isReadOnly","getLabel"}) do
fs[v] = function(path) fs[v] = function(path)
local fsi,path = fs.resolve(path) local fsi,path = fs.resolve(path)
return fsmounts[fsi][v](path) return fsmounts[fsi][v](path)
@ -96,7 +99,7 @@ function fs.rename(from,to) -- moves file *from* to *to*
return true return true
end end
function fs.mount(path,proxy) -- mounts the filesystem *proxy* to the mount point *path* if it is a directory. BYO proxy. function fs.mount(path,proxy)
if fs.isDirectory(path) then if fs.isDirectory(path) then
fsmounts[table.concat(fs.segments(path),"/")] = proxy fsmounts[table.concat(fs.segments(path),"/")] = proxy
return true return true
@ -104,23 +107,6 @@ function fs.mount(path,proxy) -- mounts the filesystem *proxy* to the mount poin
return false, "path is not a directory" return false, "path is not a directory"
end 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()) fsmounts["/"] = component.proxy(computer.tmpAddress())
fs.makeDirectory("temp") fs.makeDirectory("temp")
if computer.getBootAddress then if computer.getBootAddress then

View File

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

View File

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

View File

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

View File

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