diff options
author | Mario Limonciello <mario.limonciello@dell.com> | 2018-03-28 12:01:09 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2018-03-30 12:01:20 +0200 |
commit | 355064675f1c997cea017ea64c8f2c216e5425d9 (patch) | |
tree | 71dcf9924f7878f793cb72f21f69fad606523b1f /kernel/power | |
parent | dbdd0f58fd2cdde5cf945c9da67a2d52d32ba550 (diff) | |
download | linux-355064675f1c997cea017ea64c8f2c216e5425d9.tar.bz2 |
PM / hibernate: Make passing hibernate offsets more friendly
Currently the only way to specify a hibernate offset for a
swap file is on the kernel command line.
Add a new /sys/power/resume_offset that lets userspace
specify the offset and disk to use when initiating a hibernate
cycle.
Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'kernel/power')
-rw-r--r-- | kernel/power/hibernate.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index a5c36e9c56a6..d58fad3db22d 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -1061,6 +1061,29 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr, power_attr(resume); +static ssize_t resume_offset_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + return sprintf(buf, "%llu\n", (unsigned long long)swsusp_resume_block); +} + +static ssize_t resume_offset_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, + size_t n) +{ + unsigned long long offset; + int rc; + + rc = kstrtoull(buf, 0, &offset); + if (rc) + return rc; + swsusp_resume_block = offset; + + return n; +} + +power_attr(resume_offset); + static ssize_t image_size_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { @@ -1106,6 +1129,7 @@ power_attr(reserved_size); static struct attribute * g[] = { &disk_attr.attr, + &resume_offset_attr.attr, &resume_attr.attr, &image_size_attr.attr, &reserved_size_attr.attr, |