]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
hibernate-util: report no available swap as no enough swap space
authorMike Yuan <me@yhndnzj.com>
Fri, 17 Nov 2023 14:17:06 +0000 (22:17 +0800)
committerMike Yuan <me@yhndnzj.com>
Sat, 18 Nov 2023 12:15:41 +0000 (20:15 +0800)
Otherwise, ENOENT or ENXIO may be directly returned as error through
bus.

Should help to generate clearer error message for #30083.

src/shared/hibernate-util.c

index 51f64aa2b190795375a23c06d4ab00f72bc8e0a2..d1f74923170442f89f41cbbc5fe6fd883ed53727 100644 (file)
@@ -349,7 +349,7 @@ int find_suitable_hibernation_device_full(HibernationDevice *ret_device, uint64_
         if (r < 0)
                 return r;
         if (entries.n_swaps == 0)
-                return log_debug_errno(SYNTHETIC_ERRNO(ENOENT), "No swap space available for hibernation.");
+                return log_debug_errno(SYNTHETIC_ERRNO(ENOSPC), "No swap space available for hibernation.");
 
         FOREACH_ARRAY(swap, entries.swaps, entries.n_swaps) {
                 r = swap_entry_get_resume_config(swap);
@@ -385,7 +385,7 @@ int find_suitable_hibernation_device_full(HibernationDevice *ret_device, uint64_
         if (!entry) {
                 /* No need to check n_swaps == 0, since it's rejected early */
                 assert(resume_config_devno > 0);
-                return log_debug_errno(SYNTHETIC_ERRNO(ENXIO), "Cannot find swap entry corresponding to /sys/power/resume.");
+                return log_debug_errno(SYNTHETIC_ERRNO(ENOSPC), "Cannot find swap entry corresponding to /sys/power/resume.");
         }
 
         if (ret_device)