Lines 35-40
static int write_hibernate_location_info(void) {
Link Here
|
35 |
_cleanup_free_ struct fiemap *fiemap = NULL; |
35 |
_cleanup_free_ struct fiemap *fiemap = NULL; |
36 |
char offset_str[DECIMAL_STR_MAX(uint64_t)]; |
36 |
char offset_str[DECIMAL_STR_MAX(uint64_t)]; |
37 |
char device_str[DECIMAL_STR_MAX(uint64_t)]; |
37 |
char device_str[DECIMAL_STR_MAX(uint64_t)]; |
|
|
38 |
char device_num_str [DECIMAL_STR_MAX(uint)*2+1]; |
38 |
_cleanup_close_ int fd = -1; |
39 |
_cleanup_close_ int fd = -1; |
39 |
struct stat stb; |
40 |
struct stat stb; |
40 |
uint64_t offset; |
41 |
uint64_t offset; |
Lines 44-53
static int write_hibernate_location_info(void) {
Link Here
|
44 |
if (r < 0) |
45 |
if (r < 0) |
45 |
return log_debug_errno(r, "Unable to find hibernation location: %m"); |
46 |
return log_debug_errno(r, "Unable to find hibernation location: %m"); |
46 |
|
47 |
|
47 |
/* if it's a swap partition, we just write the disk to /sys/power/resume */ |
48 |
/* if it's a swap partition, we just write the corresponding major:minor number to /sys/power/resume */ |
48 |
if (streq(type, "partition")) |
49 |
if (streq(type, "partition")) { |
49 |
return write_string_file("/sys/power/resume", device, 0); |
50 |
r = stat( device, &stb); |
50 |
else if (!streq(type, "file")) |
51 |
if (r == -1) { |
|
|
52 |
return log_debug_errno(errno, "Error while trying to get stats for %s: %m", device); |
53 |
} |
54 |
sprintf(device_num_str, "%u:%u",major(stb.st_rdev) , minor(stb.st_rdev) ); |
55 |
return write_string_file("/sys/power/resume", device_num_str, 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 |
|