Patchwork add shutdown hook for udev

login
register
mail settings
Submitter igeiser@devonit.com
Date Feb. 3, 2013, 7:17 p.m.
Message ID <1359919022-13375-1-git-send-email-igeiser@devonit.com>
Download mbox | patch
Permalink /patch/43869/
State Accepted
Commit ce690659ef797bd26dc2be59167aa01744841510
Headers show

Comments

igeiser@devonit.com - Feb. 3, 2013, 7:17 p.m.
From: Ian Reinhart Geiser <igeiser@devonit.com>

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.

Signed-off-by: Ian Reinhart Geiser <igeiser@devonit.com>
---
 .../initrdscripts/initramfs-framework/udev         |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
Richard Purdie - Feb. 4, 2013, 12:47 p.m.
On Sun, 2013-02-03 at 14:17 -0500, igeiser@devonit.com wrote:
> From: Ian Reinhart Geiser <igeiser@devonit.com>
> 
> 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.
> 
> Signed-off-by: Ian Reinhart Geiser <igeiser@devonit.com>
> ---
>  .../initrdscripts/initramfs-framework/udev         |   12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)

I've merged this but in future can you please put a suitable prefix on
the subject line so people know which area the patch changes
("initramfs-framework: " in this case). I believe the commit message
guidelines mention this if its unclear.

Cheers,

Richard

Patch

diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/udev b/meta/recipes-core/initrdscripts/initramfs-framework/udev
index 7fbcc61..50c9349 100644
--- a/meta/recipes-core/initrdscripts/initramfs-framework/udev
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/udev
@@ -2,6 +2,14 @@ 
 # 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"
 
@@ -27,11 +35,11 @@  udev_enabled() {
 }
 
 udev_run() {
+	add_module_pre_hook "udev_shutdown_hook_handler"
+
 	mkdir -p /run
 
 	$_UDEV_DAEMON --daemon
 	udevadm trigger --action=add
 	udevadm settle
-
-	killall `basename $_UDEV_DAEMON` 2>/dev/null
 }