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 <kzak@redhat.com>
This commit is contained in:
parent
6bebea1b13
commit
b3fc2a3c33
|
@ -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))
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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 "
|
||||
|
|
Loading…
Reference in New Issue