summaryrefslogtreecommitdiffstats
path: root/sys-utils/rtcwake.c
Commit message (Collapse)AuthorAgeFilesLines
* rtcwake: terminate mode and excl[]Karel Zak2019-05-281-1/+5
| | | | | | | * terminate string read from /proc * terminate array for exclusive options Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* rtcwake: use poweroff if shutdown is not foundJustin Chen2018-11-061-12/+27
| | | | | | | Some systems do not have the shutdown command. Use poweroff as an alternative. Signed-off-by: Justin Chen <justinpopo6@gmail.com>
* rtcwake: wait stdin to settle down before entering a system sleepSami Kerola2018-01-021-0/+20
| | | | | | | | | | | | This can delay entering to system sleep up to 0.28 seconds while discarding input, when stdin is interactive device. [kzak@redhat.com: - add note to the man page] Reference: https://github.com/karelzak/util-linux/issues/527 See-also: a85c39013491713ac0d9e24fd0f07b4fabdcfc17 Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* rtcwake: fix sys vs. rtc time delta usageKarel Zak2017-11-271-1/+1
| | | | | | | | | | | | | | srett commented: After some head scratching why relative wakeup using -s always works while -t didn't seem to work at all I discovered that the adjustment for time difference between sys and rtc is actually inverted when writing the alarm (code for -m show reading is fine), so if the RTC lags 10 minutes behind, the alarm will be shifted into the future by 10 minutes, resulting in a wakeup that is 20 minutes late. Addresses: https://github.com/karelzak/util-linux/issues/544 Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-291-1/+1
| | | | | | | | | changed in include/c.h and applied via sed: sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c") sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c") Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: introduce print_usage_help_options()Ruediger Meier2017-06-271-2/+1Star
| | | | | | | | | | | | Consolidate --help and --version descriptions. We are now able to align them to the other options. We changed include/c.h. The rest of this patch was generated by sed, plus manually setting the right alignment numbers. We do not change anything but white spaces in the --help output. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: cleanup and fix --unknownopt issuesRuediger Meier2017-06-261-9/+8Star
| | | | | | | | | | | | | | | | Fixed checkusage.sh warnings: rtcwake: --unknownopt, non-empty stdout rtcwake: --unknownopt, stderr too long: 21 blockdev: --unknownopt, stderr too long: 28 lsipc: --unknownopt, stderr too long: 77 pg: --unknownopt, stderr too long: 23 renice: --unknownopt, stderr too long: 18 sulogin: --unknownopt, stderr too long: 17 write: --unknownopt, stderr too long: 12 Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: do not use plain 0 as NULL [smatch scan]Sami Kerola2017-02-201-16/+16
| | | | | | | | | | text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer Since many 'struct option' has used zero as NULL make them more readable in same go by reindenting, and using named argument requirements. Reference: https://lwn.net/Articles/93577/ Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* rtcwake: make sure buffer is zero terminated [coverity scan]Karel Zak2016-10-051-1/+1
|
* misc: always check setenv(3) return valueSami Kerola2016-08-121-1/+2
| | | | | | At least glibc setenv(3) can fail when system runs out of memory. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: fix declarations shadowing variables in the global scope [oclint]Sami Kerola2016-07-211-3/+3
| | | | | | Fixes multiple occurences of 'optarg' overwrites. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: simplify if clauses [oclint]Sami Kerola2016-07-211-6/+3Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: Fix various typosSebastian Rasmussen2016-05-311-1/+1
| | | | | | | Fix various typos in error messages, warnings, debug strings, comments and names of static functions. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* misc: fix some includesRuediger Meier2016-02-291-1/+0Star
| | | | | | | | | 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>
* rtcwake: improve open() usage [coverity scan]Karel Zak2015-08-051-7/+12
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* rtcwake: cosmetic changesKarel Zak2015-06-291-15/+28
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* rtcwake: fix ARRAY_SIZE() usageKarel Zak2015-06-291-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* rtcwake: don't use usage() on errorKarel Zak2015-06-291-4/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* rtcwake: fix valgrind warningSami Kerola2015-06-291-1/+1
| | | | | | | | | ==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>
* rtcwake: read accepted mode strings from /sys/power/stateSami Kerola2015-06-291-55/+62
| | | | | | | | | | | | 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>
* rtcwake: make some command line options mutually exclusiveSami Kerola2015-06-291-0/+7
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* rtcwake: improve coding styleSami Kerola2015-06-291-94/+29Star
| | | | | Reviewed-by: Benno Schulenberg <bensberg@justemail.net> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* rtcwake: add --list-modesSami Kerola2015-06-291-1/+17
| | | | | | | | | | | 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>
* rtcwake: do not overwrite device nameSami Kerola2015-06-291-22/+23
| | | | | | | This improves error messaging, and removes a memory leak. Reviewed-by: Karel Zak <kzak@redhat.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* rtcwake: clean up struct tm initializationsSami Kerola2015-06-291-13/+8Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* rtcwake: fix preprocessor redefinitionSami Kerola2015-06-291-4/+3Star
| | | | | | The RTC_AF is expected to be part of linux/rtc.h file. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* rtcwake: add human readable --date timestamp formatSami Kerola2015-06-291-5/+19
| | | | | Reviewed-by: Benno Schulenberg <bensberg@justemail.net> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* rtcwake: improve read_clock_mode()Sami Kerola2015-06-291-12/+7Star
| | | | | | | | 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>
* rtcwake: remove RTC_ALM_READ and RTC_ALM_SET compatibilitySami Kerola2015-06-291-36/+6Star
| | | | | | | | | | | 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: https://github.com/torvalds/linux/commit/e824290e5dcfaf2120da587b16d10dfdff8d5d3e Reference: https://github.com/torvalds/linux/commit/f8245c26886c912627ebc49f714e4491261224c4 Reviewed-by: Benno Schulenberg <bensberg@justemail.net> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* rtcwake: replace long if else statement with switch caseSami Kerola2015-06-291-8/+16
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* rtcwake: enumerate constant mode stringsSami Kerola2015-06-291-49/+65
| | | | | Reviewed-by: Karel Zak <kzak@redhat.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* rtcwake: add rtcwake_control and remove global variablesSami Kerola2015-06-291-62/+69
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* build: fix printf warnings for icc (-Wformat-security)Ruediger Meier2015-01-211-1/+1
| | | | | | | | 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"));
* textual: add a docstring to most of the utilitiesBenno Schulenberg2015-01-061-0/+3
| | | | | | | | | 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>
* textual: use version printing macro everywhereSami Kerola2014-10-011-2/+1Star
| | | | | | | 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>
* include/c.h: prefer nanosleep() over usleep()Karel Zak2014-01-241-1/+1
| | | | | | | | | | | | | | 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>
* rtcwake: pass -h to shutdownMike Frysinger2013-04-251-1/+2
| | | | | | | 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>
* rtcwake: add support for "freeze" modeKarel Zak2013-04-231-0/+1
| | | | | | | Supported by Linux since 3.9 (upstream commit 7e73c5ae6e7991a6c01f6d096ff8afaef4458c36). Signed-off-by: Karel Zak <kzak@redhat.com>
* rtcwake: add --auto to usage()Karel Zak2013-04-051-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* rtcwake: clean up usageKarel Zak2013-03-261-8/+8
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include/pathnames: rename _PATH_ADJPATH to _PATH_ADJTIMEKarel Zak2013-03-261-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* rtcwake: add --adjfile command line optionKarel Zak2013-03-261-18/+26
| | | | | | ... for better compatibility with hwclock. Signed-off-by: Karel Zak <kzak@redhat.com>
* translation: unify exec error messagesSami Kerola2013-02-061-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: standardize reporting of program name plus package versionBenno Schulenberg2013-01-251-1/+2
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* include/c: move usleep() fallback to c.hKarel Zak2012-10-221-1/+0Star
| | | | | | To make it available everywhere in code. Signed-off-by: Karel Zak <kzak@redhat.com>
* rtcwake: doesn't reset wakealarmGiacomo2012-09-131-4/+19
| | | | | | | | 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>
* translation: unify file open error messagesSami Kerola2012-07-161-3/+3
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sys-utils: cleanup strtoxx_or_err()Karel Zak2012-05-151-4/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* sys-utils: verify writing to streams was successfulSami Kerola2012-04-041-1/+4
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>