[arch-general] [PATCH 28/48] Use bash-style conditionals when setting up the hardware clock.
Kurt J. Bosch
kjb-temp-2009 at alpenjodel.de
Wed Aug 18 03:41:09 EDT 2010
Am 2010-06-30 23:47, schrieb Victor Lowther:
> Trying to stick with POSIX syntax only just slows things down.
> ---
> rc.sysinit | 27 +++++++++++----------------
> 1 files changed, 11 insertions(+), 16 deletions(-)
>
> diff --git a/rc.sysinit b/rc.sysinit
> index 29adeca..f3e60b7 100755
> --- a/rc.sysinit
> +++ b/rc.sysinit
> @@ -44,27 +44,22 @@ fi
>
> HWCLOCK_PARAMS="--hctosys"
> case $HARDWARECLOCK in
> - UTC) "$HWCLOCK_PARAMS --utc";;
> - localtime) HWCLOCK_PARAMS="$HWCLOCK_PARAMS --localtime";;
> + UTC) HWCLOCK_PARAMS+=" --utc";;
> + localtime) HWCLOCK_PARAMS+=" --localtime";;
> *) HWCLOCK_PARAMS="";;
> esac
>
> -if [ -n "$HWCLOCK_PARAMS" ]; then
> +if [[ $HWCLOCK_PARAMS ]]; then
> # enable rtc access
> - /sbin/modprobe -q rtc-cmos
> - # some custom kernels use rtc/genrtc, try to load those too
> - /sbin/modprobe -q rtc
> - /sbin/modprobe -q genrtc
> + /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 -a ! -c /dev/rtc0 ]; then
> - if [ -f /sys/class/rtc/rtc0/dev ]; then
> - IFS=: read -r major minor< /sys/class/rtc/rtc0/dev
> - /bin/mknod /dev/rtc0 c $major $minor
> - elif [ -f /sys/class/misc/rtc/dev ]; then
> - IFS=: read -r major minor< /sys/class/misc/rtc/dev
> - /bin/mknod /dev/rtc c $major $minor
> - fi
> + 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
Actually this doesn't do the same. What about the following?
if ! [[ -c /dev/rtc || -c /dev/rtc0 ]]; then
for dev in /sys/class/rtc/rtc0 /sys/class/misc/rtc; do
[[ -e $dev/dev ]] || continue
IFS=: read -r major minor< "$dev/dev"
/bin/mknod /dev/${dev##*/} c $major $minor
done
fi
More information about the arch-general
mailing list