[Suspend2][ 06/20] [Suspend2] Calculate header storage needed.

Nigel Cunningham
2006-06-26T23:34:54Z

Calculate the total amount of storage needed (in pages) for the image header.

Signed-off-by: Nigel Cunningham <nigel@suspend2.net>

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

diff --git a/kernel/power/prepare_image.c b/kernel/power/prepare_image.c
index 9f1eb74..5070735 100644
--- a/kernel/power/prepare_image.c
+++ b/kernel/power/prepare_image.c
@@ -120,3 +120,16 @@ static long main_storage_needed(int use_
(use_ecr ? suspend_expected_compression_ratio() : 100) / 100);
}

+/*
+ * Storage needed for the image header, in bytes until the return.
+ */
+static int header_storage_needed(void)
+{
+ unsigned long bytes =
+ sizeof(struct suspend_header) +
+ (int) suspend_header_storage_for_modules() +
+ suspend_pageflags_space_needed();
+
+ return ((int) ((bytes + (int) PAGE_SIZE - 1) >> PAGE_SHIFT));