aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Lutomirski <luto@kernel.org>2017-11-21 19:12:16 -0800
committerAndy Lutomirski <luto@kernel.org>2017-11-21 19:12:16 -0800
commit8343eeb486b76959d1b101599b55efecb9641111 (patch)
treef7ed2201b0d63c2ec6eb6502e8b8be158bca63f8
parentfea83eecf86cb95080a9e31ab9cd606839884e0b (diff)
parent6d478c3dd46e2083fb29ff5fb8d143cbfae2903b (diff)
downloadvirtme-8343eeb486b76959d1b101599b55efecb9641111.tar.gz
Merge two commits from PR #12
-rwxr-xr-xvirtme/guest/virtme-init15
1 files changed, 14 insertions, 1 deletions
diff --git a/virtme/guest/virtme-init b/virtme/guest/virtme-init
index c2860ae..07833ec 100755
--- a/virtme/guest/virtme-init
+++ b/virtme/guest/virtme-init
@@ -19,7 +19,10 @@ mount -t sysfs -o nosuid,noexec,nodev sys /sys/
declare -A mount_tags
for i in /sys/bus/virtio/drivers/9pnet_virtio/virtio*/mount_tag; do
- mount_tags["`cat "$i"`"]=1
+ # mount_tag is terminated with a NUL byte, which leads to a
+ # "command substitution: ignored null byte in input" warning from
+ # bash; use sed instead of a bare 'cat' here to strip it off.
+ mount_tags["`sed '$s/\x00$//;' "$i"`"]=1
done
kver="`uname -r`"
@@ -122,6 +125,16 @@ mkdir -p -m 0755 /dev/shm /dev/pts
mount -t devpts -o gid=tty,mode=620,noexec,nosuid devpts /dev/pts
mount -t tmpfs -o mode=1777,nosuid,nodev tmpfs /dev/shm
+# Install /proc/self/fd symlinks into /dev if not already present
+declare -r -A fdlinks=(["/dev/fd"]="/proc/self/fd"
+ ["/dev/stdin"]="/proc/self/fd/0"
+ ["/dev/stdout"]="/proc/self/fd/1"
+ ["/dev/stderr"]="/proc/self/fd/2")
+
+for p in "${!fdlinks[@]}"; do
+ [[ -e "$p" ]] || ln -s "${fdlinks[$p]}" "$p"
+done
+
# Bring up networking
ip link set dev lo up