On Fri, Aug 20, 2010 at 2:12 AM, Kurt J. Bosch <kjb-temp-2009@xxxxxxxxxxxxx> wrote: > On 2010-08-19 23:12, Victor Lowther wrote: >> >> On Aug 19, 2010 10:08 AM, "Kurt J. Bosch"<kjb-temp-2009@xxxxxxxxxxxxx> >> wrote: >>> >>> On 2010-08-19 10:19, Jan de Groot wrote: >>>> >>>> On Thu, 2010-08-19 at 00:56 -0400, Dave Reisner wrote: >>>>> >>>>> Couldn't we avoid all this by just flipping a switch in the kernel? >>>>> >>>>> CONFIG_RTC_DRV_CMOS=y >>>>> >>>>> If it's compiled into the kernel, udev picks it up and creates >>>>> the /dev >>>>> nodes for us. >>>> >>>> Which still locks out the people who use a custom kernel with this >>>> driver compiled as module. IMHO the init scripts should work with both >>>> module and built-in. >>>> >>> >>> So why not let udev do the job? Patch below. I modified my initcpio to >>> get rid of the devtmpfs. A ls -l /dev/rtc* added between the new >>> /sbin/udevadm settle and the initial clock setting showed /dev/rtc0 and >>> /dev/rtc -> rtc0. So I think this should work. >>> >>> I did *not* move the sysinit_udevlaunched hook together with udev start >>> to avoid insane creation times of dev nodes because this hook is used >>> for some early udev triggering in fbsplash-extras (AUR). >>> >>> Patch against bashification-redux: >>> >>> From 22d410a2566964d58752d443a1312a6eb552660a Mon Sep 17 00:00:00 2001 >>> From: Kurt J. Bosch<kjb-temp-2009@xxxxxxxxxxxxx> >>> Date: Thu, 19 Aug 2010 16:46:23 +0200 >>> Subject: [PATCH 17/17] Correct rtc dev nodes creation using udev >>> >>> --- >>> rc.sysinit | 22 +++++++--------------- >>> 1 files changed, 7 insertions(+), 15 deletions(-) >>> >>> diff --git a/rc.sysinit b/rc.sysinit >>> index 4421def..2415967 100755 >>> --- a/rc.sysinit >>> +++ b/rc.sysinit >>> @@ -46,6 +46,12 @@ else >>> /bin/dmesg -n 3 >>> fi >>> >>> +echo> /proc/sys/kernel/hotplug >>> + >>> +stat_busy "Starting UDev Daemon" >>> +/sbin/udevd --daemon >>> +stat_done >>> + >>> HWCLOCK_PARAMS="--hctosys" >>> case $HARDWARECLOCK in >>> UTC) HWCLOCK_PARAMS+=" --utc";; >>> @@ -56,15 +62,7 @@ esac >>> if [[ $HWCLOCK_PARAMS ]]; then >>> # enable rtc access >>> /sbin/modprobe -q -a rtc-cmos rtc genrtc >>> - # If devtmpfs is used, the required RTC device already exists now >>> - # Otherwise, create whatever device is available >>> - if ! [[ -c /dev/rtc || -c /dev/rtc0 ]]; then >>> - for dev in /sys/class/rtc/rtc0/dev /sys/class/misc/rtc/dev; do >>> - [[ -e $dev ]] || continue >>> - IFS=: read -r major minor< "$dev" >>> - /bin/mknod /dev/rtc c $major $minor >>> - done >>> - fi >>> + /sbin/udevadm settle >>> >>> # Do a clock set here for a few reasons: >>> # 1. Make creation time on udev nodes sane (FS#8665) >>> @@ -79,12 +77,6 @@ if [[ $HWCLOCK_PARAMS ]]; then >>> fi >>> fi >>> >>> -echo> /proc/sys/kernel/hotplug >>> - >>> -stat_busy "Starting UDev Daemon" >>> -/sbin/udevd --daemon >>> -stat_done >>> - >>> run_hook sysinit_udevlaunched >>> >>> # Trigger udev uevents >>> -- >>> 1.7.2.1 >>> >>> > >> I like this one the best. >> >> Sent from my Nexus One. Sorry for top posting. >> > Corrected > > Hmm, the patch might break things with custom non modular kernels without > devtmpfs though. No modules loading no uevents and no dev nodes. On the > other hand reading the hwclock man page, I'm a bit uncertain whether that > piece will ever use /dev/rtc0 without a symlink from /dev/rtc. Instead it > might actually fall back to direct I/O with the current code and with the > patched one too. > > Moreover I found a couple of interesting things: > * The system clock is already set (by the kernel - in spite of > CONFIG_RTC_HCTOSYS not set) even without doing anything. Weird, but with UTC > hardware clock I even get correct mtimes in early user space. > * man hwclock: >> --systz >> Reset the System Time based on the current timezone. >> ... >> This is an alternate option to --hctosys that does not read the >> hardware clock, and may be used in system startup scripts for recent >> 2.6 kernels where you know the System Time contains the Hardware >> Clock time. > I switched my hardware clock to localtime, reverted my patch and modified > rc.sysinit to use -systz instead of --hctosys for the first hwclock call and > also disabled the entire rtc modprobe and mknod code. A date command > inserted for testing spit out the correct time. > From the util-linux-ng list: >> Indeed, we may be running hwclock --systz before /dev is mounted. > Getting rid of the pre fsck hwclock --hctosys would also on the average save > another half second of boot up time beside removing some ugly code. > > AFAIKS we can go one of three ways: > * Use udev expecting CONFIG_RTC_DRV_CMOS=m or fall back to direct I/O > * Use --systz, drop the ugly code and expect some help from the kernel > * Use an even more ugly code creating the missing symlink: > > Corrected non udev patch against bashification-redux: > > From 4e5d6a763af8f45c63ad53aa99b82246f90c0b43 Mon Sep 17 00:00:00 2001 > From: Kurt J. Bosch <kjb-temp-2009@xxxxxxxxxxxxx> > Date: Fri, 20 Aug 2010 09:04:46 +0200 > Subject: [PATCH 17/17] Really correct rtc dev nodes creation > > --- > rc.sysinit | 15 +++++++++------ > 1 files changed, 9 insertions(+), 6 deletions(-) > > diff --git a/rc.sysinit b/rc.sysinit > index 4421def..1ff37cc 100755 > --- a/rc.sysinit > +++ b/rc.sysinit > @@ -58,12 +58,15 @@ if [[ $HWCLOCK_PARAMS ]]; then > /sbin/modprobe -q -a rtc-cmos rtc genrtc > # If devtmpfs is used, the required RTC device already exists now > # Otherwise, create whatever device is available > - if ! [[ -c /dev/rtc || -c /dev/rtc0 ]]; then > - for dev in /sys/class/rtc/rtc0/dev /sys/class/misc/rtc/dev; do > - [[ -e $dev ]] || continue > - IFS=: read -r major minor < "$dev" > - /bin/mknod /dev/rtc c $major $minor > - done > + if ! [[ -c /dev/rtc ]]; then > + for dev in /sys/class/misc/rtc /sys/class/rtc/rtc0; do > + [[ -e $dev/dev ]] || continue > + IFS=: read -r major minor < "$dev/dev" > + node=${dev##*/} > + /bin/mknod /dev/$node c $major $minor > + [[ $node = rtc ]] || /bin/ln -s $node /dev/rtc > + break > + done > fi > > # Do a clock set here for a few reasons: > -- > 1.7.2.1 Thanks, I will apply this to bashification-redux. > -- > Kurt > > >