Write the header of an image to storage.
Signed-off-by: Nigel Cunningham <[email protected]>
kernel/power/io.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 62 insertions(+), 0 deletions(-)
diff --git a/kernel/power/io.c b/kernel/power/io.c
index b179c50..d7c48e0 100644
--- a/kernel/power/io.c
+++ b/kernel/power/io.c
@@ -614,3 +614,65 @@ static int read_module_configs(void)
return 0;
}
+/* write_image_header()
+ *
+ * Description: Write the image header after write the image proper.
+ * Returns: Int. Zero on success or -1 on failure.
+ */
+
+int write_image_header(void)
+{
+ int ret;
+ int total = pagedir1.pageset_size + pagedir2.pageset_size+2;
+ char *header_buffer = NULL;
+
+ /* Now prepare to write the header */
+ if ((ret = suspend_active_writer->write_header_init())) {
+ abort_suspend("Active writer's write_header_init"
+ " function failed.");
+ goto write_image_header_abort;
+ }
+
+ /* Get a buffer */
+ header_buffer = (char *) get_zeroed_page(GFP_ATOMIC);
+ if (!header_buffer) {
+ abort_suspend("Out of memory when trying to get page "
+ "for header!");
+ goto write_image_header_abort;
+ }
+
+ /* Write suspend header */
+ fill_suspend_header((struct suspend_header *) header_buffer);
+ suspend_active_writer->rw_header_chunk(WRITE, NULL,
+ header_buffer, sizeof(struct suspend_header));
+
+ free_page((unsigned long) header_buffer);
+
+ /* Write module configurations */
+ if ((ret = write_module_configs())) {
+ abort_suspend("Failed to write module configs.");
+ goto write_image_header_abort;
+ }
+
+ save_dyn_pageflags(pageset1_map);
+
+ /* Flush data and let writer cleanup */
+ if (suspend_active_writer->write_header_cleanup()) {
+ abort_suspend("Failed to cleanup writing header.");
+ goto write_image_header_abort_no_cleanup;
+ }
+
+ if (test_result_state(SUSPEND_ABORTED))
+ goto write_image_header_abort_no_cleanup;
+
+ suspend_message(SUSPEND_IO, SUSPEND_VERBOSE, 1, "|\n");
+ suspend_update_status(total, total, NULL);
+
+ return 0;
+
+write_image_header_abort:
+ suspend_active_writer->write_header_cleanup();
+write_image_header_abort_no_cleanup:
+ 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]