Lines 44-53
static int write_hibernate_location_info(void) {
Link Here
|
44 |
if (r < 0) |
44 |
if (r < 0) |
45 |
return log_debug_errno(r, "Unable to find hibernation location: %m"); |
45 |
return log_debug_errno(r, "Unable to find hibernation location: %m"); |
46 |
|
46 |
|
47 |
/* if it's a swap partition, we just write the disk to /sys/power/resume */ |
47 |
/* if it's a swap partition, we just write the disk to /sys/power/resume, convert it to major:minor id */ |
48 |
if (streq(type, "partition")) |
48 |
if (streq(type, "partition")) { |
49 |
return write_string_file("/sys/power/resume", device, 0); |
49 |
if (stat( device, &stb) == -1) { |
50 |
else if (!streq(type, "file")) |
50 |
return log_debug_errno(EINVAL, "Error while trying to get stats for %s", |
|
|
51 |
device); |
52 |
} |
53 |
char buffer [DECIMAL_STR_MAX(uint)*2+1]; |
54 |
sprintf(buffer, "%u:%u",major(stb.st_rdev) , minor(stb.st_rdev) ); |
55 |
return write_string_file("/sys/power/resume", buffer, 0); |
56 |
}else if (!streq(type, "file")) |
51 |
return log_debug_errno(EINVAL, "Invalid hibernate type %s: %m", |
57 |
return log_debug_errno(EINVAL, "Invalid hibernate type %s: %m", |
52 |
type); |
58 |
type); |
53 |
|
59 |
|