Messages in this thread Patch in this message | | | From | Nigel Cunningham <> | Subject | [Suspend2][ 22/28] [Suspend2] Does a swapwriter image exist? | Date | Tue, 27 Jun 2006 08:42:21 +1000 |
| |
Return whether there is an image at the location currently pointed to by resume2=.
Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
kernel/power/suspend_swap.c | 54 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/kernel/power/suspend_swap.c b/kernel/power/suspend_swap.c index ba6ed75..7342cb2 100644 --- a/kernel/power/suspend_swap.c +++ b/kernel/power/suspend_swap.c @@ -872,3 +872,57 @@ static unsigned long swapwriter_storage_ return result; } +/* + * Image_exists + */ + +static int swapwriter_image_exists(void) +{ + int signature_found; + union p_diskpage diskpage; + + if (!resume_dev_t) { + printk("Not even trying to read header " + "because resume_dev_t is not set.\n"); + return 0; + } + + if (!resume_block_device && + IS_ERR(resume_block_device = open_bdev(MAX_SWAPFILES, resume_dev_t))) + return 0; + + diskpage.address = get_zeroed_page(GFP_ATOMIC); + + suspend_bio_ops.bdev_page_io(READ, resume_block_device, + resume_firstblock, + virt_to_page(diskpage.ptr)); + suspend_bio_ops.finish_all_io(); + + signature_found = parse_signature(diskpage.pointer->swh.magic.magic, 0); + free_page(diskpage.address); + + if (signature_found < 2) { + return 0; /* Normal swap space */ + } else if (signature_found == -1) { + printk(KERN_ERR name_suspend + "Unable to find a signature. Could you have moved " + "a swap file?\n"); + return 0; + } else if (signature_found < 6) { + if ((!(test_suspend_state(SUSPEND_NORESUME_SPECIFIED))) + && suspend_early_boot_message(1, + SUSPEND_CONTINUE_REQ, + "Detected the signature of an alternate " + "implementation.\n")) + set_suspend_state(SUSPEND_NORESUME_SPECIFIED); + return 0; + } else if ((signature_found >> 1) != SIGNATURE_VER) { + if ((!(test_suspend_state(SUSPEND_NORESUME_SPECIFIED))) && + suspend_early_boot_message(1, SUSPEND_CONTINUE_REQ, + "Found a different style suspend image signature.")) + set_suspend_state(SUSPEND_NORESUME_SPECIFIED); + } + + return 1; +} + -- Nigel Cunningham nigel at suspend2 dot net - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |