]> err.no Git - util-linux/commitdiff
hwclock: do not access hardware clock when using --systz
authorScott James Remnant <scott@ubuntu.com>
Thu, 24 Sep 2009 18:59:33 +0000 (11:59 -0700)
committerKarel Zak <kzak@redhat.com>
Tue, 13 Oct 2009 12:03:30 +0000 (14:03 +0200)
When using --systz we do not read from the hardware clock, so there
is no need to search for a hardware clock.  Indeed, we may be running
hwclock --systz before /dev is mounted.

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
hwclock/hwclock.c

index 3504f2bedeecb4dfa57f0a217aaf2fdce40cdfb1..9cdadfea675a5f80eeaba4bb2d342438d3c50698 100644 (file)
@@ -1136,9 +1136,11 @@ manipulate_clock(const bool show, const bool adjust, const bool noadjfile,
     int rc;  /* local return code */
     bool no_auth;  /* User lacks necessary authorization to access the clock */
 
-    no_auth = ur->get_permissions();
-    if (no_auth)
-         return EX_NOPERM;
+    if (!systz) {
+      no_auth = ur->get_permissions();
+      if (no_auth)
+              return EX_NOPERM;
+    }
 
     if (!noadjfile && (adjust || set || systohc || (!utc && !local_opt))) {
       rc = read_adjtime(&adjtime);
@@ -1644,16 +1646,19 @@ main(int argc, char **argv) {
 
        if (debug)
                out_version();
-       determine_clock_access_method(directisa);
-       if (!ur) {
-               fprintf(stderr,
-                       _("Cannot access the Hardware Clock via "
-                         "any known method.\n"));
-               if (!debug)
+       if (!systz) {
+               determine_clock_access_method(directisa);
+               if (!ur) {
                        fprintf(stderr,
-                               _("Use the --debug option to see the details "
-                                 "of our search for an access method.\n"));
-               hwclock_exit(1);
+                               _("Cannot access the Hardware Clock via "
+                                 "any known method.\n"));
+                       if (!debug)
+                               fprintf(stderr,
+                                       _("Use the --debug option to see the "
+                                         "details of our search for an access "
+                                         "method.\n"));
+                       hwclock_exit(1);
+               }
        }
 
        rc = manipulate_clock(show, adjust, noadjfile, set, set_time,