Skip to content

Commit

Permalink
hibernate-util: report no available swap as no enough swap space
Browse files Browse the repository at this point in the history
Otherwise, ENOENT or ENXIO may be directly returned as error through
bus.

Should help to generate clearer error message for systemd#30083.
  • Loading branch information
YHNdnzj authored and ssahani committed Nov 23, 2023
1 parent 9537718 commit 0b9b270
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/shared/hibernate-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0b9b270

Please sign in to comment.