]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hwclock: add --update-drift check
authorJ William Piggott <elseifthen@gmx.com>
Sun, 18 Jun 2017 17:14:40 +0000 (13:14 -0400)
committerJ William Piggott <elseifthen@gmx.com>
Tue, 20 Jun 2017 23:56:39 +0000 (19:56 -0400)
Only allow --update-drift for --set or --systohc

Signed-off-by: J William Piggott <elseifthen@gmx.com>
sys-utils/hwclock.8.in
sys-utils/hwclock.c

index cf33e632937ee7c96a31e194b6f4a90395e440d1..72b842ed55bb37c5175c2a9627a416c8f057c3b0 100644 (file)
@@ -376,9 +376,8 @@ in learning about the internal operations of hwclock.
 .B \-\-update\-drift
 Update the Hardware Clock's drift factor in
 .IR @ADJTIME_PATH@ .
-It is used with
+It can only be used with
 .BR \-\-set " or " \%\-\-systohc ,
-otherwise it is ignored.
 .sp
 A minimum four hour period between settings is required.  This is to
 avoid invalid calculations.  The longer the period, the more precise the
index 5868ad6fd881f6248841c57c53a99995e5de1300..7d69b7ac551bb1b0b2daedc49da42e3714fc2beb 100644 (file)
@@ -1233,7 +1233,7 @@ usage(const struct hwclock_control *ctl, FILE *out)
 #if defined(__linux__) && defined(__alpha__)
        fputs(_("     --epoch <year>   epoch input for --setepoch\n"), out);
 #endif
-       fputs(_("     --update-drift   update drift factor (requires --set or --systohc)\n"), out);
+       fputs(_("     --update-drift   update the RTC drift factor\n"), out);
        fprintf(out, _(
                "     --noadjfile      do not use %1$s\n"
                "     --adjfile <file> use an alternate file to %1$s\n"), _PATH_ADJTIME);
@@ -1465,6 +1465,11 @@ int main(int argc, char **argv)
        if (!ctl.adj_file_name)
                ctl.adj_file_name = _PATH_ADJTIME;
 
+       if (ctl.update && !ctl.set && !ctl.systohc) {
+               warnx(_("--update-drift requires --set or --systohc"));
+               hwclock_exit(&ctl, EX_USAGE);
+       }
+
        if (ctl.noadjfile && !ctl.utc && !ctl.local_opt) {
                warnx(_("With --noadjfile, you must specify "
                        "either --utc or --localtime"));