diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c index ca3befb30..125e3a4ac 100644 --- a/src/sleep/sleep.c +++ b/src/sleep/sleep.c @@ -44,10 +44,16 @@ static int write_hibernate_location_info(void) { if (r < 0) return log_debug_errno(r, "Unable to find hibernation location: %m"); - /* if it's a swap partition, we just write the disk to /sys/power/resume */ - if (streq(type, "partition")) - return write_string_file("/sys/power/resume", device, 0); - else if (!streq(type, "file")) + /* if it's a swap partition, we just write the disk to /sys/power/resume, convert it to major:minor id */ + if (streq(type, "partition")) { + if (stat( device, &stb) == -1) { + return log_debug_errno(EINVAL, "Error while trying to get stats for %s", + device); + } + char buffer [DECIMAL_STR_MAX(uint)*2+1]; + sprintf(buffer, "%u:%u",major(stb.st_rdev) , minor(stb.st_rdev) ); + return write_string_file("/sys/power/resume", buffer, 0); + }else if (!streq(type, "file")) return log_debug_errno(EINVAL, "Invalid hibernate type %s: %m", type);