diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2006-03-23 06:00:03 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-23 10:38:07 -0500 |
commit | 6e1819d615f24ce0726a7d0bd3dd0152d7b21654 (patch) | |
tree | abc68747446e8241a1a7103882b9f6b6e24fa274 /kernel/power/snapshot.c | |
parent | 543cc27d09643640cbc34189c03a40beb8227aef (diff) |
[PATCH] swsusp: userland interface
This patch introduces a user space interface for swsusp.
The interface is based on a special character device, called the snapshot
device, that allows user space processes to perform suspend and resume-related
operations with the help of some ioctls and the read()/write() functions.
Additionally it allows these processes to allocate free swap pages from a
selected swap partition, called the resume partition, so that they know which
sectors of the resume partition are available to them.
The interface uses the same low-level system memory snapshot-handling
functions that are used by the built-it swap-writing/reading code of swsusp.
The interface documentation is included in the patch.
The patch assumes that the major and minor numbers of the snapshot device will
be 10 (ie. misc device) and 231, the registration of which has already been
requested.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel/power/snapshot.c')
-rw-r--r-- | kernel/power/snapshot.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c index cc349437fb72..0036955357e0 100644 --- a/kernel/power/snapshot.c +++ b/kernel/power/snapshot.c | |||
@@ -37,6 +37,7 @@ | |||
37 | struct pbe *pagedir_nosave; | 37 | struct pbe *pagedir_nosave; |
38 | static unsigned int nr_copy_pages; | 38 | static unsigned int nr_copy_pages; |
39 | static unsigned int nr_meta_pages; | 39 | static unsigned int nr_meta_pages; |
40 | static unsigned long *buffer; | ||
40 | 41 | ||
41 | #ifdef CONFIG_HIGHMEM | 42 | #ifdef CONFIG_HIGHMEM |
42 | unsigned int count_highmem_pages(void) | 43 | unsigned int count_highmem_pages(void) |
@@ -389,7 +390,7 @@ struct pbe *alloc_pagedir(unsigned int nr_pages, gfp_t gfp_mask, int safe_needed | |||
389 | free_pagedir(pblist); | 390 | free_pagedir(pblist); |
390 | pblist = NULL; | 391 | pblist = NULL; |
391 | } else | 392 | } else |
392 | create_pbe_list(pblist, nr_pages); | 393 | create_pbe_list(pblist, nr_pages); |
393 | return pblist; | 394 | return pblist; |
394 | } | 395 | } |
395 | 396 | ||
@@ -418,6 +419,7 @@ void swsusp_free(void) | |||
418 | nr_copy_pages = 0; | 419 | nr_copy_pages = 0; |
419 | nr_meta_pages = 0; | 420 | nr_meta_pages = 0; |
420 | pagedir_nosave = NULL; | 421 | pagedir_nosave = NULL; |
422 | buffer = NULL; | ||
421 | } | 423 | } |
422 | 424 | ||
423 | 425 | ||
@@ -523,6 +525,8 @@ static void init_header(struct swsusp_info *info) | |||
523 | info->cpus = num_online_cpus(); | 525 | info->cpus = num_online_cpus(); |
524 | info->image_pages = nr_copy_pages; | 526 | info->image_pages = nr_copy_pages; |
525 | info->pages = nr_copy_pages + nr_meta_pages + 1; | 527 | info->pages = nr_copy_pages + nr_meta_pages + 1; |
528 | info->size = info->pages; | ||
529 | info->size <<= PAGE_SHIFT; | ||
526 | } | 530 | } |
527 | 531 | ||
528 | /** | 532 | /** |
@@ -568,8 +572,6 @@ static inline struct pbe *pack_orig_addresses(unsigned long *buf, struct pbe *pb | |||
568 | 572 | ||
569 | int snapshot_read_next(struct snapshot_handle *handle, size_t count) | 573 | int snapshot_read_next(struct snapshot_handle *handle, size_t count) |
570 | { | 574 | { |
571 | static unsigned long *buffer; | ||
572 | |||
573 | if (handle->page > nr_meta_pages + nr_copy_pages) | 575 | if (handle->page > nr_meta_pages + nr_copy_pages) |
574 | return 0; | 576 | return 0; |
575 | if (!buffer) { | 577 | if (!buffer) { |
@@ -774,7 +776,6 @@ static int create_image(struct snapshot_handle *handle) | |||
774 | 776 | ||
775 | int snapshot_write_next(struct snapshot_handle *handle, size_t count) | 777 | int snapshot_write_next(struct snapshot_handle *handle, size_t count) |
776 | { | 778 | { |
777 | static unsigned long *buffer; | ||
778 | int error = 0; | 779 | int error = 0; |
779 | 780 | ||
780 | if (handle->prev && handle->page > nr_meta_pages + nr_copy_pages) | 781 | if (handle->prev && handle->page > nr_meta_pages + nr_copy_pages) |