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
This commit is contained in:
Mike Yuan 2023-07-10 21:04:49 +08:00
parent 2d5c53fc34
commit 0281927686
No known key found for this signature in database
GPG key ID: 417471C0A40F58B3

View file

@ -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=.",