]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
0ef6f454 LP |
2 | #pragma once |
3 | ||
17c40b3a | 4 | #include <linux/fiemap.h> |
c58493c0 ML |
5 | #include "time-util.h" |
6 | ||
28ca9c24 ZS |
7 | typedef struct SleepConfig { |
8 | bool allow_suspend; /* AllowSuspend */ | |
9 | bool allow_hibernate; /* AllowHibernation */ | |
10 | bool allow_s2h; /* AllowSuspendThenHibernate */ | |
11 | bool allow_hybrid_sleep; /* AllowHybridSleep */ | |
12 | ||
13 | char **suspend_modes; /* SuspendMode */ | |
14 | char **suspend_states; /* SuspendState */ | |
15 | char **hibernate_modes; /* HibernateMode */ | |
16 | char **hibernate_states; /* HibernateState */ | |
17 | char **hybrid_modes; /* HybridSleepMode */ | |
18 | char **hybrid_states; /* HybridSleepState */ | |
19 | ||
20 | usec_t hibernate_delay_sec; /* HibernateDelaySec */ | |
21 | } SleepConfig; | |
22 | ||
1326de01 | 23 | SleepConfig* free_sleep_config(SleepConfig *sc); |
28ca9c24 ZS |
24 | DEFINE_TRIVIAL_CLEANUP_FUNC(SleepConfig*, free_sleep_config); |
25 | ||
7bdf56a2 ZS |
26 | /* entry in /proc/swaps */ |
27 | typedef struct SwapEntry { | |
28 | char *device; | |
29 | char *type; | |
30 | uint64_t size; | |
31 | uint64_t used; | |
32 | int priority; | |
33 | } SwapEntry; | |
34 | ||
35 | SwapEntry* swap_entry_free(SwapEntry *se); | |
36 | DEFINE_TRIVIAL_CLEANUP_FUNC(SwapEntry*, swap_entry_free); | |
37 | ||
38 | /* | |
39 | * represents values for /sys/power/resume & /sys/power/resume_offset | |
40 | * and the matching /proc/swap entry. | |
41 | */ | |
42 | typedef struct HibernateLocation { | |
52133271 ZS |
43 | dev_t devno; |
44 | uint64_t offset; | |
7bdf56a2 ZS |
45 | SwapEntry *swap; |
46 | } HibernateLocation; | |
47 | ||
48 | HibernateLocation* hibernate_location_free(HibernateLocation *hl); | |
49 | DEFINE_TRIVIAL_CLEANUP_FUNC(HibernateLocation*, hibernate_location_free); | |
50 | ||
28ca9c24 ZS |
51 | int sleep_settings(const char *verb, const SleepConfig *sleep_config, bool *ret_allow, char ***ret_modes, char ***ret_states); |
52 | ||
17c40b3a | 53 | int read_fiemap(int fd, struct fiemap **ret); |
28ca9c24 | 54 | int parse_sleep_config(SleepConfig **sleep_config); |
7bdf56a2 | 55 | int find_hibernate_location(HibernateLocation **ret_hibernate_location); |
19adb8a3 ZJS |
56 | |
57 | int can_sleep(const char *verb); | |
58 | int can_sleep_disk(char **types); | |
59 | int can_sleep_state(char **types); |