fix(init): resync watched mounts after host file replacement

A bind mount tracks the inode, not the path. When the host replaces one
of the HOST_WATCH files, the container mount keeps pointing at the
unlinked inode and findmnt reports it with a "//deleted" source. The
keepalive loop only compared file contents, so a byte-identical recreate
left the mount disconnected, and when /run/host exposed the same deleted
peer the content check could never trigger at all.

Signed-off-by: Luca Di Maio <luca.dimaio1@gmail.com>
This commit is contained in:
Luca Di Maio committed 2026-09-17 16:21:37 +02:00
1 parent 884f14ee17
commit 510e6d9be3
1 file changed
+8 -1
@@ -2837,7 +2837,14 @@ if [ "${init}" -eq 0 ]; then
file_watch_src="/run/host${file_watch_src}"
fi
fi
if ! diff "${file_watch}" "${file_watch_src}" > /dev/null; then
# findmnt marks a bind whose host file was replaced as "//deleted";
# diff alone misses it when the new content is equal.
if [ ! -e "${file_watch_src}" ] ||
findmnt -no SOURCE "${file_watch_src}" 2> /dev/null | grep -q '//deleted'; then
continue
fi
if echo "${mount_source}" | grep -q '//deleted' ||
! diff "${file_watch}" "${file_watch_src}" > /dev/null; then
# We only do this, if the file is actually different
umount "${file_watch}" &&
mount_bind "${file_watch_src}" "${file_watch}"