]>
Commit | Line | Data |
---|---|---|
a032b68d | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
aa27b158 MP |
2 | #pragma once |
3 | ||
b012e921 MB |
4 | #include <linux/fiemap.h> |
5 | #include "time-util.h" | |
663996b3 | 6 | |
8b3d4ff0 MB |
7 | typedef enum SleepOperation { |
8 | SLEEP_SUSPEND, | |
9 | SLEEP_HIBERNATE, | |
10 | SLEEP_HYBRID_SLEEP, | |
11 | SLEEP_SUSPEND_THEN_HIBERNATE, | |
12 | _SLEEP_OPERATION_MAX, | |
13 | _SLEEP_OPERATION_INVALID = -EINVAL, | |
14 | } SleepOperation; | |
15 | ||
f2dec872 | 16 | typedef struct SleepConfig { |
8b3d4ff0 MB |
17 | bool allow[_SLEEP_OPERATION_MAX]; |
18 | char **modes[_SLEEP_OPERATION_MAX]; | |
19 | char **states[_SLEEP_OPERATION_MAX]; | |
20 | usec_t hibernate_delay_sec; | |
f2dec872 BR |
21 | } SleepConfig; |
22 | ||
478ed938 | 23 | SleepConfig* free_sleep_config(SleepConfig *sc); |
f2dec872 BR |
24 | DEFINE_TRIVIAL_CLEANUP_FUNC(SleepConfig*, free_sleep_config); |
25 | ||
e1f67bc7 MB |
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 { | |
46cdbd49 BR |
43 | dev_t devno; |
44 | uint64_t offset; | |
e1f67bc7 MB |
45 | SwapEntry *swap; |
46 | } HibernateLocation; | |
47 | ||
48 | HibernateLocation* hibernate_location_free(HibernateLocation *hl); | |
49 | DEFINE_TRIVIAL_CLEANUP_FUNC(HibernateLocation*, hibernate_location_free); | |
50 | ||
b012e921 | 51 | int read_fiemap(int fd, struct fiemap **ret); |
f2dec872 | 52 | int parse_sleep_config(SleepConfig **sleep_config); |
e1f67bc7 | 53 | int find_hibernate_location(HibernateLocation **ret_hibernate_location); |
663996b3 | 54 | |
8b3d4ff0 | 55 | int can_sleep(SleepOperation operation); |
663996b3 MS |
56 | int can_sleep_disk(char **types); |
57 | int can_sleep_state(char **types); | |
8b3d4ff0 MB |
58 | |
59 | const char* sleep_operation_to_string(SleepOperation s) _const_; | |
60 | SleepOperation sleep_operation_from_string(const char *s) _pure_; |