Patchwork [v3] initscripts: fix timestamp checking at bootmisc.sh

login
register
mail settings
Submitter Lauri Hintsala
Date Dec. 14, 2011, 6:27 a.m.
Message ID <1323844047-16390-1-git-send-email-lauri.hintsala@bluegiga.com>
Download mbox | patch
Permalink /patch/16905/
State Accepted
Commit cc8695f22bc70ef958f81d0d3da73dece5f4700a
Headers show

Comments

Lauri Hintsala - Dec. 14, 2011, 6:27 a.m.
Timestamp checking has been broken by the commit
2078af333d704fd894a2dedbc19cef5775cdadbb. Currently the RTC time
is always overwritten with the time from /etc/timestmap. Fix timestamp
checking and clean the code.

Signed-off-by: Lauri Hintsala <lauri.hintsala@bluegiga.com>

---
changes since V2
* reduce number of forks/execs
---
 .../initscripts/initscripts-1.0/bootmisc.sh        |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
Saul Wold - Dec. 15, 2011, 7:17 p.m.
On 12/13/2011 10:27 PM, Lauri Hintsala wrote:
> Timestamp checking has been broken by the commit
> 2078af333d704fd894a2dedbc19cef5775cdadbb. Currently the RTC time
> is always overwritten with the time from /etc/timestmap. Fix timestamp
> checking and clean the code.
>
> Signed-off-by: Lauri Hintsala<lauri.hintsala@bluegiga.com>
>
> ---
> changes since V2
> * reduce number of forks/execs
> ---
>   .../initscripts/initscripts-1.0/bootmisc.sh        |    7 +++----
>   1 files changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> index 03fd67c..ab18ad9 100755
> --- a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> +++ b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> @@ -62,15 +62,14 @@ then
>   fi
>
>   # Set the system clock from hardware clock
> -# If the timestamp is 1 day or more recent than the current time,
> +# If the timestamp is more recent than the current time,
>   # use the timestamp instead.
>   /etc/init.d/hwclock.sh start
>   if test -e /etc/timestamp
>   then
> -	SYSTEMDATE=`date  -u +%2m%2d%2H%2M%4Y`
> +	SYSTEMDATE=`date -u +%4Y%2m%2d`
>   	read TIMESTAMP<  /etc/timestamp
> -        NEEDUPDATE=`expr \( $TIMESTAMP \>  $SYSTEMDATE + 10000 \)`
> -        if [ $NEEDUPDATE -eq 1 ]; then
> +	if [ ${TIMESTAMP#????????}${TIMESTAMP%????????} -gt $SYSTEMDATE ]; then
>   		date -u $TIMESTAMP
>   		/etc/init.d/hwclock.sh stop
>   	fi
Merged into OE-Core

Thanks
	Sau!

Patch

diff --git a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
index 03fd67c..ab18ad9 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
@@ -62,15 +62,14 @@  then
 fi
 
 # Set the system clock from hardware clock
-# If the timestamp is 1 day or more recent than the current time,
+# If the timestamp is more recent than the current time,
 # use the timestamp instead.
 /etc/init.d/hwclock.sh start
 if test -e /etc/timestamp
 then
-	SYSTEMDATE=`date  -u +%2m%2d%2H%2M%4Y`
+	SYSTEMDATE=`date -u +%4Y%2m%2d`
 	read TIMESTAMP < /etc/timestamp
-        NEEDUPDATE=`expr \( $TIMESTAMP \> $SYSTEMDATE + 10000 \)`
-        if [ $NEEDUPDATE -eq 1 ]; then 
+	if [ ${TIMESTAMP#????????}${TIMESTAMP%????????} -gt $SYSTEMDATE ]; then
 		date -u $TIMESTAMP
 		/etc/init.d/hwclock.sh stop
 	fi