From 07627d8cdd1adff00e9f77a12b9a6498f7ad7dd4 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 13 Dec 2006 12:17:38 +0000 Subject: [PATCH] * Move starting of udevd (and udevtrigger/settle) into an Upstart job. svn path=/nixos/trunk/; revision=7330 --- boot/boot-stage-2-init.sh | 13 ------------- configuration/upstart.nix | 6 ++++++ upstart-jobs/hardware-scan.nix | 2 +- upstart-jobs/syslogd.nix | 2 +- upstart-jobs/udev.nix | 31 +++++++++++++++++++++++++++++++ 5 files changed, 39 insertions(+), 15 deletions(-) create mode 100644 upstart-jobs/udev.nix diff --git a/boot/boot-stage-2-init.sh b/boot/boot-stage-2-init.sh index 364c6b682429..71d3fcc10b5f 100644 --- a/boot/boot-stage-2-init.sh +++ b/boot/boot-stage-2-init.sh @@ -88,19 +88,6 @@ mknod -m 0666 /dev/null c 1 3 export MODULE_DIR=@kernel@/lib/modules/ -# Start udev. -udevd --daemon - - -# Let udev create device nodes for all modules that have already been -# loaded into the kernel (or for which support is built into the -# kernel). -udevtrigger -udevsettle # wait for udev to finish - -chmod 666 /dev/null # grmbl - - # Start an interactive shell. #exec @shell@ diff --git a/configuration/upstart.nix b/configuration/upstart.nix index 8efa0a4ca755..27696a2daa7a 100644 --- a/configuration/upstart.nix +++ b/configuration/upstart.nix @@ -17,6 +17,12 @@ import ../upstart-jobs/gather.nix { inherit (pkgs) sysklogd; }) + # The udev daemon creates devices nodes and runs programs when + # hardware events occur. + (import ../upstart-jobs/udev.nix { + inherit (pkgs) udev procps; + }) + # Hardware scan; loads modules for PCI devices. (import ../upstart-jobs/hardware-scan.nix { inherit (pkgs) kernel module_init_tools; diff --git a/upstart-jobs/hardware-scan.nix b/upstart-jobs/hardware-scan.nix index 3ffd8f9223f5..bfa44798bdb9 100644 --- a/upstart-jobs/hardware-scan.nix +++ b/upstart-jobs/hardware-scan.nix @@ -5,7 +5,7 @@ name = "hardware-scan"; job = " -start on startup +start on udev script export MODULE_DIR=${kernel}/lib/modules/ diff --git a/upstart-jobs/syslogd.nix b/upstart-jobs/syslogd.nix index 8f326b0d6cf4..0fbc92e87310 100644 --- a/upstart-jobs/syslogd.nix +++ b/upstart-jobs/syslogd.nix @@ -3,7 +3,7 @@ { name = "syslogd"; job = " - start on startup + start on udev stop on shutdown respawn ${sysklogd}/sbin/syslogd -n "; diff --git a/upstart-jobs/udev.nix b/upstart-jobs/udev.nix new file mode 100644 index 000000000000..e218246c0463 --- /dev/null +++ b/upstart-jobs/udev.nix @@ -0,0 +1,31 @@ +{udev, procps}: + +{ + name = "udev"; + + job = " +start on startup +stop on shutdown + +start script + echo '' > /proc/sys/kernel/hotplug + + # Start udev. + ${udev}/sbin/udevd --daemon + + # Let udev create device nodes for all modules that have already + # been loaded into the kernel (or for which support is built into + # the kernel). + ${udev}/sbin/udevtrigger + ${udev}/sbin/udevsettle # wait for udev to finish + + # Kill udev, let Upstart restart and monitor it. (This is nasty, + # but we have to run udevtrigger first. Maybe we can use + # Upstart's `binary' keyword, but it isn't implemented yet.) + ${procps}/bin/pkill -u root '^udevd$' +end script + +respawn ${udev}/sbin/udevd + "; + +}