summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/busybox
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2020-12-17 14:54:39 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-12-20 00:03:01 +0000
commitf9e84b31ea4afe566c76dcdea25960478cd36ecc (patch)
tree4decbb13e5fd36672f8d9819d33498668fa22ad3 /meta/recipes-core/busybox
parent991394be9e695f9ddb5e2fca167c06f7a56a7449 (diff)
downloadopenembedded-core-f9e84b31ea4afe566c76dcdea25960478cd36ecc.tar.gz
busybox: Run mdev as daemon
When busybox is used for device management, kernel needs to support older/obsolete mechanism via CONFIG_UEVENT_HELPER and CONFIG_UEVENT_HELPER_PATH to enable /proc/sys/kernel/hotplug but this would require kernel defconfig change and will always be needed when mdev is used, intead run it in daemon mode Update mdev init script to run mdev in daemon mode Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/busybox')
-rw-r--r--meta/recipes-core/busybox/busybox/mdev.cfg2
-rwxr-xr-xmeta/recipes-core/busybox/files/mdev56
2 files changed, 41 insertions, 17 deletions
diff --git a/meta/recipes-core/busybox/busybox/mdev.cfg b/meta/recipes-core/busybox/busybox/mdev.cfg
index 6aefe90e43..143e6097cb 100644
--- a/meta/recipes-core/busybox/busybox/mdev.cfg
+++ b/meta/recipes-core/busybox/busybox/mdev.cfg
@@ -9,3 +9,5 @@ CONFIG_SETSID=y
CONFIG_CTTYHACK=y
CONFIG_FEATURE_SHADOWPASSWDS=y
+CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM=y
+CONFIG_FEATURE_MDEV_DAEMON=y
diff --git a/meta/recipes-core/busybox/files/mdev b/meta/recipes-core/busybox/files/mdev
index 8c9c06e96c..2fbdfb073e 100755
--- a/meta/recipes-core/busybox/files/mdev
+++ b/meta/recipes-core/busybox/files/mdev
@@ -1,21 +1,43 @@
#!/bin/sh
-mount -t proc proc /proc
-mount -t sysfs sysfs /sys
-mount -t tmpfs tmpfs /dev -o size=64k,mode=0755
-mkdir /dev/pts /dev/shm
-chmod 777 /dev/shm
-mount -t devpts devpts /dev/pts
-touch /dev/mdev.seq
-#sysctl -w kernel.hotplug=/sbin/mdev
-echo "/sbin/mdev" > /proc/sys/kernel/hotplug
-mdev -s
-
#
-# We might have mounted something over /dev, see if /dev/initctl is there.
+# Run the mdev daemon
#
-if test ! -p /dev/initctl
-then
- rm -f /dev/initctl
- mknod -m 600 /dev/initctl p
-fi
+
+DAEMON="mdev"
+PIDFILE="/var/run/$DAEMON.pid"
+
+
+start() {
+ echo -n "Starting $DAEMON... "
+ start-stop-daemon -S -b -m -p $PIDFILE -x /sbin/mdev -- -df
+ [ $? -eq 0 ] && echo "OK" || echo "ERROR"
+
+ # coldplug modules
+ find /sys/ -name modalias -print0 | \
+ xargs -0 sort -u | \
+ tr '\n' '\0' | \
+ xargs -0 modprobe -abq
+}
+
+stop() {
+ echo -n "Stopping $DAEMON... "
+ start-stop-daemon -K -p $PIDFILE
+ [ $? -eq 0 ] && echo "OK" || echo "ERROR"
+}
+
+restart() {
+ stop
+ start
+}
+
+case "$1" in
+ start|stop|restart)
+ "$1"
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart}"
+ exit 1
+esac
+
+exit $?