chiark / gitweb /
uml psusan: wip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 6 Aug 2021 14:41:43 +0000 (15:41 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 6 Aug 2021 17:57:04 +0000 (18:57 +0100)
More or less copied from the putty docs (putty has a permissive licence)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
psusan-uml [new file with mode: 0755]
psusan-uml-inside [new file with mode: 0755]

diff --git a/psusan-uml b/psusan-uml
new file mode 100755 (executable)
index 0000000..acc4def
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+bwrap --dev-bind / / --tmpfs /dev/shm \
+linux mem=512M rootfstype=hostfs rootflags=/ rw \
+ con=fd:2,fd:2 ssl0=fd:0,fd:1 init=$PWD/psusan-uml-inside
diff --git a/psusan-uml-inside b/psusan-uml-inside
new file mode 100755 (executable)
index 0000000..ee6ec47
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/bash
+# Set up vital pseudo-filesystems
+mount -t proc none /proc
+mount -t devpts none /dev/pts
+# Redirect I/O to the serial port, but stderr to the console
+exec 0<>/dev/ttyS0 1>&0 2>/dev/console
+# Set the serial port into raw mode, to run a binary protocol
+stty raw -echo
+# Choose what shell you want to run inside psusan
+export SHELL=/bin/bash
+# And now run psusan over the serial port
+exec psusan