2020-11-09 05:23:58 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
2016-02-16 20:05:15 +01:00
|
|
|
#pragma once
|
|
|
|
|
2018-03-08 09:41:50 +01:00
|
|
|
#include <linux/fiemap.h>
|
2018-03-08 14:17:33 +01:00
|
|
|
#include "time-util.h"
|
|
|
|
|
2019-05-20 07:43:29 +02:00
|
|
|
typedef struct SleepConfig {
|
|
|
|
bool allow_suspend; /* AllowSuspend */
|
|
|
|
bool allow_hibernate; /* AllowHibernation */
|
|
|
|
bool allow_s2h; /* AllowSuspendThenHibernate */
|
|
|
|
bool allow_hybrid_sleep; /* AllowHybridSleep */
|
|
|
|
|
|
|
|
char **suspend_modes; /* SuspendMode */
|
|
|
|
char **suspend_states; /* SuspendState */
|
|
|
|
char **hibernate_modes; /* HibernateMode */
|
|
|
|
char **hibernate_states; /* HibernateState */
|
|
|
|
char **hybrid_modes; /* HybridSleepMode */
|
|
|
|
char **hybrid_states; /* HybridSleepState */
|
|
|
|
|
|
|
|
usec_t hibernate_delay_sec; /* HibernateDelaySec */
|
|
|
|
} SleepConfig;
|
|
|
|
|
2020-06-10 16:53:24 +02:00
|
|
|
SleepConfig* free_sleep_config(SleepConfig *sc);
|
2019-05-20 07:43:29 +02:00
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC(SleepConfig*, free_sleep_config);
|
|
|
|
|
2019-09-27 06:02:28 +02:00
|
|
|
/* entry in /proc/swaps */
|
|
|
|
typedef struct SwapEntry {
|
|
|
|
char *device;
|
|
|
|
char *type;
|
|
|
|
uint64_t size;
|
|
|
|
uint64_t used;
|
|
|
|
int priority;
|
|
|
|
} SwapEntry;
|
|
|
|
|
|
|
|
SwapEntry* swap_entry_free(SwapEntry *se);
|
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC(SwapEntry*, swap_entry_free);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* represents values for /sys/power/resume & /sys/power/resume_offset
|
|
|
|
* and the matching /proc/swap entry.
|
|
|
|
*/
|
|
|
|
typedef struct HibernateLocation {
|
2019-12-07 01:37:22 +01:00
|
|
|
dev_t devno;
|
|
|
|
uint64_t offset;
|
2019-09-27 06:02:28 +02:00
|
|
|
SwapEntry *swap;
|
|
|
|
} HibernateLocation;
|
|
|
|
|
|
|
|
HibernateLocation* hibernate_location_free(HibernateLocation *hl);
|
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC(HibernateLocation*, hibernate_location_free);
|
|
|
|
|
2019-05-20 07:43:29 +02:00
|
|
|
int sleep_settings(const char *verb, const SleepConfig *sleep_config, bool *ret_allow, char ***ret_modes, char ***ret_states);
|
|
|
|
|
2018-03-08 09:41:50 +01:00
|
|
|
int read_fiemap(int fd, struct fiemap **ret);
|
2019-05-20 07:43:29 +02:00
|
|
|
int parse_sleep_config(SleepConfig **sleep_config);
|
2019-09-27 06:02:28 +02:00
|
|
|
int find_hibernate_location(HibernateLocation **ret_hibernate_location);
|
2013-05-04 18:31:28 +02:00
|
|
|
|
|
|
|
int can_sleep(const char *verb);
|
|
|
|
int can_sleep_disk(char **types);
|
|
|
|
int can_sleep_state(char **types);
|