Messages in this thread Patch in this message | | | From | Nigel Cunningham <> | Subject | [Suspend2][ 14/19] [Suspend2] Sanity check image header. | Date | Tue, 27 Jun 2006 08:36:46 +1000 |
| |
Check that an image header matches the currently running kernel, and return either a string describing the problem, or NULL.
Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
kernel/power/io.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/kernel/power/io.c b/kernel/power/io.c index d7c48e0..8c9c284 100644 --- a/kernel/power/io.c +++ b/kernel/power/io.c @@ -676,3 +676,42 @@ write_image_header_abort_no_cleanup: return -1; } +/* sanity_check() + * + * Description: Perform a few checks, seeking to ensure that the kernel being + * booted matches the one suspended. They need to match so we can + * be _sure_ things will work. It is not absolutely impossible for + * resuming from a different kernel to work, just not assured. + * Arguments: Struct suspend_header. The header which was saved at suspend + * time. + */ +static char *sanity_check(struct suspend_header *sh) +{ + if (sh->version_code != LINUX_VERSION_CODE) + return "Incorrect kernel version."; + + if (sh->num_physpages != num_physpages) + return "Incorrect memory size."; + + if (strncmp(sh->machine, system_utsname.machine, 65)) + return "Incorrect machine type."; + + if (strncmp(sh->version, system_utsname.version, 65)) + return "Right kernel version but wrong build number."; + + if (sh->page_size != PAGE_SIZE) + return "Incorrect PAGE_SIZE."; + + if (!test_suspend_state(SUSPEND_IGNORE_ROOTFS)) { + const struct super_block *sb; + list_for_each_entry(sb, &super_blocks, s_list) { + if ((!(sb->s_flags & MS_RDONLY)) && + (sb->s_type->fs_flags & FS_REQUIRES_DEV)) + return "Device backed fs has been mounted " + "rw prior to resume."; + } + } + + 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |