summaryrefslogtreecommitdiff
path: root/src/sleep
Commit message (Collapse)AuthorAgeFilesLines
...
* systemd-sleep: refuse to calculate swapfile offset on BtrfsZach Smith2019-06-261-1/+9
| | | | | | | | | | If hibernation is requested but /sys/power/resume and /sys/power/resume_offset are not configured correctly, systemd-sleep attempts to calculate swapfile offset using fstat and fiemap. Btrfs returns virtual device number for stat and a virtual offset for fiemap which results in incorrect offset calculations. In the case where offset would be calculated and the user is using Btrfs, log a debug message and fail to write device and offset values.
* systemd-sleep: (bug) use resume_offset value if setZach Smith2019-06-261-2/+34
| | | | | | | Use hibernation configuration as defined in /sys/power/resume and /sys/power/resume_offset if present before inspecting /proc/swaps and attempting to calculate swapfile offset
* sleep: properly pass verb to sleep scriptLennart Poettering2019-06-171-1/+5
| | | | | | Another fall-out from our rewriting of argv[] now. Fixes: #12782
* systemd-sleep: refactor sleep config parsingZach Smith2019-05-301-20/+17
| | | | | | | | remove verb from parse refactor required fields checks refactor allow settings
* systemd-sleep: replace rtc wakealarm with CLOCK_BOOTTIME_ALARM s2hZach Smith2019-05-281-46/+26
| | | | | | | | | | refactor to use timerfd in place of rtc wakealarm confirm CLOCK_BOOTTIME_ALARM support in can_s2h Remove CLOCK_BOOTTIME_ALARM task from TODO remove unnecessary check on clock_supported return
* fix typo in partition device messageZach Smith2019-05-141-1/+1
|
* headers: remove unneeded includes from util.hZbigniew Jędrzejewski-Szmek2019-03-271-0/+5
| | | | | This means we need to include many more headers in various files that simply included util.h before, but it seems cleaner to do it this way.
* sleep: (void)ify some callLennart Poettering2019-03-261-2/+2
|
* core: Allow to configure execute_directories execution behaviorMatthias Klumpp2019-02-181-2/+2
| | | | | | | | | This adds a new bitfield to `execute_directories()` which allows to configure whether to ignore non-zero exit statuses of binaries run and whether to allow parallel execution of commands. In case errors are not ignored, the exit status of the failed script will now be returned for error reposrting purposes or other further future use.
* sleep: install default sleep.confYu Watanabe2019-01-031-0/+25
| | | | Closes #11310.
* coccinelle: make use of SYNTHETIC_ERRNOZbigniew Jędrzejewski-Szmek2018-11-221-21/+17
| | | | | | | | | | | Ideally, coccinelle would strip unnecessary braces too. But I do not see any option in coccinelle for this, so instead, I edited the patch text using search&replace to remove the braces. Unfortunately this is not fully automatic, in particular it didn't deal well with if-else-if-else blocks and ifdefs, so there is an increased likelikehood be some bugs in such spots. I also removed part of the patch that coccinelle generated for udev, where we returns -1 for failure. This should be fixed independently.
* Split out pretty-print.c and move pager.c and main-func.h to shared/Zbigniew Jędrzejewski-Szmek2018-11-201-1/+1
| | | | | This is high-level functionality, and fits better in shared/ (which is for our executables), than in basic/ (which is also for libraries).
* log: introduce new helper call log_setup_service()Lennart Poettering2018-11-201-3/+1
| | | | | Let's reduce the common boilerplate and have a single setup function used by all service code to setup logging.
* util-lib: move main() definition macros to its own header fileLennart Poettering2018-11-191-0/+1
| | | | | | | | | This way, we can extend the macro a bit with stuff pulled in from other headers without this affecting everything which pulls in macro.h, which is one of our most basic headers. This is just refactoring, no change in behaviour, in prepartion for later changes.
* sleep: define main through macroZbigniew Jędrzejewski-Szmek2018-11-171-9/+8
|
* tree-wide: set WRITE_STRING_FILE_DISABLE_BUFFER flag when we write files ↵Yu Watanabe2018-11-061-6/+8
| | | | under /proc or /sys
* sleep: when we can't hibernate on suspend-then-hibernate, fall back to ↵Lennart Poettering2018-10-241-1/+11
| | | | | | | | | suspend again Let's make this a bit safer, and try hard to return to sleep, if we can at all. Fixes: #10212
* sleep: rework what we do if a suspend fails.Lennart Poettering2018-10-241-6/+9
| | | | | | | | | | | | | | | | | First of all, let's fix logging: let's simply log the same message as we do on success, so that there's always the same pair of these messages around, regardless if the suspend was successful or not. To distuingish a successful suspend from a failed one, check the ERRNO= field of the structured message. In most ways a failed suspend cycle is not distuingishable from a successful one that took no time, hence let's treat it this way, and always pair the success message with a failure message. This also changes a more important concept: the post-suspend callouts are now called also called on failure, following the same logic: let's always run them in pairs: for every pre callout a post callout has to follow.
* sleep: no need to check for resume_offset twiceLennart Poettering2018-10-241-6/+5
| | | | | The W_OK check already checks for existance hence let's remove the F_OK check.
* sleep: let's turn off the RTC alarm time ASAPLennart Poettering2018-10-241-7/+7
| | | | | | | Let's be a tiny bit more careful here. Also, let's rearrange things to simplify them a bit, and to not use "r" outside of its immediate scope of validity.
* sleep: round up when calculating RTC sleep timeLennart Poettering2018-10-241-1/+1
| | | | | Paranoia: this way we know that when we wake up all timers are definitely equal or ahead of what we expect them to be.
* sleep: move log message generation for rtc_read_time() into the function itselfLennart Poettering2018-10-241-4/+8
| | | | | The log messages were petty borked anyway, and generated at two separate locations. Let's fix that.
* sleep: rework write_wakealarm() to take a numeric parameterLennart Poettering2018-10-241-13/+13
| | | | | | Also, let's rename it to rtc_write_wake_alarm(). Both changes together make sure rtc_write_wake_alarm() and rtc_read_time() are more alike in their naming and semantics.
* sleep: rename read_wakealarm() → rtc_read_time()Lennart Poettering2018-10-241-4/+4
| | | | | It doesn't read wakealarm, but the current time of the RTC. Hence, let's rename this to make it less misleading.
* sleep: log about the correct errorsLennart Poettering2018-10-241-2/+2
|
* sleep: don't make up errors, propagate the right onesLennart Poettering2018-10-241-3/+6
|
* sleep: let's use write_string_file() instead of write_string_stream() if we canLennart Poettering2018-10-241-7/+1
| | | | Let's shorten things.
* shared/sleep-config: add switches to kill specific sleep modesZbigniew Jędrzejewski-Szmek2018-10-081-6/+9
| | | | | | | | | | | | /etc/systemd/sleep.conf gains four new switches: AllowSuspend=, AllowHibernation=, AllowSuspendThenHibernate=, AllowHybridSleep=. Disabling specific modes was already possible by masking suspend.target, hibernate.target, suspend-then-hibernate.target, or hybrid-sleep.target. But this is not convenient for distributions, which want to set some defaults based on what they want to support. Having those available as configuration makes it easy to put a config file in /usr/lib/systemd/sleep.conf.d/ that overrides the defaults and gives instructions how to undo that override.
* exec-util: in execute_directories, support initial exec environmentDimitri John Ledkov2018-09-241-2/+2
|
* tree-wide: add clickable man page link to all --help textsLennart Poettering2018-08-201-11/+23
| | | | | | | | | | This is a bit like the info link in most of GNU's --help texts, but we don't do info but man pages, and we make them properly clickable on terminal supporting that, because awesome. I think it's generally advisable to link up our (brief) --help texts and our (more comprehensive) man pages a bit, so this should be an easy and straight-forward way to do it.
* sleep: tiny coding style updatesLennart Poettering2018-07-171-26/+28
| | | | No change in behaviour
* Drop my copyright headersZbigniew Jędrzejewski-Szmek2018-06-141-1/+0
| | | | | | | perl -i -0pe 's/\s*Copyright © .... Zbigniew Jędrzejewski.*?\n/\n/gms' man/*xml git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/(#\n)?# +Copyright © [0-9, -]+ Zbigniew Jędrzejewski.*?\n//gms' git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/\s*\/\*\*\*\s+Copyright © [0-9, -]+ Zbigniew Jędrzejewski[^\n]*?\s*\*\*\*\/\s*/\n\n/gms' git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/\s+Copyright © [0-9, -]+ Zbigniew Jędrzejewski[^\n]*//gms'
* tree-wide: beautify remaining copyright statementsLennart Poettering2018-06-141-3/+3
| | | | | | Let's unify an beautify our remaining copyright statements, with a unicode ©. This means our copyright statements are now always formatted the same way. Yay.
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-1/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* basic/log: add the log_struct terminator to macroZbigniew Jędrzejewski-Szmek2018-06-041-4/+2
| | | | | This way all callers do not need to specify it. Exhaustively tested by running test-log under valgrind ;)
* Merge pull request #8676 from keszybz/drop-license-boilerplateLennart Poettering2018-04-101-13/+0
|\ | | | | Drop license boilerplate
| * tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | | | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* | sleep: Move the error level debugging for write_mode and write_stateMario Limonciello2018-04-091-6/+3
| | | | | | | | | | | | This makes it more consistent with other code used in the file. Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
* | sleep: Add support for setting a disk offset when hibernatingMario Limonciello2018-04-091-3/+71
|/ | | | | | | | | | | The Linux kernel is adding support for configuring the offset into a disk. This allows swapfiles to be more usable as users will no longer need to set the offset on their kernel command line. Use this API in systemd when hibernating as well. Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
* Rename suspend-to-hibernate to suspend-then-hibernateMario Limonciello2018-03-281-3/+3
| | | | | Per some discussion with Gnome folks, they would prefer this name as it's more descriptive of what's happening.
* Introduce suspend-to-hibernate (#8274)Mario Limonciello2018-03-081-4/+90
| | | | | | | | | | | | | | Suspend to Hibernate is a new sleep method that invokes suspend for a predefined period of time before automatically waking up and hibernating the system. It's similar to HybridSleep however there isn't a performance impact on every suspend cycle. It's intended to use with systems that may have a higher power drain in their supported suspend states to prevent battery and data loss over an extended suspend cycle. Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* fileio: make write_string_stream() accept flags parameterLennart Poettering2017-09-221-1/+1
| | | | | | Let's make write_string_stream() and write_string_file() more alike, and pass the same flag set so that we can remove a number of boolean parameters.
* exec-util,conf-files: skip non-executable files in execute_directories()Lennart Poettering2017-09-131-1/+4
| | | | Fixes: #6787
* build-sys: drop automake supportZbigniew Jędrzejewski-Szmek2017-07-181-1/+0
| | | | | v2: - also mention m4
* Merge pull request #5131 from keszybz/environment-generatorsLennart Poettering2017-02-211-2/+3
|\ | | | | Environment generators
| * basic/exec-util: add support for synchronous (ordered) executionZbigniew Jędrzejewski-Szmek2017-02-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The output of processes can be gathered, and passed back to the callee. (This commit just implements the basic functionality and tests.) After the preparation in previous commits, the change in functionality is relatively simple. For coding convenience, alarm is prepared *before* any children are executed, and not before. This shouldn't matter usually, since just forking of the children should be pretty quick. One could also argue that this is more correct, because we will also catch the case when (for whatever reason), forking itself is slow. Three callback functions and three levels of serialization are used: - from individual generator processes to the generator forker - from the forker back to the main process - deserialization in the main process v2: - replace an structure with an indexed array of callbacks
| * basic/util: move execute_directory() to separate fileZbigniew Jędrzejewski-Szmek2017-02-111-0/+1
| | | | | | | | It's a fairly specialized function. Let's make new files for it and the tests.
* | tree-wide: add SD_ID128_MAKE_STR, remove LOG_MESSAGE_IDZbigniew Jędrzejewski-Szmek2017-02-151-2/+2
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Embedding sd_id128_t's in constant strings was rather cumbersome. We had SD_ID128_CONST_STR which returned a const char[], but it had two problems: - it wasn't possible to statically concatanate this array with a normal string - gcc wasn't really able to optimize this, and generated code to perform the "conversion" at runtime. Because of this, even our own code in coredumpctl wasn't using SD_ID128_CONST_STR. Add a new macro to generate a constant string: SD_ID128_MAKE_STR. It is not as elegant as SD_ID128_CONST_STR, because it requires a repetition of the numbers, but in practice it is more convenient to use, and allows gcc to generate smarter code: $ size .libs/systemd{,-logind,-journald}{.old,} text data bss dec hex filename 1265204 149564 4808 1419576 15a938 .libs/systemd.old 1260268 149564 4808 1414640 1595f0 .libs/systemd 246805 13852 209 260866 3fb02 .libs/systemd-logind.old 240973 13852 209 255034 3e43a .libs/systemd-logind 146839 4984 34 151857 25131 .libs/systemd-journald.old 146391 4984 34 151409 24f71 .libs/systemd-journald It is also much easier to check if a certain binary uses a certain MESSAGE_ID: $ strings .libs/systemd.old|grep MESSAGE_ID MESSAGE_ID=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x MESSAGE_ID=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x MESSAGE_ID=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x MESSAGE_ID=%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x $ strings .libs/systemd|grep MESSAGE_ID MESSAGE_ID=c7a787079b354eaaa9e77b371893cd27 MESSAGE_ID=b07a249cd024414a82dd00cd181378ff MESSAGE_ID=641257651c1b4ec9a8624d7a40a9e1e7 MESSAGE_ID=de5b426a63be47a7b6ac3eaac82e2f6f MESSAGE_ID=d34d037fff1847e6ae669a370e694725 MESSAGE_ID=7d4958e842da4a758f6c1cdc7b36dcc5 MESSAGE_ID=1dee0369c7fc4736b7099b38ecb46ee7 MESSAGE_ID=39f53479d3a045ac8e11786248231fbf MESSAGE_ID=be02cf6855d2428ba40df7e9d022f03d MESSAGE_ID=7b05ebc668384222baa8881179cfda54 MESSAGE_ID=9d1aaa27d60140bd96365438aad20286