[Suspend2][ 09/28] [Suspend2] Prepare swapwriter signature.

From: Nigel Cunningham
Date: Mon Jun 26 2006 - 18:49:55 EST


Set the swapwriter signature to reflect that we have an image and point to
the device and sector where the header proper begins.

Signed-off-by: Nigel Cunningham <nigel@xxxxxxxxxxxx>

kernel/power/suspend_swap.c | 36 ++++++++++++++++++++++++++++++++++++
1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/kernel/power/suspend_swap.c b/kernel/power/suspend_swap.c
index 08c4f86..7f16bea 100644
--- a/kernel/power/suspend_swap.c
+++ b/kernel/power/suspend_swap.c
@@ -293,3 +293,39 @@ static int parse_signature(char *header,
return type;
}

+/*
+ * prepare_signature
+ */
+
+static int prepare_signature(dev_t bdev, unsigned long block,
+ char *current_header)
+{
+ int current_type = parse_signature(current_header, 0);
+ dev_t *header_ptr = (dev_t *) (&current_header[1]);
+ unsigned long *headerblock_ptr =
+ (unsigned long *) (&current_header[6]);
+
+ if ((current_type > 1) && (current_type < 6))
+ return 1;
+
+ /* At the moment, I don't have a way to handle the block being
+ * > 32 bits. Not enough room in the signature and no way to
+ * safely put the data elsewhere. */
+
+ if (BITS_PER_LONG == 64 && ffs(block) > 31) {
+ suspend_prepare_status(DONT_CLEAR_BAR,
+ "Header sector requires 33+ bits. "
+ "Would not be able to resume.");
+ return 1;
+ }
+
+ if (current_type & 1)
+ current_header[0] = 'Z';
+ else
+ current_header[0] = 'z';
+ *header_ptr = bdev;
+ /* prev is the first/last swap page of the resume area */
+ *headerblock_ptr = (unsigned long) block;
+ return 0;
+}
+

--
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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/