hwclock: allow setting of RTC when it contains invalid data
In some cases the date/time stored in an RTC can be corrupted, eg due to
loss of power, before its been initially set, etc. When this occurs
the RTC_RD_TIME ioctl can fail since the Linux kernel determines that
the RTC contains invalid data. Currently, when setting an RTC using
hwclock, hwclock performs a number of RTC_RD_TIME ioctls before setting
the RTC. When one of these ioctls fails, hwclock bombs out and the
corrupted RTC data can't be overwritten. Thus once an RTC is corrupted,
it can't be fixed via hwclock*.
To work around the above issue we can make hwclock not exit when a
RTC_RD_TIME failure occurs during the process of setting the RTC. This
allows the RTC to be set even when it contains an invalid value,
although it is not synchronized to a clock tick before it is set.
* 'hwclock --utc --noadjfile --set --date="11/23/10 17:19:00' currently
works to fix a corrupted RTC, but a user couldn't determine this without
digging through the source code.