Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 53773
b: refs/heads/master
c: 1b29c16
h: refs/heads/master
i:
  53771: 079fe9b
v: v3
  • Loading branch information
Vivek Goyal authored and Andi Kleen committed May 2, 2007
1 parent 4f4912d commit c5d8764
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 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: 49c3df6aaa6a51071fc135273d1a2515d019099f
refs/heads/master: 1b29c1643c0d82512477ccd97dc290198fe23e22
42 changes: 27 additions & 15 deletions trunk/kernel/power/swap.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ extern char resume_file[];

#define SWSUSP_SIG "S1SUSPEND"

static struct swsusp_header {
struct swsusp_header {
char reserved[PAGE_SIZE - 20 - sizeof(sector_t)];
sector_t image;
char orig_sig[10];
char sig[10];
} __attribute__((packed, aligned(PAGE_SIZE))) swsusp_header;
} __attribute__((packed));

static struct swsusp_header *swsusp_header;

/*
* General things
Expand Down Expand Up @@ -141,14 +143,14 @@ static int mark_swapfiles(sector_t start)
{
int error;

bio_read_page(swsusp_resume_block, &swsusp_header, NULL);
if (!memcmp("SWAP-SPACE",swsusp_header.sig, 10) ||
!memcmp("SWAPSPACE2",swsusp_header.sig, 10)) {
memcpy(swsusp_header.orig_sig,swsusp_header.sig, 10);
memcpy(swsusp_header.sig,SWSUSP_SIG, 10);
swsusp_header.image = start;
bio_read_page(swsusp_resume_block, swsusp_header, NULL);
if (!memcmp("SWAP-SPACE",swsusp_header->sig, 10) ||
!memcmp("SWAPSPACE2",swsusp_header->sig, 10)) {
memcpy(swsusp_header->orig_sig,swsusp_header->sig, 10);
memcpy(swsusp_header->sig,SWSUSP_SIG, 10);
swsusp_header->image = start;
error = bio_write_page(swsusp_resume_block,
&swsusp_header, NULL);
swsusp_header, NULL);
} else {
printk(KERN_ERR "swsusp: Swap header not found!\n");
error = -ENODEV;
Expand Down Expand Up @@ -564,7 +566,7 @@ int swsusp_read(void)
if (error < PAGE_SIZE)
return error < 0 ? error : -EFAULT;
header = (struct swsusp_info *)data_of(snapshot);
error = get_swap_reader(&handle, swsusp_header.image);
error = get_swap_reader(&handle, swsusp_header->image);
if (!error)
error = swap_read_page(&handle, header, NULL);
if (!error)
Expand All @@ -591,17 +593,17 @@ int swsusp_check(void)
resume_bdev = open_by_devnum(swsusp_resume_device, FMODE_READ);
if (!IS_ERR(resume_bdev)) {
set_blocksize(resume_bdev, PAGE_SIZE);
memset(&swsusp_header, 0, sizeof(swsusp_header));
memset(swsusp_header, 0, sizeof(PAGE_SIZE));
error = bio_read_page(swsusp_resume_block,
&swsusp_header, NULL);
swsusp_header, NULL);
if (error)
return error;

if (!memcmp(SWSUSP_SIG, swsusp_header.sig, 10)) {
memcpy(swsusp_header.sig, swsusp_header.orig_sig, 10);
if (!memcmp(SWSUSP_SIG, swsusp_header->sig, 10)) {
memcpy(swsusp_header->sig, swsusp_header->orig_sig, 10);
/* Reset swap signature now */
error = bio_write_page(swsusp_resume_block,
&swsusp_header, NULL);
swsusp_header, NULL);
} else {
return -EINVAL;
}
Expand Down Expand Up @@ -632,3 +634,13 @@ void swsusp_close(void)

blkdev_put(resume_bdev);
}

static int swsusp_header_init(void)
{
swsusp_header = (struct swsusp_header*) __get_free_page(GFP_KERNEL);
if (!swsusp_header)
panic("Could not allocate memory for swsusp_header\n");
return 0;
}

core_initcall(swsusp_header_init);

0 comments on commit c5d8764

Please sign in to comment.