From 94967e5bea7e58637529135837b18117aa8f2da6 Mon Sep 17 00:00:00 2001 From: Gerardo Exequiel Pozzi Date: Wed, 29 Jul 2009 03:45:03 -0300 Subject: [PATCH 2/2] Reorder/changing RTC device initialization code. * This changes how RTC device is created at startup. Instead of doing this manually like now (and only with rtc-cmos), leave the work for udev. * The hwclock is executed just after all devices are created (udevadm settle), and all modules are loaded. * In case of no udevd is in the system, do it manually. * For the manual step, change the code a bit to be more simple, and use only bash "read" built-in and /sys * Also change the test for detect if udev is loaded. Instead of using pidof, check if the directory /dev/.udev exists. Signed-off-by: Gerardo Exequiel Pozzi --- rc.sysinit | 60 +++++++++++++++++++++++++++++++----------------------------- 1 files changed, 31 insertions(+), 29 deletions(-) diff --git a/rc.sysinit b/rc.sysinit index 298f446..da8e3d8 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -33,30 +33,6 @@ else /bin/dmesg -n 3 fi -# enable rtc access -/sbin/modprobe rtc-cmos >/dev/null 2>&1 -RTC_MAJOR=$(/bin/grep -w rtc /proc/devices 2>/dev/null); RTC_MAJOR="${RTC_MAJOR%% *}" -if [ -n "$RTC_MAJOR" ]; then - /bin/mknod /dev/rtc0 c $RTC_MAJOR 0 - /bin/ln -s /dev/rtc0 /dev/rtc -fi - -HWCLOCK_PARAMS="--hctosys" -if [ "$HARDWARECLOCK" = "UTC" ]; then - HWCLOCK_PARAMS="$HWCLOCK_PARAMS --utc" -else - HWCLOCK_PARAMS="$HWCLOCK_PARAMS --localtime" -fi -if [ "$USEDIRECTISA" = "yes" -o "$USEDIRECTISA" = "YES" ]; then - HWCLOCK_PARAMS="$HWCLOCK_PARAMS --directisa" -fi - -# Set clock early to fix some bugs with filesystem checks -# Clock is set again later to match rc.conf -if [ -f /etc/localtime ]; then - /sbin/hwclock $HWCLOCK_PARAMS --noadjfile -fi - echo > /proc/sys/kernel/hotplug if [ -x /sbin/udevadm ]; then @@ -69,10 +45,10 @@ else fi # Trigger udev uevents -if /bin/pidof -o %PPID /sbin/udevd >/dev/null; then - stat_busy "Triggering UDev uevents" - /sbin/udevadm trigger & - stat_done +if [ -d /dev/.udev ]; then + stat_busy "Triggering UDev uevents" + /sbin/udevadm trigger & + stat_done fi # Load modules from the MODULES array defined in rc.conf @@ -107,7 +83,7 @@ if ! [ "$load_modules" = "off" ]; then fi # Wait for udev uevents -if /bin/pidof -o %PPID /sbin/udevd >/dev/null; then +if [ -d /dev/.udev ]; then stat_busy "Waiting for UDev uevents to be processed" udevstart="$(/bin/date +%s%0N)" /sbin/udevadm settle @@ -116,6 +92,32 @@ if /bin/pidof -o %PPID /sbin/udevd >/dev/null; then printhl " UDev uevent processing time: $((($udevend-$udevstart)/1000000))ms" fi +# enable rtc access +if [ ! -d /dev/.udev ]; then + /sbin/modprobe rtc-cmos >/dev/null 2>&1 + if [ -f /sys/class/rtc/rtc0/dev ]; then + read -d: RTC_MAJOR < /sys/class/rtc/rtc0/dev + /bin/mknod /dev/rtc0 c $RTC_MAJOR 0 + /bin/ln -s /dev/rtc0 /dev/rtc + fi +fi + +HWCLOCK_PARAMS="--hctosys" +if [ "$HARDWARECLOCK" = "UTC" ]; then + HWCLOCK_PARAMS="$HWCLOCK_PARAMS --utc" +else + HWCLOCK_PARAMS="$HWCLOCK_PARAMS --localtime" +fi +if [ "$USEDIRECTISA" = "yes" -o "$USEDIRECTISA" = "YES" ]; then + HWCLOCK_PARAMS="$HWCLOCK_PARAMS --directisa" +fi + +# Set clock early to fix some bugs with filesystem checks +# Clock is set again later to match rc.conf +if [ -f /etc/localtime ]; then + /sbin/hwclock $HWCLOCK_PARAMS --noadjfile +fi + # bring up the loopback interface if [ -d /sys/class/net/lo ]; then stat_busy "Bringing up loopback interface" -- 1.6.3.3