~ubuntu-branches/debian/sid/util-linux/sid

« back to all changes in this revision

Viewing changes to hwclock/hwclock.c

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones, Aurelien Jarno, Mike Frysinger, LaMont Jones, Chris Webb, Rajeev V. Pillai, Tom Prince, Karel Zak, localization folks
  • Date: 2009-05-29 04:19:25 UTC
  • mfrom: (1.3.1 upstream) (5.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20090529041925-vrgj0hskukfog849
Tags: 2.15.1~rc1-1
[Aurelien Jarno]

* chrt: don't assume SCHED_BATCH and SCHED_IDLE exist
* kFreeBSD hackery for building.  Closes: #527384

[Mike Frysinger]

* lscpu: fix cpuid code on x86/PIC
* losetup: handle symlinks in /dev/loop/

[LaMont Jones]

* Add keybuk as uploader.

[Chris Webb]

* fdisk: (and cfdisk) fix to be consistent about maximum heads

[Rajeev V. Pillai]

* cal: Highlight today even when month or year specified

[Tom Prince]

* cal: uClibc has langinfo.h but not _NL_TIME_WEEK_1STDAY.

[Karel Zak]

* build-sys: fix "make -C" bug
* build-sys: fix blkid.h include for old e2fsprogs
* blkid: make libuuid optional
* blkid: fix "hangs forever with partition type mdraid"
* blkid: blkid_do_safeprobe() has to be tolerant to RAIDs
* blkid: cleanup debug messages and return codes in blkid_do_probe()
* mount: fix undefined reference to `security_get_initial_context'.  gentoo:
  #270168
* libblkid: update man page
* libblkid: fix reiserfs name
* build-sys: add UTIL_{SET,RESTORE}_FLAGS
* build-sys: fix blkid detection in configure.ac
* tests: add mdraid libblkid test
* tests: fix reiserfs test
* tests: don't run some mount tests for non-root users
* tests: remove broken Xen dumps for lscpu
* tests: move lscpu /proc and /sys dumps to tarballs
* tests: fix script that creates lscpu dumps
* docs: update AUTHORS file
* docs: add v2.15.1 ReleaseNotes
* docs: add missing commands/projects to AUTHORS file
* build-sys: release++ (v2.15.1-rc1)
* po: merge changes

[localization folks]

* po: update vi.po (from translationproject.org) (Clytie Siddall)

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
/* Here the information for time adjustments is kept. */
104
104
#define ADJPATH "/etc/adjtime"
105
105
 
 
106
const char *adj_file_name = NULL;
 
107
 
106
108
/* Store the date here when "badyear" flag is set. */
107
109
#define LASTDATE "/var/lib/lastdate"
108
110
 
180
182
  write_date_to_file (tm);
181
183
}
182
184
 
183
 
static double
 
185
double
184
186
time_diff(struct timeval subtrahend, struct timeval subtractor) {
185
187
/*---------------------------------------------------------------------------
186
188
  The difference in seconds between two times in "timeval" format.
249
251
  int rc;  /* local return code */
250
252
  struct stat statbuf;  /* We don't even use the contents of this. */
251
253
 
252
 
    rc = stat(ADJPATH, &statbuf);
 
254
    rc = stat(adj_file_name, &statbuf);
253
255
    if (rc < 0 && errno == ENOENT) {
254
256
      /* He doesn't have a adjtime file, so we'll use defaults. */
255
257
      adjtime_p->drift_factor = 0;
257
259
      adjtime_p->not_adjusted = 0;
258
260
      adjtime_p->last_calib_time = 0;
259
261
      adjtime_p->local_utc = UNKNOWN;
 
262
      adjtime_p->dirty = FALSE;        /* don't create a zero adjfile */
260
263
 
261
264
      return 0;
262
265
    }
263
266
 
264
 
    adjfile = fopen(ADJPATH, "r");   /* open file for reading */
 
267
    adjfile = fopen(adj_file_name, "r");   /* open file for reading */
265
268
    if (adjfile == NULL) {
266
 
      outsyserr("cannot open file " ADJPATH);
 
269
      outsyserr("cannot open file %s", adj_file_name);
267
270
      return EX_OSFILE;
268
271
    }
269
272
 
349
352
 
350
353
        rc = ur->synchronize_to_clock_tick();
351
354
 
352
 
        if (debug) printf(_("...got clock tick\n"));
 
355
        if (debug) {
 
356
                if (rc)
 
357
                        printf(_("...synchronization failed\n"));
 
358
                else
 
359
                        printf(_("...got clock tick\n"));
 
360
        }
353
361
 
354
362
        return rc;
355
363
}
422
430
}
423
431
 
424
432
 
425
 
static void
 
433
static int
426
434
read_hardware_clock(const bool universal, bool *valid_p, time_t *systime_p){
427
435
/*----------------------------------------------------------------------------
428
436
  Read the hardware clock and return the current time via <tm> argument.
433
441
  int err;
434
442
 
435
443
  err = ur->read_hardware_clock(&tm);
 
444
  if (err)
 
445
          return err;
436
446
 
437
447
  if (badyear)
438
448
    read_date_from_file(&tm);
442
452
            tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
443
453
            tm.tm_hour, tm.tm_min, tm.tm_sec);
444
454
  mktime_tz(tm, universal, valid_p, systime_p);
 
455
 
 
456
  return 0;
445
457
}
446
458
 
447
459
 
514
526
 
515
527
  time_t newhwtime;
516
528
  struct timeval beginsystime, nowsystime;
 
529
  double tdiff;
517
530
 
518
531
 time_resync:
519
532
  gettimeofday(&beginsystime, NULL);
520
 
  newhwtime = sethwtime + (int) time_diff(beginsystime, refsystime) + 1;
 
533
  tdiff = time_diff(beginsystime, refsystime);
 
534
  newhwtime = sethwtime + (int) (tdiff + 0.5);
521
535
  if (debug)
522
536
    printf(_("Time elapsed since reference time has been %.6f seconds.\n"
523
 
           "Delaying further to reach the next full second.\n"),
524
 
           time_diff(beginsystime, refsystime));
 
537
           "Delaying further to reach the new time.\n"), tdiff);
525
538
 
526
539
  /*
527
 
   * Now delay some more until Hardware Clock time newhwtime arrives.  The -500
528
 
   * ms is because the Hardware Clock always sets to your set time plus 500 ms
 
540
   * Now delay some more until Hardware Clock time newhwtime arrives.  The 0.5 s
 
541
   * is because the Hardware Clock always sets to your set time plus 500 ms
529
542
   * (because it is designed to update to the next second precisely 500 ms
530
543
   * after you finish the setting).
531
544
   */
532
545
  do {
533
 
          float tdiff;
534
546
          gettimeofday(&nowsystime, NULL);
535
547
          tdiff = time_diff(nowsystime, beginsystime);
536
548
          if (tdiff < 0)
537
 
                  goto time_resync;     /* probably time was reset */
538
 
  } while (time_diff(nowsystime, refsystime) - 0.5 < newhwtime - sethwtime);
 
549
                  goto time_resync;     /* probably backward time reset */
 
550
          if (tdiff > 0.1)
 
551
                  goto time_resync;     /* probably forward time reset */
 
552
          beginsystime = nowsystime;
 
553
          tdiff = time_diff(nowsystime, refsystime);
 
554
  } while (newhwtime == sethwtime + (int) (tdiff + 0.5));
539
555
 
540
556
  set_hardware_clock(newhwtime, universal, testing);
541
557
}
737
753
}
738
754
 
739
755
 
 
756
static int
 
757
set_system_clock_timezone(const bool testing) {
 
758
/*----------------------------------------------------------------------------
 
759
   Reset the System Clock from local time to UTC, based on its current
 
760
   value and the timezone.
 
761
 
 
762
   Also set the kernel time zone value to the value indicated by the
 
763
   TZ environment variable and/or /usr/lib/zoneinfo/, interpreted as
 
764
   tzset() would interpret them.
 
765
 
 
766
   If 'testing' is true, don't actually update anything -- just say we
 
767
   would have.
 
768
-----------------------------------------------------------------------------*/
 
769
  int retcode;
 
770
  struct timeval tv;
 
771
  struct tm *broken;
 
772
  int minuteswest;
 
773
  int rc;
 
774
 
 
775
  gettimeofday(&tv, NULL);
 
776
  if (debug) {
 
777
    struct tm broken_time;
 
778
    char ctime_now[200];
 
779
 
 
780
    broken_time = *gmtime(&tv.tv_sec);
 
781
    strftime(ctime_now, sizeof(ctime_now), "%Y/%m/%d %H:%M:%S", &broken_time);
 
782
    printf(_("Current system time: %ld = %s\n"), (long) tv.tv_sec, ctime_now);
 
783
  }
 
784
 
 
785
  broken = localtime(&tv.tv_sec);
 
786
#ifdef HAVE_TM_GMTOFF
 
787
  minuteswest = -broken->tm_gmtoff/60;          /* GNU extension */
 
788
#else
 
789
  minuteswest = timezone/60;
 
790
  if (broken->tm_isdst)
 
791
          minuteswest -= 60;
 
792
#endif
 
793
 
 
794
  gettimeofday(&tv, NULL);
 
795
  tv.tv_sec += minuteswest * 60;
 
796
 
 
797
  if (debug) {
 
798
    struct tm broken_time;
 
799
    char ctime_now[200];
 
800
 
 
801
    broken_time = *gmtime(&tv.tv_sec);
 
802
    strftime(ctime_now, sizeof(ctime_now), "%Y/%m/%d %H:%M:%S", &broken_time);
 
803
 
 
804
    printf(_("Calling settimeofday:\n"));
 
805
    printf(_("\tUTC: %s\n"), ctime_now);
 
806
    printf(_("\ttv.tv_sec = %ld, tv.tv_usec = %ld\n"),
 
807
           (long) tv.tv_sec, (long) tv.tv_usec);
 
808
    printf(_("\ttz.tz_minuteswest = %d\n"), minuteswest);
 
809
  }
 
810
  if (testing) {
 
811
    printf(_("Not setting system clock because running in test mode.\n"));
 
812
    retcode = 0;
 
813
  } else {
 
814
    const struct timezone tz = { minuteswest, 0 };
 
815
 
 
816
    rc = settimeofday(&tv, &tz);
 
817
    if (rc) {
 
818
            if (errno == EPERM) {
 
819
                    fprintf(stderr,
 
820
                            _("Must be superuser to set system clock.\n"));
 
821
                    retcode = EX_NOPERM;
 
822
            } else {
 
823
                    outsyserr(_("settimeofday() failed"));
 
824
                    retcode = 1;
 
825
            }
 
826
    } else retcode = 0;
 
827
  }
 
828
  return retcode;
 
829
}
 
830
 
 
831
 
740
832
static void
741
833
adjust_drift_factor(struct adjtime *adjtime_p,
742
834
                    const time_t nowtime,
844
936
                     const double not_adjusted,
845
937
                     const time_t systime,
846
938
                     int *adjustment_p,
847
 
                     double *retro_p,
848
 
                     const int debug ) {
 
939
                     double *retro_p) {
849
940
/*----------------------------------------------------------------------------
850
941
  Do the drift adjustment calculation.
851
942
 
900
991
    if (testing) {
901
992
      printf(_("Not updating adjtime file because of testing mode.\n"));
902
993
      printf(_("Would have written the following to %s:\n%s"),
903
 
             ADJPATH, newfile);
 
994
             adj_file_name, newfile);
904
995
    } else {
905
996
      FILE *adjfile;
906
997
      int err = 0;
907
998
 
908
 
      adjfile = fopen(ADJPATH, "w");
 
999
      adjfile = fopen(adj_file_name, "w");
909
1000
      if (adjfile == NULL) {
910
 
        outsyserr("Could not open file with the clock adjustment parameters "
911
 
               "in it (" ADJPATH ") for writing");
 
1001
        outsyserr(_("Could not open file with the clock adjustment parameters "
 
1002
               "in it (%s) for writing"), adj_file_name);
912
1003
        err = 1;
913
1004
      } else {
914
1005
        if (fputs(newfile, adjfile) < 0) {
915
 
          outsyserr("Could not update file with the clock adjustment "
916
 
                    "parameters (" ADJPATH ") in it");
 
1006
          outsyserr(_("Could not update file with the clock adjustment "
 
1007
                    "parameters (%s) in it"), adj_file_name);
917
1008
          err = 1;
918
1009
        }
919
1010
        if (fclose(adjfile) < 0) {
920
 
          outsyserr("Could not update file with the clock adjustment "
921
 
                    "parameters (" ADJPATH ") in it");
 
1011
          outsyserr(_("Could not update file with the clock adjustment "
 
1012
                    "parameters (%s) in it"), adj_file_name);
922
1013
          err = 1;
923
1014
        }
924
1015
      }
972
1063
    adjtime_p->dirty = TRUE;
973
1064
  } else if (adjtime_p->last_adj_time == 0) {
974
1065
    if (debug)
975
 
      printf("Not setting clock because last adjustment time is zero, "
976
 
             "so history is bad.");
 
1066
      printf(_("Not setting clock because last adjustment time is zero, "
 
1067
             "so history is bad."));
977
1068
  } else {
978
1069
    int adjustment;
979
1070
    /* Number of seconds we must insert in the Hardware Clock */
985
1076
                         adjtime_p->last_adj_time,
986
1077
                         adjtime_p->not_adjusted,
987
1078
                         hclocktime,
988
 
                         &adjustment, &retro,
989
 
                         debug );
 
1079
                         &adjustment, &retro);
990
1080
    if (adjustment > 0 || adjustment < -1) {
991
1081
      set_hardware_clock_exact(hclocktime + adjustment,
992
1082
                               time_inc(read_time, -retro),
1017
1107
  if (!ur)
1018
1108
          ur = probe_for_kd_clock();
1019
1109
 
 
1110
  /*
 
1111
   * This final clause is a really bad idea on x86/AT PCs. You run the
 
1112
   * risk of a race condition with another copy of hwclock
 
1113
   * that already has /dev/rtc open. The fallback case on
 
1114
   * x86 is to then raise I/O priviledge level and access
 
1115
   * the RTC CMOS directly using I/O instructions. Simultaneous
 
1116
   * access like that can really hose the RTC.
 
1117
   */
 
1118
#if !defined(__i386__)
1020
1119
  if (!ur && !user_requests_ISA)
1021
1120
          ur = probe_for_cmos_clock();
 
1121
#endif
1022
1122
 
1023
1123
  if (debug) {
1024
1124
          if (ur)
1031
1131
static int
1032
1132
manipulate_clock(const bool show, const bool adjust, const bool noadjfile,
1033
1133
                 const bool set, const time_t set_time,
1034
 
                 const bool hctosys, const bool systohc,
 
1134
                 const bool hctosys, const bool systohc, const bool systz,
1035
1135
                 const struct timeval startup_time,
1036
1136
                 const bool utc, const bool local_opt,
1037
1137
                 const bool testing) {
1070
1170
        adjtime.dirty = TRUE;
1071
1171
      }
1072
1172
 
1073
 
      rc = synchronize_to_clock_tick();  /* this takes up to 1 second */
1074
 
      if (rc)
1075
 
              return rc;
1076
 
 
1077
1173
      {
1078
1174
        struct timeval read_time;
1079
1175
          /* The time at which we read the Hardware Clock */
1080
1176
 
1081
 
        bool hclock_valid;
 
1177
        bool hclock_valid = FALSE;
1082
1178
          /* The Hardware Clock gives us a valid time, or at least something
1083
1179
             close enough to fool mktime().
1084
1180
             */
1085
1181
 
1086
 
        time_t hclocktime;
 
1182
        time_t hclocktime = 0;
1087
1183
          /* The time the hardware clock had just after we
1088
1184
             synchronized to its next clock tick when we started up.
1089
1185
             Defined only if hclock_valid is true.
1090
1186
             */
1091
1187
 
1092
 
        gettimeofday(&read_time, NULL);
1093
 
        read_hardware_clock(universal, &hclock_valid, &hclocktime);
 
1188
        if (show || adjust || hctosys || (!noadjfile && !systz)) {
 
1189
          /* data from HW-clock are required */
 
1190
          rc = synchronize_to_clock_tick();
 
1191
          if (rc && rc != 2)            /* 2= synchronization timeout */
 
1192
            return EX_IOERR;
 
1193
          gettimeofday(&read_time, NULL);
 
1194
          rc = read_hardware_clock(universal, &hclock_valid, &hclocktime);
 
1195
          if (rc)
 
1196
             return EX_IOERR;
 
1197
        }
1094
1198
 
1095
1199
        if (show) {
1096
1200
          display_time(hclock_valid, hclocktime,
1098
1202
        } else if (set) {
1099
1203
          set_hardware_clock_exact(set_time, startup_time,
1100
1204
                                      universal, testing);
1101
 
          adjust_drift_factor(&adjtime, set_time, hclock_valid, hclocktime,
1102
 
                              time_diff(read_time, startup_time));
 
1205
          if (!noadjfile)
 
1206
            adjust_drift_factor(&adjtime, set_time, hclock_valid, hclocktime,
 
1207
                                time_diff(read_time, startup_time));
1103
1208
        } else if (adjust) {
1104
1209
          do_adjustment(&adjtime, hclock_valid, hclocktime,
1105
1210
                        read_time, universal, testing);
1115
1220
 
1116
1221
          set_hardware_clock_exact((time_t) reftime.tv_sec, reftime,
1117
1222
                                   universal, testing);
1118
 
          adjust_drift_factor(&adjtime, (time_t) reftime.tv_sec, hclock_valid,
1119
 
                              hclocktime, (double) read_time.tv_usec / 1E6);
 
1223
          if (!noadjfile)
 
1224
            adjust_drift_factor(&adjtime, (time_t) reftime.tv_sec, hclock_valid,
 
1225
                                hclocktime, (double) read_time.tv_usec / 1E6);
1120
1226
        } else if (hctosys) {
1121
1227
          rc = set_system_clock(hclock_valid, hclocktime, testing);
1122
1228
          if (rc) {
1123
1229
            printf(_("Unable to set system clock.\n"));
1124
1230
            return rc;
1125
1231
          }
 
1232
        } else if (systz) {
 
1233
          if (!universal) {
 
1234
            rc = set_system_clock_timezone(testing);
 
1235
            if (rc) {
 
1236
              printf(_("Unable to set system clock.\n"));
 
1237
              return rc;
 
1238
            }
 
1239
          } else if (debug) {
 
1240
            printf(_("Clock in UTC, not changed.\n"));
 
1241
          }
1126
1242
        }
1127
1243
        if (!noadjfile)
1128
1244
         save_adjtime(adjtime, testing);
1207
1323
    "hwclock - query and set the hardware clock (RTC)\n\n"
1208
1324
    "Usage: hwclock [function] [options...]\n\n"
1209
1325
    "Functions:\n"
1210
 
    "  --help        show this help\n"
1211
 
    "  --show        read hardware clock and print result\n"
1212
 
    "  --set         set the rtc to the time given with --date\n"
1213
 
    "  --hctosys     set the system time from the hardware clock\n"
1214
 
    "  --systohc     set the hardware clock to the current system time\n"
1215
 
    "  --adjust      adjust the rtc to account for systematic drift since \n"
1216
 
    "                the clock was last set or adjusted\n"
1217
 
    "  --getepoch    print out the kernel's hardware clock epoch value\n"
1218
 
    "  --setepoch    set the kernel's hardware clock epoch value to the \n"
1219
 
    "                value given with --epoch\n"
1220
 
    "  --version     print out the version of hwclock to stdout\n"
1221
 
    "\nOptions: \n"
1222
 
    "  --utc         the hardware clock is kept in coordinated universal time\n"
1223
 
    "  --localtime   the hardware clock is kept in local time\n"
1224
 
    "  --rtc=path    special /dev/... file to use instead of default\n"
1225
 
    "  --directisa   access the ISA bus directly instead of %s\n"
1226
 
    "  --badyear     ignore rtc's year because the bios is broken\n"
1227
 
    "  --date        specifies the time to which to set the hardware clock\n"
1228
 
    "  --epoch=year  specifies the year which is the beginning of the \n"
1229
 
    "                hardware clock's epoch value\n"
1230
 
    "  --noadjfile   do not access /etc/adjtime. Requires the use of\n"
1231
 
    "                either --utc or --localtime\n"
 
1326
        "  -h | --help         show this help\n"
 
1327
        "  -r | --show         read hardware clock and print result\n"
 
1328
        "       --set          set the rtc to the time given with --date\n"
 
1329
        "  -s | --hctosys      set the system time from the hardware clock\n"
 
1330
        "  -w | --systohc      set the hardware clock to the current system time\n"
 
1331
        "       --systz        set the system time based on the current timezone\n"
 
1332
        "       --adjust       adjust the rtc to account for systematic drift since\n"
 
1333
        "                      the clock was last set or adjusted\n"
 
1334
        "       --getepoch     print out the kernel's hardware clock epoch value\n"
 
1335
        "       --setepoch     set the kernel's hardware clock epoch value to the \n"
 
1336
        "                      value given with --epoch\n"
 
1337
        "  -v | --version      print out the version of hwclock to stdout\n"
 
1338
        "\nOptions: \n"
 
1339
        "  -u | --utc          the hardware clock is kept in UTC\n"
 
1340
        "       --localtime    the hardware clock is kept in local time\n"
 
1341
        "  -f | --rtc=path     special /dev/... file to use instead of default\n"
 
1342
        "       --directisa    access the ISA bus directly instead of %s\n"
 
1343
        "       --badyear      ignore rtc's year because the bios is broken\n"
 
1344
        "       --date         specifies the time to which to set the hardware clock\n"
 
1345
        "       --epoch=year   specifies the year which is the beginning of the \n"
 
1346
        "                      hardware clock's epoch value\n"
 
1347
        "       --noadjfile    do not access /etc/adjtime. Requires the use of\n"
 
1348
        "                      either --utc or --localtime\n"
 
1349
        "       --adjfile=path specifies the path to the adjust file (default is\n"
 
1350
        "                      /etc/adjtime)\n"
 
1351
        "       --test         do everything except actually updating the hardware\n"
 
1352
        "                      clock or anything else\n"
 
1353
        "  -D | --debug        debug mode\n"
 
1354
        "\n"
1232
1355
    ),RTC_DEV);
1233
1356
#ifdef __alpha__
1234
1357
  fprintf(usageto, _(
1235
 
    "  --jensen, --arc, --srm, --funky-toy\n"
1236
 
    "                tell hwclock the type of alpha you have (see hwclock(8))\n"
 
1358
        "  -J|--jensen, -A|--arc, -S|--srm, -F|--funky-toy\n"
 
1359
        "       tell hwclock the type of alpha you have (see hwclock(8))\n"
 
1360
        "\n"
1237
1361
    ) );
1238
1362
#endif
1239
1363
 
1240
 
 
1241
1364
  fflush(stdout);
1242
1365
  if (fmt) {
1243
1366
    usageto = stderr;
1278
1401
        { "date", 1, 0, 136 },
1279
1402
        { "epoch", 1, 0, 137 },
1280
1403
        { "rtc", 1, 0, 'f' },
 
1404
        { "adjfile", 1, 0, 138 },
 
1405
        { "systz", 0, 0, 139 },
1281
1406
        { NULL, 0, 0, 0 }
1282
1407
};
1283
1408
 
1303
1428
 
1304
1429
        /* Variables set by various options; show may also be set later */
1305
1430
        /* The options debug, badyear and epoch_option are global */
1306
 
        bool show, set, systohc, hctosys, adjust, getepoch, setepoch;
 
1431
        bool show, set, systohc, hctosys, systz, adjust, getepoch, setepoch;
1307
1432
        bool utc, testing, local_opt, noadjfile, directisa;
1308
1433
        bool ARCconsole, Jensen, SRM, funky_toy;
1309
1434
        char *date_opt;
1333
1458
        textdomain(PACKAGE);
1334
1459
 
1335
1460
        /* Set option defaults */
1336
 
        show = set = systohc = hctosys = adjust = noadjfile = FALSE;
 
1461
        show = set = systohc = hctosys = systz = adjust = noadjfile = FALSE;
1337
1462
        getepoch = setepoch = utc = local_opt = testing = debug = FALSE;
1338
1463
        ARCconsole = Jensen = SRM = funky_toy = directisa = badyear = FALSE;
1339
1464
        date_opt = NULL;
1403
1528
                case 137:
1404
1529
                        epoch_option = atoi(optarg);    /* --epoch */
1405
1530
                        break;
 
1531
                case 138:
 
1532
                        adj_file_name = optarg;         /* --adjfile */
 
1533
                        break;
 
1534
                case 139:
 
1535
                        systz = TRUE;                   /* --systz */
 
1536
                        break;
1406
1537
                case 'f':
1407
1538
                        rtc_dev_name = optarg;          /* --rtc */
1408
1539
                        break;
1434
1565
                      MYNAME, argc);
1435
1566
        }
1436
1567
 
1437
 
        if (show + set + systohc + hctosys + adjust + getepoch + setepoch > 1){
 
1568
        if (show + set + systohc + hctosys + systz + adjust + getepoch
 
1569
            + setepoch > 1){
1438
1570
                fprintf(stderr, _("You have specified multiple functions.\n"
1439
1571
                                  "You can only perform one function "
1440
1572
                                  "at a time.\n"));
1455
1587
                hwclock_exit(EX_USAGE);
1456
1588
        }
1457
1589
 
 
1590
        if (adj_file_name && noadjfile) {
 
1591
                fprintf(stderr, _("%s: The --adjfile and --noadjfile options "
 
1592
                                  "are mutually exclusive.  You specified "
 
1593
                                  "both.\n"), MYNAME);
 
1594
                hwclock_exit(EX_USAGE);
 
1595
        }
 
1596
        if (!adj_file_name)
 
1597
                adj_file_name = ADJPATH;
 
1598
 
1458
1599
        if (noadjfile && !(utc || local_opt)) {
1459
1600
                fprintf(stderr, _("%s: With --noadjfile, you must specify "
1460
1601
                                  "either --utc or --localtime\n"), MYNAME);
1476
1617
                }
1477
1618
        }
1478
1619
 
1479
 
        if (!(show | set | systohc | hctosys | adjust | getepoch | setepoch))
 
1620
        if (!(show | set | systohc | hctosys | systz | adjust | getepoch
 
1621
              | setepoch))
1480
1622
                show = 1; /* default to show */
1481
1623
 
1482
1624
 
1484
1626
                permitted = TRUE;
1485
1627
        else {
1486
1628
                /* program is designed to run setuid (in some situations) */
1487
 
                if (set || hctosys || systohc || adjust) {
 
1629
                if (set || systohc || adjust) {
1488
1630
                        fprintf(stderr,
1489
1631
                                _("Sorry, only the superuser can change "
1490
1632
                                  "the Hardware Clock.\n"));
1491
1633
                        permitted = FALSE;
1492
 
                } else if (hctosys) {
 
1634
                } else if (systz || hctosys) {
1493
1635
                        fprintf(stderr,
1494
1636
                                _("Sorry, only the superuser can change "
1495
1637
                                  "the System Clock.\n"));
1526
1668
        }
1527
1669
 
1528
1670
        rc = manipulate_clock(show, adjust, noadjfile, set, set_time,
1529
 
                                hctosys, systohc, startup_time, utc,
 
1671
                                hctosys, systohc, systz, startup_time, utc,
1530
1672
                                local_opt, testing);
1531
1673
        hwclock_exit(rc);
1532
1674
        return rc;      /* Not reached */