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 <kzak@redhat.com>
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;
}
} 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 "