From: Karel Zak Date: Wed, 24 Jun 2026 11:29:16 +0000 (+0200) Subject: hwclock, rtcwake: hint about uninitialized RTC on EINVAL X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=52161b408c6efb8d416d3602d72cd900d4ccc52d;p=thirdparty%2Futil-linux.git hwclock, rtcwake: hint about uninitialized RTC on EINVAL 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 --- diff --git a/sys-utils/hwclock-rtc.c b/sys-utils/hwclock-rtc.c index f8518c30c..1b82b77b4 100644 --- a/sys-utils/hwclock-rtc.c +++ b/sys-utils/hwclock-rtc.c @@ -157,8 +157,11 @@ static int do_rtc_read_ioctl(int rtc_fd, struct tm *tm) 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; } diff --git a/sys-utils/rtcwake.c b/sys-utils/rtcwake.c index ad5135644..0a3bf8e05 100644 --- a/sys-utils/rtcwake.c +++ b/sys-utils/rtcwake.c @@ -174,7 +174,10 @@ static int get_basetimes(struct rtcwake_control *ctl, int fd) * 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; }