Commit Graph

57 Commits

Author SHA1 Message Date
Sami Kerola 254e9e58b7 rtcwake: make some command line options mutually exclusive
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-29 13:39:37 +02:00
Sami Kerola 5b4185e17d rtcwake: improve coding style
Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-29 13:39:37 +02:00
Sami Kerola 43a44bfc6d rtcwake: add --list-modes
Commit ece44f19f4 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>
2015-06-29 13:39:37 +02:00
Sami Kerola 067fde32c9 rtcwake: do not overwrite device name
This improves error messaging, and removes a memory leak.

Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-29 13:39:37 +02:00
Sami Kerola 499a0c7956 rtcwake: clean up struct tm initializations
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-29 13:39:37 +02:00
Sami Kerola 356b2989ae rtcwake: fix preprocessor redefinition
The RTC_AF is expected to be part of linux/rtc.h file.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-29 13:39:37 +02:00
Sami Kerola a10ce9a3e5 rtcwake: add human readable --date timestamp format
Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-29 13:39:37 +02:00
Sami Kerola 3e5a54554d rtcwake: improve read_clock_mode()
Make skipping two lines more robust, and add message about unexpected
adjfile contents when running with --verbose.

Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-29 13:39:37 +02:00
Sami Kerola 5fde2f0d34 rtcwake: remove RTC_ALM_READ and RTC_ALM_SET compatibility
The RTC_WKALM_RD and RTC_WKALM_SET have been available since 2.6.17, and
preferred way since 2007.  Keeping the fallbacks to the old interface is
no longer needed.

Reference: e824290e5d
Reference: f8245c2688
Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-29 13:39:37 +02:00
Sami Kerola 64a8067835 rtcwake: replace long if else statement with switch case
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-29 13:39:37 +02:00
Sami Kerola 6e1ec14faf rtcwake: enumerate constant mode strings
Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-29 13:39:37 +02:00
Sami Kerola 71d95e92c1 rtcwake: add rtcwake_control and remove global variables
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-29 13:39:37 +02:00
Ruediger Meier f205c90a72 build: fix printf warnings for icc (-Wformat-security)
Intel compiler complains about printf style function calls with trivial
format string and no other arguments. Like this one:

../sys-utils/ipcrm.c(117): warning #2279: printf/scanf format not a string literal and no format arguments
                        err(EXIT_FAILURE, iskey ? _("key failed") : _("id failed"));
2015-01-21 11:15:19 +01:00
Benno Schulenberg 451dbcfae1 textual: add a docstring to most of the utilities
This adds a concise description of a tool to its usage text.

A first form of this patch was proposed by Steven Honeyman
(see http://www.spinics.net/lists/util-linux-ng/msg09994.html).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-06 11:27:38 +01:00
Sami Kerola f627750083 textual: use version printing macro everywhere
Only mount, umount, and blkid remains not using the macro because they
are print also library references.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:23 +02:00
Karel Zak a5bd793996 include/c.h: prefer nanosleep() over usleep()
Let's use nanosleep() although if usleep() exists. The nanosleep
function does no interact with signals and other timers.

The patch introduces xusleep() as replacement to libc (or our fallback)
usleep(). Yes, we don't want to use struct timespec + nanosleep()
everywhere in code as nano-time resolution is useless for us.

The patch also enlarges delays in some busy wait loops. It seems
enough to try read/write 4x per second.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-24 13:04:14 +01:00
Mike Frysinger caf60f22fb rtcwake: pass -h to shutdown
The sysvinit shutdown requires you use -h when using -H or -P.
Other inits just don't seem to care.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-04-25 09:23:40 +02:00
Karel Zak ece44f19f4 rtcwake: add support for "freeze" mode
Supported by Linux since 3.9 (upstream commit
7e73c5ae6e7991a6c01f6d096ff8afaef4458c36).

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-23 13:20:15 +02:00
Karel Zak 49ebda9b89 rtcwake: add --auto to usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-05 13:19:13 +02:00
Karel Zak 09e092ad5c rtcwake: clean up usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-26 12:14:31 +01:00
Karel Zak 7528fae9e9 include/pathnames: rename _PATH_ADJPATH to _PATH_ADJTIME
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-26 11:45:45 +01:00
Karel Zak 3a2f3e82bb rtcwake: add --adjfile command line option
... for better compatibility with hwclock.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-26 11:16:12 +01:00
Sami Kerola 07ff972eb6 translation: unify exec error messages
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-02-06 11:51:17 +01:00
Benno Schulenberg 217615e8ed textual: standardize reporting of program name plus package version
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-01-25 11:47:29 +01:00
Karel Zak 2a31396a9c include/c: move usleep() fallback to c.h
To make it available everywhere in code.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-22 11:03:09 +02:00
Giacomo 829eab67e6 rtcwake: doesn't reset wakealarm
Disable an alarm use the same logic used to enable it: first try RTC_WKALM_SET
with the "enabled" flag set to false, if it fails fall back to RTC_AIE_OFF.

Signed-off-by: Giacomo <giacomo.perale@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-13 13:23:11 +02:00
Sami Kerola 289dcc9023 translation: unify file open error messages
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-16 18:18:22 +02:00
Karel Zak 20a3998222 sys-utils: cleanup strtoxx_or_err()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-15 17:45:17 +02:00
Sami Kerola efb8854f4c sys-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:49:40 +02:00
Karel Zak 8063efea36 rtcwake: tiny coding style change
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-02 13:21:33 +02:00
Paul Fox 1707576155 rtcwake: only invoke RTC_AIE_ON/OFF ioctls in pairs
many rtc drivers don't implement the RTC_AIE_ON/OFF ioctls at all --
so if we never tried to enable the alarm interrupt, don't try to
disable it later.

Signed-off-by: Paul Fox <pgf@laptop.org>
2012-04-02 13:14:00 +02:00
Sami Kerola 0e00261d2e rtcwake: align with howto-usage-function.txt
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-10-30 14:23:54 +01:00
Petr Uzel 8cbe756a63 rtcwake: fix crash (invalid free)
~ $ rtcwake -d X -s 10
*** glibc detected *** rtcwake: munmap_chunk(): invalid pointer: 0x00007fff839253c3 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x733b6)[0x7f582677a3b6]
rtcwake[0x4022d5]
/lib64/libc.so.6(__libc_start_main+0xfd)[0x7f5826725bfd]
rtcwake[0x4016b9]
======= Memory map: ========
<SNIP>

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-10-17 11:06:33 +02:00
Karel Zak 704c770555 rtcwake: cleanup usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-16 13:23:30 +02:00
Davidlohr Bueso c1196d3ab7 rtcwake: do not duplicate argument strings
This is not necessary and prevents memory leaks.

