From: Mike Yuan Date: Wed, 27 Dec 2023 14:19:07 +0000 (+0800) Subject: hibernate-util: make sure we use blockdev path for HibernationDevice.path X-Git-Tag: v256-rc1~1377^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=66b9956082f4e458b5fb2d3571088fb73872f6b2;p=thirdparty%2Fsystemd.git hibernate-util: make sure we use blockdev path for HibernationDevice.path Before this commit, this field could spuriously contain the path of the swapfile. --- diff --git a/src/shared/hibernate-util.c b/src/shared/hibernate-util.c index 48ed4141973..99b37483bdb 100644 --- a/src/shared/hibernate-util.c +++ b/src/shared/hibernate-util.c @@ -388,12 +388,24 @@ int find_suitable_hibernation_device_full(HibernationDevice *ret_device, uint64_ return log_debug_errno(SYNTHETIC_ERRNO(ENOSPC), "Cannot find swap entry corresponding to /sys/power/resume."); } - if (ret_device) + if (ret_device) { + char *path; + + if (entry->swapfile) { + r = device_path_make_canonical(S_IFBLK, entry->devno, &path); + if (r < 0) + return log_debug_errno(r, + "Failed to format canonical device path for devno '" DEVNUM_FORMAT_STR "': %m", + DEVNUM_FORMAT_VAL(entry->devno)); + } else + path = TAKE_PTR(entry->path); + *ret_device = (HibernationDevice) { .devno = entry->devno, .offset = entry->offset, - .path = TAKE_PTR(entry->path), + .path = path, }; + } if (ret_size) { *ret_size = entry->size;