[PATCH 18/20] host/rootfs: virtiofsd: Do not use FD 0 as the socket

Demi Marie Obenour
2025-09-04T23:48:23Z

virtiofsd might close it, and closing stdin is a bad idea.

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
---
.../etc/s6-linux-init/run-image/service/vhost-user-fs/template/run | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-fs/template/run b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-fs/template/run
index 17e604ec41299934ae5eabbdea3d9cad3e63d1e1..70b06acb5193942c58d5011bfd9aa5a3bdd98ec0 100755
--- a/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-fs/template/run
+++ b/host/rootfs/etc/s6-linux-init/run-image/service/vhost-user-fs/template/run
@@ -5,7 +5,8 @@
s6-ipcserver-socketbinder -a 0700 -B env/virtiofsd.sock

if { fdmove 1 3 echo }
-fdclose 3
+fdmove -c 3 0
+redirfd -r 0 /dev/null

export TMPDIR /run

@@ -14,4 +15,4 @@ export TMPDIR /run
unshare -m --propagation slave
if { mount --rbind -o ro /run/vm/by-id/${1}/fs /run/vm/by-id/${1}/fs }

-virtiofsd --fd 0 --shared-dir /run/vm/by-id/${1}/fs
+virtiofsd --fd 3 --shared-dir /run/vm/by-id/${1}/fs

--
2.51.0