From: Mike Yuan Date: Wed, 8 May 2024 04:52:35 +0000 (+0800) Subject: hibernate-util,logind: also differentiate the case of misconfigured resume X-Git-Tag: v256-rc2~74^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3fce141c1bf9a949cdcd81fc77f4b3dc8aca98f0;p=thirdparty%2Fsystemd.git hibernate-util,logind: also differentiate the case of misconfigured resume --- diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index ef8cad0a316..53e966562e6 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -2160,6 +2160,10 @@ static int method_do_shutdown_or_sleep( return sd_bus_error_set(error, BUS_ERROR_SLEEP_VERB_NOT_SUPPORTED, "Specified resume device is missing or is not an active swap device"); + case SLEEP_RESUME_MISCONFIGURED: + return sd_bus_error_set(error, BUS_ERROR_SLEEP_VERB_NOT_SUPPORTED, + "Invalid resume config: resume= is not populated yet resume_offset= is"); + case SLEEP_NOT_ENOUGH_SWAP_SPACE: return sd_bus_error_set(error, BUS_ERROR_SLEEP_VERB_NOT_SUPPORTED, "Not enough suitable swap space for hibernation available on compatible block devices and file systems"); diff --git a/src/shared/hibernate-util.c b/src/shared/hibernate-util.c index ce49344debd..7c21157580f 100644 --- a/src/shared/hibernate-util.c +++ b/src/shared/hibernate-util.c @@ -159,7 +159,7 @@ static int read_resume_config(dev_t *ret_devno, uint64_t *ret_offset) { } if (devno == 0 && offset > 0 && offset != UINT64_MAX) - return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), + return log_debug_errno(SYNTHETIC_ERRNO(ENOMEDIUM), "Found populated /sys/power/resume_offset (%" PRIu64 ") but /sys/power/resume is not set, refusing.", offset); diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c index 0a4303f3eb5..3d4d3317109 100644 --- a/src/shared/sleep-config.c +++ b/src/shared/sleep-config.c @@ -378,6 +378,10 @@ static int sleep_supported_internal( *ret_support = SLEEP_RESUME_DEVICE_MISSING; return false; + case -ENOMEDIUM: + *ret_support = SLEEP_RESUME_MISCONFIGURED; + return false; + case -ENOSPC: *ret_support = SLEEP_NOT_ENOUGH_SWAP_SPACE; return false; diff --git a/src/shared/sleep-config.h b/src/shared/sleep-config.h index be0287e2e49..b59bce8fc4e 100644 --- a/src/shared/sleep-config.h +++ b/src/shared/sleep-config.h @@ -60,6 +60,7 @@ typedef enum SleepSupport { SLEEP_STATE_OR_MODE_NOT_SUPPORTED, /* SleepConfig.states/modes are not supported by kernel */ SLEEP_RESUME_NOT_SUPPORTED, SLEEP_RESUME_DEVICE_MISSING, /* resume= is specified, but the device cannot be found in /proc/swaps */ + SLEEP_RESUME_MISCONFIGURED, /* resume= is not set yet resume_offset= is configured */ SLEEP_NOT_ENOUGH_SWAP_SPACE, SLEEP_ALARM_NOT_SUPPORTED, /* CLOCK_BOOTTIME_ALARM is unsupported by kernel (only used by s2h) */ } SleepSupport;