Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 42714
b: refs/heads/master
c: 37b2ba1
h: refs/heads/master
v: v3
  • Loading branch information
Rafael J. Wysocki authored and Linus Torvalds committed Dec 7, 2006
1 parent d9d2ab6 commit 41f73bd
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ecbd0da1eced957e0cbb611b4a4cb5b0cf63ba31
refs/heads/master: 37b2ba12df88f0e29f2d52aaf1ab22789377d5b5
14 changes: 13 additions & 1 deletion trunk/kernel/power/power.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ extern int snapshot_write_next(struct snapshot_handle *handle, size_t count);
extern int snapshot_image_loaded(struct snapshot_handle *handle);
extern void snapshot_free_unused_memory(struct snapshot_handle *handle);

/*
* This structure is used to pass the values needed for the identification
* of the resume swap area from a user space to the kernel via the
* SNAPSHOT_SET_SWAP_AREA ioctl
*/
struct resume_swap_area {
loff_t offset;
u_int32_t dev;
} __attribute__((packed));

#define SNAPSHOT_IOC_MAGIC '3'
#define SNAPSHOT_FREEZE _IO(SNAPSHOT_IOC_MAGIC, 1)
#define SNAPSHOT_UNFREEZE _IO(SNAPSHOT_IOC_MAGIC, 2)
Expand All @@ -119,7 +129,9 @@ extern void snapshot_free_unused_memory(struct snapshot_handle *handle);
#define SNAPSHOT_SET_SWAP_FILE _IOW(SNAPSHOT_IOC_MAGIC, 10, unsigned int)
#define SNAPSHOT_S2RAM _IO(SNAPSHOT_IOC_MAGIC, 11)
#define SNAPSHOT_PMOPS _IOW(SNAPSHOT_IOC_MAGIC, 12, unsigned int)
#define SNAPSHOT_IOC_MAXNR 12
#define SNAPSHOT_SET_SWAP_AREA _IOW(SNAPSHOT_IOC_MAGIC, 13, \
struct resume_swap_area)
#define SNAPSHOT_IOC_MAXNR 13

#define PMOPS_PREPARE 1
#define PMOPS_ENTER 2
Expand Down
31 changes: 31 additions & 0 deletions trunk/kernel/power/user.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,37 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
}
break;

case SNAPSHOT_SET_SWAP_AREA:
if (data->bitmap) {
error = -EPERM;
} else {
struct resume_swap_area swap_area;
dev_t swdev;

error = copy_from_user(&swap_area, (void __user *)arg,
sizeof(struct resume_swap_area));
if (error) {
error = -EFAULT;
break;
}

/*
* User space encodes device types as two-byte values,
* so we need to recode them
*/
swdev = old_decode_dev(swap_area.dev);
if (swdev) {
offset = swap_area.offset;
data->swap = swap_type_of(swdev, offset);
if (data->swap < 0)
error = -ENODEV;
} else {
data->swap = -1;
error = -EINVAL;
}
}
break;

default:
error = -ENOTTY;

Expand Down

0 comments on commit 41f73bd

Please sign in to comment.