[arch-dev-public] [RFC] Rewrite early RTC device creation
Dan McGee
dpmcgee at gmail.com
Tue Jun 8 21:53:03 EDT 2010
On Tue, Jun 8, 2010 at 5:43 PM, Thomas Bächler <thomas at archlinux.org> wrote:
> Creating the RTC device will result in an error if devtmpfs is used,
> as it already exists after loading the module. The new code skips
> the mknod if the device is already present.
>
> Additionally to rtc-cmos, we now also try to load rtc and genrtc,
> as some custom kernels use the "old" misc RTC device instead of
> the newer RTC class. In this case, the created device is also
> different. This should fix FS#18078.
> ---
> rc.sysinit | 18 ++++++++++++------
> 1 files changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/rc.sysinit b/rc.sysinit
> index 61b04c9..8349860 100755
> --- a/rc.sysinit
> +++ b/rc.sysinit
> @@ -56,12 +56,18 @@ fi
>
> if [ -n "$HWCLOCK_PARAMS" ]; then
> # 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
> + /sbin/modprobe -q rtc-cmos
> + # some custom kernels use rtc/genrtc, try to load those too
> + /sbin/modprobe -q rtc
> + /sbin/modprobe -q genrtc
> + # If devtmpfs is used, the required RTC device already exists now
> + # Otherwise, create whatever device is available
> + if [ ! -c /dev/rtc -a ! -c /dev/rtc0 ]; then
> + if [ -f /sys/class/rtc/rtc0/dev ]; then
> + /bin/mknod /dev/rtc0 c $(cat /sys/class/rtc/rtc0/dev | sed 's|:| |')
> + elif [ -f /sys/class/misc/rtc/dev ]; then
> + /bin/mknod /dev/rtc c $(cat /sys/class/misc/rtc/dev | sed 's|:| |')
I know you are going to tell me "it doesn't matter", but why are we
starting to have non-absolute paths in utility calls? We should be
consistent, and to me that means keeping full paths. More drastically,
it means doing a purge of them all or something.
We can also just do some bash string manipulation and leave sed out of
the picture:
devnum=$(cat /sys/class/rtc/rtc0/dev)
/bin/mknod /dev/rtc0 c ${devnum/:/ }
Otherwise I like the idea of the patch and the fact that we don't
assume minor numbers anymore.
> + fi
> fi
>
> # Do a clock set here for a few reasons:
> --
> 1.7.1
More information about the arch-dev-public
mailing list