[PATCH 08/22] img/app: auto-mount virtiofs0 filesystem

Alyssa Ross
2022-10-10T23:32:25Z

img/app/Makefile | 1 +
img/app/etc/mdev.conf | 3 ++-
img/app/etc/mdev/virtiofs | 10 ++++++++++
3 files changed, 13 insertions(+), 1 deletion(-)
create mode 100755 img/app/etc/mdev/virtiofs

diff --git a/img/app/Makefile b/img/app/Makefile
index 9aae612..259e819 100644
--- a/img/app/Makefile
+++ b/img/app/Makefile
@@ -51,6 +51,7 @@ VM_FILES = \
etc/mdev.conf \
etc/mdev/iface \
etc/mdev/listen \
+ etc/mdev/virtiofs \
etc/mdev/wait \
etc/passwd \
etc/resolv.conf \
diff --git a/img/app/etc/mdev.conf b/img/app/etc/mdev.conf
index f114719..e370da8 100644
--- a/img/app/etc/mdev.conf
+++ b/img/app/etc/mdev.conf
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: EUPL-1.2+
-# SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
+# SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>

-$MODALIAS=.* 0:0 660 +importas -iu MODALIAS MODALIAS modprobe -q $MODALIAS
$INTERFACE=.* 0:0 660 ! +/etc/mdev/iface
+$MODALIAS=virtio:d0000001Av.* 0:0 660 ! +/etc/mdev/virtiofs
diff --git a/img/app/etc/mdev/virtiofs b/img/app/etc/mdev/virtiofs
new file mode 100755
index 0000000..a028002
--- /dev/null
+++ b/img/app/etc/mdev/virtiofs
@@ -0,0 +1,10 @@
+#!/bin/execlineb -P
+# SPDX-License-Identifier: EUPL-1.2+
+# SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is>
+
+# There's currently no kernel mechanism to let us enumerate available
+# virtiofs filesystems, so we only supported a single, hardcoded
+# filesystem tag for now.
+if { mkdir -p /run/virtiofs/virtiofs0 }
+if { mount -t virtiofs virtiofs0 /run/virtiofs/virtiofs0 }
+/etc/mdev/listen virtiofs0
--
2.37.1