diff mbox series

udev-extraconf: detect init manager from pid

Message ID 20260315124401.53744-1-opensource@nabladev.com
State Under Review
Headers show
Series udev-extraconf: detect init manager from pid | expand

Commit Message

opensource@nabladev.com March 15, 2026, 12:44 p.m. UTC
From: Stefano Babic <sbabic@nabladev.com>

Detecting the init manager from /sbin/init does not always work and it
fails when etc-overlayfs is used, because first the
pre-init script is called and init is renamed as init.orig.. Read the
process name with pid = 1 from /proc, and use it to detect the init manager.

Signed-off-by: Stefano Babic <sbabic@nabladev.com>
---
 meta/recipes-core/udev/udev-extraconf/mount.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/meta/recipes-core/udev/udev-extraconf/mount.sh b/meta/recipes-core/udev/udev-extraconf/mount.sh
index 4827779e2f..3ddee84b78 100644
--- a/meta/recipes-core/udev/udev-extraconf/mount.sh
+++ b/meta/recipes-core/udev/udev-extraconf/mount.sh
@@ -4,7 +4,8 @@ 
 #
 # Attempt to mount any added block devices and umount any removed devices
 
-BASE_INIT="`readlink -f "@base_sbindir@/init"`"
+INITNAME=`cat /proc/1/cmdline`
+BASE_INIT="`readlink -f ${INITNAME}`"
 INIT_SYSTEMD="@systemd_unitdir@/systemd"
 MOUNT_BASE="@MOUNT_BASE@"
 
@@ -165,7 +166,7 @@  automount() {
 		echo "$name" > "/tmp/.automount-$name"
 	fi
 }
-	
+
 rm_dir() {
 	# We do not want to rm -r populated directories
 	if test "`find "$1" | wc -l | tr -d " "`" -lt 2 -a -d "$1"