Reported-by: Marek Otahal <markotahal@gmail.com>
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-03-08 13:34:20 +01:00
Lawrence Rust e6d1dc9416 rtcwake: test for available suspend modes
Signed-off-by: Lawrence Rust <lawrence@softsystem.co.uk>
2011-02-28 10:21:12 +01:00
Fabian Groffen eb76ca98b0 build-sys: provide alternatives for err, errx, warn and warnx
Solaris lacks err, errx, warn and warnx.  This also means the err.h header
doesn't exist.  Removed err.h include from all files, and included err.h from
c.h instead if it exists, otherwise alternatives are provided.

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
2011-02-14 17:45:24 +01:00
Karel Zak 07b336c92e rtcwake: use err.h routines
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-11-26 17:43:54 +01:00
Marek Otahal fcf6729430 rtcwake: add 'show' mode for rtc alarm
The 'show' mode prints information on current alarm setting.

[kzak@redhat.com: - code clean up
                  - don't setup alarm on 'disable' mode]

Signed-off-by: Marek Otahal <markotahal@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-11-26 16:47:38 +01:00
Davidlohr Bueso 2ab428f6a8 sys-utils: make use xalloc wrappers
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2010-11-01 16:43:23 +01:00
Marek Otahal c15dd93b17 rtcwake : add disable action for rtc alarm
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-04-23 14:16:59 +02:00
Karel Zak 569f3ca278 rtcwake: add --dry-run option
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-04-08 09:20:21 +02:00
Karel Zak ecd55f9647 rtcwake: does miss the "off" option
Reported-by: Piergiorgio Sartor <piergiorgio.sartor@nexgo.de>
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=580296
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-04-08 08:51:00 +02:00
Paul Fox 1da17ec6c1 rtcwake: ignore the tm_isdst field returned from the RTC
Signed-off-by: Paul Fox <pgf@laptop.org>
2009-09-07 12:29:37 +02:00
Karel Zak 77f5744c98 rtcwake: add S5 support
Based on patch from
   Piergiorgio Sartor <piergiorgio.sartor@nexgo.de>
at
   https://bugzilla.redhat.com/show_bug.cgi?id=449115

Piergiorgio's note about S5:
> According to the ACPI specifications, chapter 4.7.2.4 "Real Time
> Clock Alarm", the wakeup from RTC, when supported, should work from
> *sleep* state S1-S3 and, optionally, from S4.
>
> Note 3 (same chapter) says that S5 is *not* a sleep state and should
> not be supported. Actually it also says that: "The OS will disable
> the RTC_EN bit prior to entering the G2/S5 or G3 states regardless."
>
> Nevertheless, on all PC supporting the RTC wakeup I tested, all were
> able to wake from S5.

Signed-off-by: Karel Zak <kzak@redhat.com>
2009-09-07 12:04:26 +02:00
Daniel Mierswa 437fa54f05 replace usleep() for systems that don't have them
This function is marked obsolete in POSIX.1-2001 and removed in
POSIX.1-2008.

Conditionally replaced with nanosleep().

Signed-off-by: Daniel Mierswa <impulze@impulze.org>
2009-08-21 09:58:17 +02:00
Marco d'Itri e4b0fc36ff rtcwake: support not suspending
People usually want to use pm-utils to suspend the system instead of
the raw kernel interface, so I added an option to just exit after
configuring the wakeup time.
Actually I think that all the suspend code should be removed from
rtcwake, since it does not really belong there.

Signed-off-by: Marco d'Itri <md@linux.it>
2009-01-26 21:22:24 +01:00
Karel Zak f8d87ab139 rtcwake: cleanup return codes
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-08-06 12:36:10 +02:00
Gabriel Burt fc18118430 rtcwake: prefer RTC_WKALM_SET over RTC_ALM_SET
rtcwake: Prefer RTC_WKALM_SET over RTC_ALM_SET, fixing bug with not
waking up with new RTCs.  Also, return error if unable to set the alarm.

Signed-off-by: Gabriel Burt <gburt@novell.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-08-06 12:19:46 +02:00
Paulius Zaleckas 47bf8ef7f1 rtcwake: fix the default mode to "standby"
Writing "suspend" to /sys/power/state does nothing.
Even "man rtcwake" says that default should be "standby" :)

Signed-off-by: Paulius Zaleckas <paulius.zaleckas@teltonika.lt>
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-06-09 12:49:00 +02:00