Some RTC drivers (e.g., rtc-nxp-bbnsm) return EINVAL from
RTC_RD_TIME when the hardware time counter has never been
initialized. Print a hint so users know the likely cause rather
than just seeing "Invalid argument".
Addresses: https://github.com/util-linux/util-linux/pull/4376
Signed-off-by: Karel Zak <kzak@redhat.com>
rc = ioctl(rtc_fd, RTC_RD_TIME, &rtc_tm);
if (rc == -1) {
+ int errsv = errno;
warn(_("ioctl(RTC_RD_TIME) to %s to read the time failed"),
rtc_dev_name);
+ if (errsv == EINVAL)
+ warnx(_("RTC may not be initialized"));
return -1;
}
* precisely (+/- a second) as we can read them.
*/
if (ioctl(fd, RTC_RD_TIME, &rtc) < 0) {
+ int errsv = errno;
warn(_("read rtc time failed"));
+ if (errsv == EINVAL)
+ warnx(_("RTC may not be initialized"));
return -1;
}