moved most of the shutil functions into programs in exec/ to reduce kernel size.
This commit is contained in:
parent
c7d044c810
commit
868e0eee74
@ -15,6 +15,15 @@ modules/net/copper.lua
|
|||||||
modules/util/motd.lua
|
modules/util/motd.lua
|
||||||
modules/lib/readline.lua
|
modules/lib/readline.lua
|
||||||
modules/lib/shutil.lua
|
modules/lib/shutil.lua
|
||||||
|
fwrap shutil.cat exec/cat.lua
|
||||||
|
fwrap shutil.mem exec/free.lua
|
||||||
|
fwrap shutil.ls exec/ls.lua
|
||||||
|
fwrap shutil.ps exec/ps.lua
|
||||||
|
alias shutil.cd fs.cd
|
||||||
|
alias shutil.rm fs.rm
|
||||||
|
alias shutil.mkdir fs.mkdir
|
||||||
|
alias shutil.cp fs.cp
|
||||||
|
alias shutil.mv fs.mv
|
||||||
libwrap sha modules/lib/sha256.lua
|
libwrap sha modules/lib/sha256.lua
|
||||||
modules/net/net-ext.lua
|
modules/net/net-ext.lua
|
||||||
modules/applications/login.lua
|
modules/applications/login.lua
|
||||||
|
@ -13,6 +13,15 @@ modules/net/copper.lua
|
|||||||
modules/util/motd.lua
|
modules/util/motd.lua
|
||||||
modules/lib/readline.lua
|
modules/lib/readline.lua
|
||||||
modules/lib/shutil.lua
|
modules/lib/shutil.lua
|
||||||
|
fwrap shutil.cat exec/cat.lua
|
||||||
|
fwrap shutil.mem exec/free.lua
|
||||||
|
fwrap shutil.ls exec/ls.lua
|
||||||
|
fwrap shutil.ps exec/ps.lua
|
||||||
|
alias shutil.cd fs.cd
|
||||||
|
alias shutil.rm fs.rm
|
||||||
|
alias shutil.mkdir fs.mkdir
|
||||||
|
alias shutil.cp fs.cp
|
||||||
|
alias shutil.mv fs.mv
|
||||||
modules/lib/sha256.lua
|
modules/lib/sha256.lua
|
||||||
modules/net/net-ext.lua
|
modules/net/net-ext.lua
|
||||||
modules/applications/login.lua
|
modules/applications/login.lua
|
||||||
|
5
exec/cat.lua
Normal file
5
exec/cat.lua
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
local tA = {...}
|
||||||
|
local p = tA[1]
|
||||||
|
local f=io.open(p)
|
||||||
|
print(f:read("*a"))
|
||||||
|
f:close()
|
5
exec/free.lua
Normal file
5
exec/free.lua
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
print(" \tTotal\tFree\tUsed")
|
||||||
|
io.write("Mem\t")
|
||||||
|
io.write(tostring(math.floor(computer.totalMemory()/1024)).."K\t")
|
||||||
|
io.write(tostring(math.floor(computer.freeMemory()/1024)).."K\t")
|
||||||
|
print(tostring(math.floor((computer.totalMemory()-computer.freeMemory())/1024)).."K\t")
|
7
exec/ls.lua
Normal file
7
exec/ls.lua
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
local tA = {...}
|
||||||
|
if #tA == 0 then tA[1] = (os.getenv("PWD") or "/") end
|
||||||
|
for _, p in ipairs(tA) do
|
||||||
|
for k,v in ipairs(fs.list(p)) do
|
||||||
|
print(v)
|
||||||
|
end
|
||||||
|
end
|
9
exec/ps.lua
Normal file
9
exec/ps.lua
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
local tA = {...}
|
||||||
|
local f=tA[1] or ""
|
||||||
|
print("PID\tUser\tName")
|
||||||
|
for k,v in pairs(os.tasks()) do
|
||||||
|
local _,_,uid = os.taskinfo(k)
|
||||||
|
if v:find(f) then
|
||||||
|
print(tostring(k).."\t"..tostring(uid:sub(1,6)).."\t"..tostring(v))
|
||||||
|
end
|
||||||
|
end
|
@ -26,6 +26,8 @@ function genkernel(modlistf,kname)
|
|||||||
nk=nk.."function "..tw[2].."(...)\n"
|
nk=nk.."function "..tw[2].."(...)\n"
|
||||||
apfile(tw[3])
|
apfile(tw[3])
|
||||||
nk=nk.."\nend\n_G."..tw[2].." = "..tw[2].."()\n"
|
nk=nk.."\nend\n_G."..tw[2].." = "..tw[2].."()\n"
|
||||||
|
elseif tw[1] == "alias" then
|
||||||
|
nk=nk..tw[2].."="..tw[3].."\n"
|
||||||
elseif tw[1] == "include" then
|
elseif tw[1] == "include" then
|
||||||
apfile(tw[2])
|
apfile(tw[2])
|
||||||
else
|
else
|
||||||
|
@ -1,34 +1,4 @@
|
|||||||
local shutil = {}
|
local shutil = {}
|
||||||
shutil.cd=fs.cd
|
|
||||||
shutil.rm=fs.rm
|
|
||||||
shutil.mkdir=fs.mkdir
|
|
||||||
shutil.cp=fs.cp
|
|
||||||
shutil.mv=fs.mv
|
|
||||||
function shutil.ls(p)
|
|
||||||
for k,v in ipairs(fs.list(p)) do print(v) end
|
|
||||||
end
|
|
||||||
function shutil.cat(p)
|
|
||||||
local f=io.open(p)
|
|
||||||
print(f:read("*a"))
|
|
||||||
f:close()
|
|
||||||
end
|
|
||||||
function shutil.ps(f)
|
|
||||||
local f=f or ""
|
|
||||||
print("PID\tUser\tName")
|
|
||||||
for k,v in pairs(os.tasks()) do
|
|
||||||
local _,_,uid = os.taskinfo(k)
|
|
||||||
if v:find(f) then
|
|
||||||
print(tostring(k).."\t"..tostring(uid:sub(1,6)).."\t"..tostring(v))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
function shutil.mem()
|
|
||||||
print(" \tTotal\tFree\tUsed")
|
|
||||||
io.write("Mem\t")
|
|
||||||
io.write(tostring(math.floor(computer.totalMemory()/1024)).."K\t")
|
|
||||||
io.write(tostring(math.floor(computer.freeMemory()/1024)).."K\t")
|
|
||||||
print(tostring(math.floor((computer.totalMemory()-computer.freeMemory())/1024)).."K\t")
|
|
||||||
end
|
|
||||||
function shutil.genenv()
|
function shutil.genenv()
|
||||||
local et = os.genenv()
|
local et = os.genenv()
|
||||||
for k,v in pairs(shutil) do
|
for k,v in pairs(shutil) do
|
||||||
|
Loading…
Reference in New Issue
Block a user