From: Karel Zak Date: Mon, 7 Oct 2019 10:57:43 +0000 (+0200) Subject: hwclock: report rtc open() errors on --verbose X-Git-Tag: v2.35-rc1~178 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3fc2a3c33905cc6871f99334e56221478d2609c;p=thirdparty%2Futil-linux.git hwclock: report rtc open() errors on --verbose Let's be more verbose and provide real open() error to make debugging easier on --verbose. For example: $ hwclock --verbose hwclock from util-linux 2.34.193-6bebea-dirty System Time: 1570445823.701266 Trying to open: /dev/rtc0 hwclock: cannot open /dev/rtc0: Permission denied <--- No usable clock interface found. hwclock: Cannot access the Hardware Clock via any known method. Addresses: https://github.com/karelzak/util-linux/issues/879 Signed-off-by: Karel Zak --- diff --git a/sys-utils/hwclock-rtc.c b/sys-utils/hwclock-rtc.c index a0d28f89e7..8c75bd40fa 100644 --- a/sys-utils/hwclock-rtc.c +++ b/sys-utils/hwclock-rtc.c @@ -129,9 +129,12 @@ static int open_rtc(const struct hwclock_control *ctl) printf(_("Trying to open: %s\n"), fls[i]); rtc_dev_fd = open(fls[i], O_RDONLY); - if (rtc_dev_fd < 0 - && (errno == ENOENT || errno == ENODEV)) - continue; + if (rtc_dev_fd < 0) { + if (errno == ENOENT || errno == ENODEV) + continue; + if (ctl->verbose) + warn(_("cannot open %s"), fls[i]); + } rtc_dev_name = fls[i]; break; } diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c index c8b3419f73..695a3a55f1 100644 --- a/sys-utils/hwclock.c +++ b/sys-utils/hwclock.c @@ -940,8 +940,10 @@ static void determine_clock_access_method(const struct hwclock_control *ctl) } else { if (ctl->verbose) printf(_("No usable clock interface found.\n")); + warnx(_("Cannot access the Hardware Clock via " "any known method.")); + if (!ctl->verbose) warnx(_("Use the --verbose option to see the " "details of our search for an access "