Compare commits
No commits in common. "d23a25613dae8412f559e1de9097b0b5e925b0c3" and "b2d137912788a1e113242e3cdfbe0c01ab6987c6" have entirely different histories.
d23a25613d
...
b2d1379127
@ -63,7 +63,6 @@ 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)
|
||||
|
@ -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",v,t.parent,t.name))
|
||||
print(string.format("%4d %4d | %s",k,t.parent,t.name))
|
||||
end
|
||||
|
@ -4,7 +4,6 @@ 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]
|
||||
|
@ -7,13 +7,10 @@ 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 = 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)
|
||||
return devfs.files[fname] ~= nil
|
||||
|
@ -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
|
||||
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
|
||||
@ -24,7 +27,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","spaceTotal","isReadOnly","getLabel"}) do
|
||||
for k,v in pairs({"makeDirectory","exists","isDirectory","list","lastModified","remove","size","spaceUsed","isReadOnly","getLabel"}) do
|
||||
fs[v] = function(path)
|
||||
local fsi,path = fs.resolve(path)
|
||||
return fsmounts[fsi][v](path)
|
||||
@ -96,7 +99,7 @@ function fs.rename(from,to) -- moves file *from* to *to*
|
||||
return true
|
||||
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
|
||||
fsmounts[table.concat(fs.segments(path),"/")] = proxy
|
||||
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"
|
||||
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
|
||||
|
@ -8,6 +8,7 @@ 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
|
||||
|
@ -30,7 +30,6 @@ 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
|
||||
|
@ -1,4 +1,5 @@
|
||||
do
|
||||
dprint=dprint or function() end
|
||||
|
||||
syslog = {}
|
||||
syslog.emergency = 0
|
||||
syslog.alert = 1
|
||||
@ -9,15 +10,8 @@ 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()) or {}).name or "unknown"
|
||||
rdprint(string.format("syslog: [%s:%d/%d] %s",service,os.pid(),level,msg))
|
||||
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))
|
||||
computer.pushSignal("syslog",msg, level, service)
|
||||
end})
|
||||
function dprint(...)
|
||||
for k,v in pairs({...}) do
|
||||
syslog(v,syslog.debug)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -31,7 +31,8 @@ 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-1), buf:sub(n+1)
|
||||
r, buf = buf:sub(1,n), buf:sub(n+1)
|
||||
dprint("bread",r)
|
||||
return r
|
||||
end
|
||||
return bread, write, function() io.write("\27[2J\27[H") end
|
||||
|
Loading…
Reference in New Issue
Block a user