]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hwclock: report rtc open() errors on --verbose
authorKarel Zak <kzak@redhat.com>
Mon, 7 Oct 2019 10:57:43 +0000 (12:57 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 7 Oct 2019 10:57:43 +0000 (12:57 +0200)
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>
sys-utils/hwclock-rtc.c
sys-utils/hwclock.c

index a0d28f89e740804efa3f9c92e19cda809645362d..8c75bd40fab962eb619426495f601c0af89d5b2e 100644 (file)
@@ -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;
                }
index c8b3419f738d1eee487afb3141672c48e3e7b148..695a3a55f126982b49e0485c2264bf2dded5a83f 100644 (file)
@@ -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 "