Return whether there is an image at the location currently pointed to by
resume2=.
Signed-off-by: Nigel Cunningham <[email protected]>
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]