From 028192768672fed98df55b9a53b521f9badcfb51 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Mon, 10 Jul 2023 21:04:49 +0800 Subject: [PATCH] hibernate-resume: use devnode_same to compare device nodes Addresses https://github.com/systemd/systemd/pull/28321#discussion_r1257866179 When devnode_same() fails we only debug log about it, because the device nodes might not have appeared by the time the generator is run. Fixes #28340 --- src/hibernate-resume/hibernate-resume-generator.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/hibernate-resume/hibernate-resume-generator.c b/src/hibernate-resume/hibernate-resume-generator.c index b6d3d257ac6..23c1a0a3c8a 100644 --- a/src/hibernate-resume/hibernate-resume-generator.c +++ b/src/hibernate-resume/hibernate-resume-generator.c @@ -8,6 +8,7 @@ #include "sd-id128.h" #include "alloc-util.h" +#include "device-nodes.h" #include "dropin.h" #include "efivars.h" #include "fd-util.h" @@ -170,9 +171,16 @@ static int parse_efi_hibernate_location(void) { arg_resume_device = TAKE_PTR(device); arg_resume_offset = location.offset; } else { - if (!path_equal_or_inode_same(arg_resume_device, device, 0)) - log_warning("resume=%s doesn't match with HibernateLocation device '%s', proceeding anyway with resume=.", - arg_resume_device, device); + if (!path_equal(arg_resume_device, device)) { + r = devnode_same(arg_resume_device, device); + if (r < 0) + log_debug_errno(r, + "Failed to check if resume=%s is the same device as HibernateLocation device '%s', ignoring: %m", + arg_resume_device, device); + if (r == 0) + log_warning("resume=%s doesn't match with HibernateLocation device '%s', proceeding anyway with resume=.", + arg_resume_device, device); + } if (arg_resume_offset != location.offset) log_warning("resume_offset=%" PRIu64 " doesn't match with HibernateLocation offset %" PRIu64 ", proceeding anyway with resume_offset=.", -- 2.47.3