summaryrefslogtreecommitdiffstats
path: root/kernel/power/user.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2007-10-26 00:59:31 +0200
committerLen Brown <len.brown@intel.com>2008-02-01 18:30:52 -0500
commitaf508b34d27e3341287d89e0eae6752fdb1b873f (patch)
treeb5d2a337d78dc25aadb02d481443d484e0dd368c /kernel/power/user.c
parentaa6299926950c8dfe2fea638276cad6def092bc9 (diff)
downloadlinux-af508b34d27e3341287d89e0eae6752fdb1b873f.tar.gz
linux-af508b34d27e3341287d89e0eae6752fdb1b873f.tar.bz2
linux-af508b34d27e3341287d89e0eae6752fdb1b873f.zip
Hibernation: Introduce SNAPSHOT_GET_IMAGE_SIZE ioctl
Add a new ioctl, SNAPSHOT_GET_IMAGE_SIZE, returning the size of the (just created) hibernation image, to the hibernation userland interface. This ioctl is necessary so that the userland utilities using the interface need not access the hibernation image header, owned by the kernel, in order to obtain the size of the image. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'kernel/power/user.c')
-rw-r--r--kernel/power/user.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/kernel/power/user.c b/kernel/power/user.c
index 5bd321bcbb75..88aac26e598a 100644
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -133,7 +133,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
{
int error = 0;
struct snapshot_data *data;
- loff_t avail;
+ loff_t size;
sector_t offset;
if (_IOC_TYPE(cmd) != SNAPSHOT_IOC_MAGIC)
@@ -210,10 +210,20 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
image_size = arg;
break;
+ case SNAPSHOT_GET_IMAGE_SIZE:
+ if (!data->ready) {
+ error = -ENODATA;
+ break;
+ }
+ size = snapshot_get_image_size();
+ size <<= PAGE_SHIFT;
+ error = put_user(size, (loff_t __user *)arg);
+ break;
+
case SNAPSHOT_AVAIL_SWAP:
- avail = count_swap_pages(data->swap, 1);
- avail <<= PAGE_SHIFT;
- error = put_user(avail, (loff_t __user *)arg);
+ size = count_swap_pages(data->swap, 1);
+ size <<= PAGE_SHIFT;
+ error = put_user(size, (loff_t __user *)arg);
break;
case SNAPSHOT_GET_SWAP_PAGE: