summaryrefslogtreecommitdiffstats
path: root/sys-utils/rtcwake.c
diff options
context:
space:
mode:
authorSami Kerola2015-01-10 21:07:08 +0100
committerKarel Zak2015-06-29 13:39:37 +0200
commit43a44bfc6da8f4666c5dd6bc03c89713e6c4bd46 (patch)
tree439991ec60e400dfb55eab562146f2c70efe97af /sys-utils/rtcwake.c
parentrtcwake: do not overwrite device name (diff)
downloadkernel-qcow2-util-linux-43a44bfc6da8f4666c5dd6bc03c89713e6c4bd46.tar.gz
kernel-qcow2-util-linux-43a44bfc6da8f4666c5dd6bc03c89713e6c4bd46.tar.xz
kernel-qcow2-util-linux-43a44bfc6da8f4666c5dd6bc03c89713e6c4bd46.zip
rtcwake: add --list-modes
Commit ece44f19f423408f576f348fed2845c876d72c6e missed freeze mode, which to a simple patch adding the missing argument but Karel pointed out it would be better to make the rtcwake to tell what arguments are supported so that possible changes end up to be automatically correct in bash completion. Proposed-by: Karel Zak <kzak@redhat.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'sys-utils/rtcwake.c')
-rw-r--r--sys-utils/rtcwake.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/sys-utils/rtcwake.c b/sys-utils/rtcwake.c
index 4b9483cc5..1044c86db 100644
--- a/sys-utils/rtcwake.c
+++ b/sys-utils/rtcwake.c
@@ -117,6 +117,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
fputs(_(" -d, --device <device> select rtc device (rtc0|rtc1|...)\n"), out);
fputs(_(" -n, --dry-run does everything, but suspend\n"), out);
fputs(_(" -l, --local RTC uses local timezone\n"), out);
+ fputs(_(" --list-modes list available modes\n"), out);
fputs(_(" -m, --mode <mode> standby|mem|... sleep mode\n"), out);
fputs(_(" -s, --seconds <seconds> seconds to sleep\n"), out);
fputs(_(" -t, --time <time_t> time to wake\n"), out);
@@ -395,6 +396,15 @@ static int open_dev_rtc(const char *devname)
return fd;
}
+static void list_modes(void)
+{
+ int i = ARRAY_SIZE(mode_str);
+
+ while (i--)
+ printf("%s%s", mode_str[i], i == 0 ? "" : " ");
+ putchar('\n');
+}
+
int main(int argc, char **argv)
{
struct rtcwake_control ctl = {
@@ -413,7 +423,8 @@ int main(int argc, char **argv)
time_t alarm = 0;
enum {
- OPT_DATE = CHAR_MAX + 1
+ OPT_DATE = CHAR_MAX + 1,
+ OPT_LIST
};
static const struct option long_options[] = {
@@ -430,6 +441,7 @@ int main(int argc, char **argv)
{"seconds", required_argument, 0, 's'},
{"time", required_argument, 0, 't'},
{"date", required_argument, 0, OPT_DATE},
+ {"list-modes", no_argument, 0, OPT_LIST},
{0, 0, 0, 0 }
};
@@ -458,6 +470,10 @@ int main(int argc, char **argv)
ctl.clock_mode = CM_LOCAL;
break;
+ case OPT_LIST:
+ list_modes();
+ return EXIT_SUCCESS;
+
case 'm':
if ((suspend = get_mode(optarg)) < 0)
errx(EXIT_FAILURE, _("unrecognized suspend state '%s'"), optarg);