mirror of
git://git.yoctoproject.org/poky
synced 2026-09-01 21:18:26 +00:00
In cases where other initramfs modules need to rely on udev running (ie in my case I have to load firmware on a device that is slow to start) there needs to be a way to keep it running during the lifecycle of the initramfs but still be shut down before swith_root is called. I added a module_pre_hook that will shut down udev before the finish module is called. (From OE-Core rev: ce690659ef797bd26dc2be59167aa01744841510) Signed-off-by: Ian Reinhart Geiser <igeiser@devonit.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
46 lines
774 B
Bash
46 lines
774 B
Bash
#!/bin/sh
|
|
# Copyright (C) 2011, 2012 O.S. Systems Software LTDA.
|
|
# Licensed on MIT
|
|
|
|
udev_shutdown_hook_handler() {
|
|
status=$1
|
|
module=$2
|
|
if [ "$status" = "pre" ] && [ "$module" = "finish" ]; then
|
|
killall `basename $_UDEV_DAEMON` 2>/dev/null
|
|
fi
|
|
}
|
|
|
|
udev_daemon() {
|
|
OPTIONS="/sbin/udevd /lib/udev/udevd /lib/systemd/systemd-udevd"
|
|
|
|
for o in $OPTIONS; do
|
|
if [ -x "$o" ]; then
|
|
echo $o
|
|
return 0
|
|
fi
|
|
done
|
|
|
|
return 1
|
|
}
|
|
|
|
_UDEV_DAEMON=`udev_daemon`
|
|
|
|
udev_enabled() {
|
|
if [ -z "$_UDEV_DAEMON" ]; then
|
|
msg "WARNING: Cannot find the udev daemon; daemon will not be started in initramfs."
|
|
return 1
|
|
fi
|
|
|
|
return 0
|
|
}
|
|
|
|
udev_run() {
|
|
add_module_pre_hook "udev_shutdown_hook_handler"
|
|
|
|
mkdir -p /run
|
|
|
|
$_UDEV_DAEMON --daemon
|
|
udevadm trigger --action=add
|
|
udevadm settle
|
|
}
|