Re: [arch-general] [PATCH 28/48] Use bash-style conditionals when setting up the hardware clock.

2010-09-01 Thread Victor Lowther
On Fri, Aug 20, 2010 at 2:12 AM, Kurt J. Bosch
 wrote:
> On 2010-08-19 23:12, Victor Lowther wrote:
>>
>> On Aug 19, 2010 10:08 AM, "Kurt J. Bosch"
>> 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
>>> 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 
> Date: Fri, 20 Aug 2010 09:04:46 +0200
> Subject: [PATCH 17/17] Really correct rtc dev nodes creation
>
> ---
>  rc.sysi

Re: [arch-general] [PATCH 28/48] Use bash-style conditionals when setting up the hardware clock.

2010-08-20 Thread Kurt J. Bosch

On 2010-08-19 23:12, Victor Lowther wrote:

On Aug 19, 2010 10:08 AM, "Kurt J. Bosch"
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
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 
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 i

Re: [arch-general] [PATCH 28/48] Use bash-style conditionals when setting up the hardware clock.

2010-08-19 Thread Victor Lowther
I like this one the best.

Sent from my Nexus One. Sorry for top posting.

On Aug 19, 2010 10:08 AM, "Kurt J. Bosch" 
wrote:
> Am 2010-08-19 10:19, schrieb Jan de Groot:
>> 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 
> 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
>
>


Re: [arch-general] [PATCH 28/48] Use bash-style conditionals when setting up the hardware clock.

2010-08-19 Thread Kurt J. Bosch

Am 2010-08-19 06:23, schrieb Victor Lowther:

I am missing the difference. Diff please?



/dev/rtc vs. /dev/{rtc,rtc0} as already said in the other replies.

Patch against bashification-redux:

From 5d3ac218c3e05bf9735bb49826bee0b393418699 Mon Sep 17 00:00:00 2001
From: Kurt J. Bosch 
Date: Thu, 19 Aug 2010 18:17:01 +0200
Subject: [PATCH 17/17] Correct rtc dev nodes creation

---
 rc.sysinit |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/rc.sysinit b/rc.sysinit
index 4421def..9fb10af 100755
--- a/rc.sysinit
+++ b/rc.sysinit
@@ -59,10 +59,10 @@ if [[ $HWCLOCK_PARAMS ]]; then
# 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
+   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

--
1.7.2.1



Re: [arch-general] [PATCH 28/48] Use bash-style conditionals when setting up the hardware clock.

2010-08-19 Thread Kurt J. Bosch

Am 2010-08-19 10:19, schrieb Jan de Groot:

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 
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




Re: [arch-general] [PATCH 28/48] Use bash-style conditionals when setting up the hardware clock.

2010-08-19 Thread Jan de Groot
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.



Re: [arch-general] [PATCH 28/48] Use bash-style conditionals when setting up the hardware clock.

2010-08-18 Thread Dave Reisner
On Thu, Aug 19, 2010 at 02:34:50PM +1000, Allan McRae wrote:
> On 19/08/10 14:23, Victor Lowther wrote:
> >I am missing the difference. Diff please?
> 
> Yours:
> >>>+ /bin/mknod /dev/rtc c $major $minor
> 
> His:
> >>/bin/mknod /dev/${dev##*/} c $major $minor
> 
> Yours creates /dev/rtc and his creates /dev/rtc and /dev/rtc0
> 
> Allan
> 
> 

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.

d


Re: [arch-general] [PATCH 28/48] Use bash-style conditionals when setting up the hardware clock.

2010-08-18 Thread Allan McRae

On 19/08/10 14:23, Victor Lowther wrote:

I am missing the difference. Diff please?


Yours:

+ /bin/mknod /dev/rtc c $major $minor


His:

/bin/mknod /dev/${dev##*/} c $major $minor


Yours creates /dev/rtc and his creates /dev/rtc and /dev/rtc0

Allan





Re: [arch-general] [PATCH 28/48] Use bash-style conditionals when setting up the hardware clock.

2010-08-18 Thread Victor Lowther
I am missing the difference. Diff please?

Sent from my Nexus One

On Aug 18, 2010 2:41 AM, "Kurt J. Bosch" 
wrote:
> 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
>


Re: [arch-general] [PATCH 28/48] Use bash-style conditionals when setting up the hardware clock.

2010-08-18 Thread Kurt J. Bosch

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