int set_epoch_rtc(const struct hwclock_control *ctl)
{
int rtc_fd;
+ unsigned long epoch;
- if (ctl->epoch_option < 1900) {
- /* kernel would not accept this epoch value
- *
- * Bad habit, deciding not to do what the user asks just
- * because one believes that the kernel might not like it.
- */
- warnx(_("The epoch value may not be less than 1900. "
- "You requested %ld"), ctl->epoch_option);
+ epoch = strtoul(ctl->epoch_option, NULL, 10);
+
+ /* There were no RTC clocks before 1900. */
+ if (epoch < 1900 || epoch == ULONG_MAX) {
+ warnx(_("invalid epoch '%s'."), ctl->epoch_option);
return 1;
}
if (ctl->debug)
printf(_("setting epoch to %lu "
- "with RTC_EPOCH_SET ioctl to %s.\n"), ctl->epoch_option,
+ "with RTC_EPOCH_SET ioctl to %s.\n"), epoch,
rtc_dev_name);
-
- if (ioctl(rtc_fd, RTC_EPOCH_SET, ctl->epoch_option) == -1) {
+ if (ioctl(rtc_fd, RTC_EPOCH_SET, epoch) == -1) {
if (errno == EINVAL)
warnx(_("The kernel device driver for %s "
"does not have the RTC_EPOCH_SET ioctl."),
.BI \-\-epoch= year
This option is required when using the
.BR \%\-\-setepoch \ function.
+.RI "The minimum " year
+value is 1900. The maximum is system dependent
+.RB ( ULONG_MAX\ -\ 1 ).
.
.TP
.BR \-f , \ \-\-rtc=\fIfilename\fR
#include "nls.h"
#include "optutils.h"
#include "pathnames.h"
-#include "strutils.h"
#include "hwclock.h"
#include "timeutils.h"
#include "env.h"
printf(_("Kernel is assuming an epoch value of %lu\n"),
epoch);
} else if (ctl->setepoch) {
- if (ctl->epoch_option == 0)
+ if (!ctl->epoch_option)
warnx(_
("To set the epoch value, you must use the 'epoch' "
"option to tell to what value to set it."));
else if (ctl->testing)
printf(_
- ("Not setting the epoch to %lu - testing only.\n"),
+ ("Not setting the epoch to %s - testing only.\n"),
ctl->epoch_option);
else if (set_epoch_rtc(ctl))
printf(_
};
int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
- strutils_set_exitcode(EX_USAGE);
-
/* Remember what time we were invoked */
gettimeofday(&startup_time, NULL);
ctl.hwaudit_on = 1;
break;
case OPT_EPOCH:
- ctl.epoch_option = /* --epoch */
- strtoul_or_err(optarg, _("invalid epoch argument"));
+ ctl.epoch_option = optarg; /* --epoch */
break;
#endif
case OPT_NOADJFILE:
char *date_opt;
char *adj_file_name;
#if defined(__linux__) && defined(__alpha__)
- unsigned long epoch_option;
+ char *epoch_option;
#endif
#ifdef __linux__
char *rtc_dev_name;