]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
hibernate-util,logind: also differentiate the case of misconfigured resume
authorMike Yuan <me@yhndnzj.com>
Wed, 8 May 2024 04:52:35 +0000 (12:52 +0800)
committerMike Yuan <me@yhndnzj.com>
Wed, 8 May 2024 04:55:25 +0000 (12:55 +0800)
src/login/logind-dbus.c
src/shared/hibernate-util.c
src/shared/sleep-config.c
src/shared/sleep-config.h

index ef8cad0a316b3ede68de9589cdf99be059150876..53e966562e6c41115a6089d03bbc00e8b67e71fa 100644 (file)
@@ -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");
index ce49344debd550761f8f842722f41eb6cbd6d459..7c21157580f5e4bb3115935e834481fb0e7b366e 100644 (file)
@@ -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);
 
index 0a4303f3eb599e57d9aaecb8921c07d6c55b9c87..3d4d3317109d76d82005204f4651595d87597112 100644 (file)
@@ -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;
index be0287e2e494daff8a5067dac20cae62705cfec3..b59bce8fc4e052bbbb3823277b77184665249ee6 100644 (file)
@@ -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;