Merge branch 'master' of github.com:XeonSquared/PsychOS

This commit is contained in:
Izaya 2017-09-14 00:03:10 +10:00
commit 5caeb70592
15 changed files with 115 additions and 51 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
out/*
kernel.lua
skernel.lua
*.swp

View File

@ -15,12 +15,12 @@ modules/net/copper.lua
modules/util/motd.lua
modules/lib/readline.lua
modules/lib/shutil.lua
modules/lib/sha256.lua
libwrap sha modules/lib/sha256.lua
modules/lib/userlib.lua
modules/net/net-ext.lua
modules/applications/login.lua
modules/applications/luash.lua
modules/applications/genkernel.lua
fwrap luash exec/luash.lua
fwrap skex exec/skex2.lua
fwrap nshd exec/nshd.lua
fwrap nsh exec/nsh.lua

28
configs/headless.cfg Executable file
View File

@ -0,0 +1,28 @@
modules/base/loadlin.lua
modules/debug/log.lua
modules/base/header.lua
modules/base/component.lua
modules/lib/fs.lua
modules/util/logflush.lua
modules/lib/buffer.lua
modules/lib/io.lua
modules/lib/print.lua
modules/lib/cdlib.lua
modules/lib/relib.lua
modules/net/copper.lua
modules/util/motd.lua
modules/lib/readline.lua
modules/lib/shutil.lua
modules/lib/sha256.lua
modules/lib/userlib.lua
modules/net/net-ext.lua
modules/applications/login.lua
fwrap luash exec/luash.lua
modules/applications/genkernel.lua
fwrap skex exec/skex2.lua
fwrap nshd exec/nshd.lua
fwrap nsh exec/nsh.lua
modules/util/fs-automount.lua
modules/setup.lua
modules/base/footer.lua

27
configs/minimal.cfg Executable file
View File

@ -0,0 +1,27 @@
modules/base/loadlin.lua
modules/debug/log.lua
modules/base/header.lua
modules/base/component.lua
modules/lib/fs.lua
modules/util/logflush.lua
modules/lib/buffer.lua
modules/lib/io.lua
modules/drivers/vt52.lua
modules/lib/print.lua
modules/drivers/kbd.lua
modules/lib/cdlib.lua
modules/lib/relib.lua
modules/net/copper.lua
modules/util/motd.lua
modules/lib/readline.lua
modules/lib/shutil.lua
modules/lib/sha256.lua
modules/lib/userlib.lua
modules/net/net-ext.lua
modules/applications/login.lua
fwrap luash exec/luash.lua
modules/applications/genkernel.lua
modules/util/fs-automount.lua
modules/setup.lua
modules/base/footer.lua

18
docs/fhs.md Normal file
View File

@ -0,0 +1,18 @@
## Filesystem Hierarchy Standard
PsychOS is not a UNIX system, nor does it try to be. It doesn't have a 'real' VFS and doesn't have a devfs. As such, the filesystem is arranged differently.
### Top level filesystems.
Filesystems devices are represented as top-level directories, eg /boot, /tmp, /fs01.
The mount points are strings, and can be of arbitrary length. However, it is recommended to keep them under 20 characters, and to not have spaces, or special characters in them.
A device can be mounted multiple times under multiple names.
### /boot
/boot is the device the system booted from, and may be the same as /tmp under some circumstances. It contains all the special directories needed for the system to function.
#### /boot/exec
exec contains executable programs and utilities, generally separate from the kernel.
#### /boot/lib
lib contains all the libraries used by the system.
#### /boot/doc
doc contains the documentation, though it may not exist if the documentation isn't neccesary.
#### /boot/sys
sys contains miscellaneous system files like the user database and autorun scripts.

View File

@ -23,3 +23,4 @@ PsychOS is a single-user cooperative multitasking operating system for OpenCompu
- User guide (WIP)
- [Building PsychOS](building.html)
- [API documentation](api.html)
- [Filesystem layout](fhs.html)

View File

@ -1,5 +1,7 @@
function luash(si)
local tA = {...}
local si = tA[1]
spawn("lua shell",function()
_ENV = shutil.genenv()
coroutine.yield()
log(login())
print("\f"..MOTD)
@ -37,7 +39,7 @@ spawn("lua shell",function()
if inp:sub(1,1) == "=" then
inp="return "..inp:sub(2)
end
local r={pcall(load(inp))}
local r={pcall(load(inp,_ENV))}
if r[1] == true then
table.remove(r,1)
end
@ -45,4 +47,3 @@ spawn("lua shell",function()
end
end
end,{sI=si})
end

View File

@ -1,3 +1,7 @@
#!/bin/bash
./genkernel.lua build.cfg "$(git rev-parse --short HEAD)" > kernel.lua
lua strip.lua kernel.lua skernel.lua
mkdir -p out/
for f in `dir -d configs/*`; do
kn=$(echo $f | cut -f 1 -d '.' | cut -f 2 -d "/")
./genkernel.lua $f "$(git rev-parse --short HEAD)" > out/$kn.lua
lua strip.lua out/$kn.lua out/s$kn.lua
done

View File

@ -22,6 +22,10 @@ function genkernel(modlistf,kname)
nk=nk.."function "..tw[2].."(...)\n"
apfile(tw[3])
nk=nk.."\nend\n"
elseif tw[1] == "libwrap" then
nk=nk.."function "..tw[2].."(...)\n"
apfile(tw[3])
nk=nk.."\nend\n_G."..tw[2].." = "..tw[2].."()\n"
elseif tw[1] == "include" then
apfile(tw[2])
else

View File

@ -53,7 +53,7 @@ function tty(gA,sA,sI,fg,bg)
elseif c == "\r" then cx=1
elseif c == "\f" then cx=1 cy=1 gP.fill(1, 1, sx, sy, " ")
elseif c == "\t" then cx=(cx+8-((cx+8)%8))+1
elseif c == "\127" then cx=cx-1 gP.set(cx,cy," ")
elseif c == "\127" then cx=cx-1 gP.set(cx,cy,(" "):rep(2))
else gP.set(cx,cy,c) cx=cx+1
end
end cv()

View File

@ -1,35 +1,4 @@
_G.buffer = {}
--[[function buffer.create(w,c) -- worker, close
local t={}
t.b=""
function t.w(s,d)
s.b=s.b..tostring(d)
end
t.write = t.w
function t.r(s,l)
if type(l) == "number" then
local ns,bs=s.b:sub(1,l+1),s.b:sub(l+2)
s.b=bs
return ns
elseif type(l) == "string" then
local oS=s.b
if l == "*a" then
s.b=""
return oS
elseif l == "*l" then
S=s.b:find("\n") or #s.b
s.b=s.b:sub(S+1)
rS = oS:sub(1,S-1)
if rS:len() < 1 then return nil end
return rS
end
end
end
t.read = t.r
t.close = c
w(t)
return t
end]]--
function buffer.ucreate()
local b = {}
b.b,b.s = "","open"

View File

@ -6,7 +6,7 @@
-- Found Here: https://bitbucket.org/Boolsheet/bslf/src/1ee664885805/bit.lua
--
-- Data card support added by https://github.com/SuPeRMiNoR2
_G.sha = {}
sha = {}
if component then
if component.data and not component.ocemu then
shamode = "hardware"
@ -216,3 +216,4 @@ local function datac256(data)
return toHex(datac.sha256(data))
end
end
return sha

View File

@ -1,17 +1,18 @@
cd=fs.cd
rm=fs.rm
mkdir=fs.mkdir
cp=fs.cp
mv=fs.mv
function ls(p)
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 cat(p)
function shutil.cat(p)
local f=io.open(p)
print(f:read("*a"))
f:close()
end
function ps(f)
function shutil.ps(f)
local f=f or ""
print("PID\tName")
for k,v in pairs(os.tasks()) do
@ -20,13 +21,22 @@ function ps(f)
end
end
end
function mem()
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()
local et = os.genenv()
for k,v in pairs(shutil) do
if k ~= "genenv" then
et[k] = v
end
end
return et
end
function loadfile(fn)
local f=io.open(fn,"rb")
local S=f:read("*a")

View File

@ -1 +1 @@
run("/boot/autorun.lua")
run("/boot/sys/init.lua")

View File

@ -31,7 +31,7 @@ for k,v in ipairs(replacements) do
no=no+1
end
end
print("\nBefore: "..sl.."\nAfter: "..tostring(ss:len()).."\n"..tostring(no).." optimisations made.\n")
print("\nBefore: "..sl.."\nAfter: "..tostring(ss:len()).."\nDelta: "..tostring(sl-ss:len()))
f=io.open(tA[2],"wb")
f:write(ss)