Commit Graph

66 Commits

Author SHA1 Message Date
Sami Kerola 74ce680a3e
misc: simplify if clauses [oclint]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-21 21:14:33 +01:00
Sebastian Rasmussen 9e93004171 misc: Fix various typos
Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.

Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
2016-05-31 23:40:21 +02:00
Ruediger Meier eaac9f88f9 misc: fix some includes
features.h:  any glibc header includes this already
libgen.h:    was unused there
sys/uio.h:   for writev(3p)
sys/queue.h  seems like it was never used

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-29 13:04:56 +01:00
Karel Zak 6b497c0e19 rtcwake: improve open() usage [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-05 11:33:29 +02:00
Karel Zak f078134257 rtcwake: cosmetic changes
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-29 15:19:47 +02:00
Karel Zak bac778c06a rtcwake: fix ARRAY_SIZE() usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-29 13:46:05 +02:00
Karel Zak 2626f123a5 rtcwake: don't use usage() on error
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-29 13:43:41 +02:00
Sami Kerola 76037ac7d8 rtcwake: fix valgrind warning
==3445== Syscall param ioctl(generic) points to uninitialised byte(s)
==3445==    at 0x4F16477: ioctl (in /usr/lib/libc-2.21.so)
==3445==    by 0x402785: setup_alarm (rtcwake.c:231)
==3445==    by 0x403302: main (rtcwake.c:520)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-29 13:39:37 +02:00
Sami Kerola f87b73ab44 rtcwake: read accepted mode strings from /sys/power/state
The rtcwake has various mode names that are internal to the command,
listed in rtcwake_mode_string array, while some modes are dynamicaly
listed in /sys/power/state.  Together these form the allowed modes.

[kzak@redhat.com: - cleanup strv usage]

Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-29 13:39:37 +02:00
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