diff options
-rw-r--r-- | sys-utils/rtcwake.8 | 5 | ||||
-rw-r--r-- | sys-utils/rtcwake.c | 44 |
2 files changed, 30 insertions, 19 deletions
diff --git a/sys-utils/rtcwake.8 b/sys-utils/rtcwake.8 index a536f322c..dea5c940c 100644 --- a/sys-utils/rtcwake.8 +++ b/sys-utils/rtcwake.8 @@ -21,7 +21,7 @@ rtcwake - enter a system sleep state until specified wakeup time .SH SYNOPSIS .B rtcwake -.RB [ \-hvVluan ] +.RB [ options ] .RB [ \-d .IR device ] .RB [ \-m @@ -56,6 +56,9 @@ Displays version information and exists. This option does everything but actually setup alarm, suspend system or wait for the alarm. .TP +\fB-A\fP | \fB--adjfile\fP \fIfile\fP +Specifies an alternative path to the adjust file. +.TP \fB-a\fP | \fB--auto\fP Reads the clock mode (whether the hardware clock is set to UTC or local time) from \fI/etc/adjtime\fP. That's the location where the diff --git a/sys-utils/rtcwake.c b/sys-utils/rtcwake.c index f0dada2e0..f233f506e 100644 --- a/sys-utils/rtcwake.c +++ b/sys-utils/rtcwake.c @@ -51,7 +51,6 @@ #define RTC_PATH "/sys/class/rtc/%s/device/power/wakeup" #define SYS_POWER_STATE_PATH "/sys/power/state" -#define ADJTIME_PATH "/etc/adjtime" #define DEFAULT_DEVICE "/dev/rtc0" #define DEFAULT_MODE "standby" @@ -61,25 +60,11 @@ enum ClockMode { CM_LOCAL }; +static char *adjfile = _PATH_ADJPATH; static unsigned verbose; static unsigned dryrun; enum ClockMode clock_mode = CM_AUTO; -static struct option long_options[] = { - {"auto", no_argument, 0, 'a'}, - {"dry-run", no_argument, 0, 'n'}, - {"local", no_argument, 0, 'l'}, - {"utc", no_argument, 0, 'u'}, - {"verbose", no_argument, 0, 'v'}, - {"version", no_argument, 0, 'V'}, - {"help", no_argument, 0, 'h'}, - {"mode", required_argument, 0, 'm'}, - {"device", required_argument, 0, 'd'}, - {"seconds", required_argument, 0, 's'}, - {"time", required_argument, 0, 't'}, - {0, 0, 0, 0 } -}; - static void __attribute__((__noreturn__)) usage(FILE *out) { fputs(USAGE_HEADER, out); @@ -87,6 +72,9 @@ static void __attribute__((__noreturn__)) usage(FILE *out) _(" %s [options]\n"), program_invocation_short_name); fputs(USAGE_OPTIONS, out); + fprintf(out, + _(" -A, --adjfile <file> specifies the path to the adjust file\n" + " the default is %s\n"), _PATH_ADJPATH); fputs(_(" -d, --device <device> select rtc device (rtc0|rtc1|...)\n" " -n, --dry-run does everything, but suspend\n" " -l, --local RTC uses local timezone\n" @@ -293,7 +281,7 @@ static int read_clock_mode(void) FILE *fp; char linebuf[MAX_LINE]; - fp = fopen(ADJTIME_PATH, "r"); + fp = fopen(adjfile, "r"); if (!fp) return -1; @@ -390,14 +378,34 @@ int main(int argc, char **argv) int fd; time_t alarm = 0; + static const struct option long_options[] = { + {"adjfile", required_argument, 0, 'A'}, + {"auto", no_argument, 0, 'a'}, + {"dry-run", no_argument, 0, 'n'}, + {"local", no_argument, 0, 'l'}, + {"utc", no_argument, 0, 'u'}, + {"verbose", no_argument, 0, 'v'}, + {"version", no_argument, 0, 'V'}, + {"help", no_argument, 0, 'h'}, + {"mode", required_argument, 0, 'm'}, + {"device", required_argument, 0, 'd'}, + {"seconds", required_argument, 0, 's'}, + {"time", required_argument, 0, 't'}, + {0, 0, 0, 0 } + }; + setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); atexit(close_stdout); - while ((t = getopt_long(argc, argv, "ahd:lm:ns:t:uVv", + while ((t = getopt_long(argc, argv, "A:ahd:lm:ns:t:uVv", long_options, NULL)) != EOF) { switch (t) { + case 'A': + /* for better compatibility with hwclock */ + adjfile = optarg; + break; case 'a': /* CM_AUTO is default */ break; |