On 12/13/2011 02:36 PM, Phil Blundell wrote:
On Tue, 2011-12-13 at 12:26 +0000, Richard Purdie wrote:
On Tue, 2011-12-13 at 08:58 +0200, Lauri Hintsala wrote:
  # 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`
-       read TIMESTAMP<  /etc/timestamp
-        NEEDUPDATE=`expr \( $TIMESTAMP \>  $SYSTEMDATE + 10000 \)`
-        if [ $NEEDUPDATE -eq 1 ]; then
-               date -u $TIMESTAMP
+       SYSTEMDATE=`date -u +%4Y%2m%2d`
+       TIMESTAMP=`cat /etc/timestamp | awk '{ print substr($0,9,4) 
substr($0,1,4); }'`
+       NEEDUPDATE=`expr \( $TIMESTAMP \>  $SYSTEMDATE \)`
+       if [ $NEEDUPDATE -eq 1 ]; then
+               date -u `cat /etc/timestamp`
                /etc/init.d/hwclock.sh stop
        fi
  fi


For reference, the code in the boot process is trying not to cause
fork/exec calls. This is why it does:

read TIMESTAMP<  /etc/timestamp

since this is faster than forking to run cat. Could we fix this in a
different way to avoid the fork/execs?

For the same reason it would probably be nice to replace that call to
"expr" (which was in the old version too) with a shell expansion.

SYSTEMDATE=`date -u +%4Y%2m%2d`
TIMESTAMP=`awk '{ print substr($0,9,4) substr($0,1,4); }' < /etc/timestamp`
if [ $TIMESTAMP -gt $SYSTEMDATE ]; then
        read TIMESTAMP < /etc/timestamp
        date -u $TIMESTAMP
        /etc/init.d/hwclock.sh stop
fi

How about this?

Lauri

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

Reply via email to