diff options
author | Mohan Kumar M <mohan@in.ibm.com> | 2006-10-09 14:56:13 +0530 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2006-10-13 16:04:17 +0900 |
commit | fcd1df8df66762b741a99319434405817e4c31ec (patch) | |
tree | 0f6d5eefbf094b321feac4eca6ca002d958291b9 | |
parent | 7ba1a8074fa4010494a779f05f360f02058d76bc (diff) |
Check for crashkernel reservation in i386
Check whether memory for crashkernel is reserved or not by looking for the
entry "Crash kernel" in /proc/iomem.
Signed-off-by: Mohan Kumar M <mohan@in.ibm.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
-rw-r--r-- | kexec/arch/i386/crashdump-x86.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c index b286527..59dd3cd 100644 --- a/kexec/arch/i386/crashdump-x86.c +++ b/kexec/arch/i386/crashdump-x86.c @@ -722,3 +722,33 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, cmdline_add_elfcorehdr(mod_cmdline, elfcorehdr); return 0; } + +int is_crashkernel_mem_reserved(void) +{ + const char iomem[]= "/proc/iomem"; + char line[MAX_LINE]; + FILE *fp; + unsigned long long start, end; + char *str; + int consumed; + int count; + + fp = fopen(iomem, "r"); + if (!fp) + die("Cannot open /proc/iomem"); + + while(fgets(line, sizeof(line), fp) != 0) { + count = sscanf(line, "%Lx-%Lx : %n", &start, &end, &consumed); + if (count != 2) + continue; + str = line + consumed; + if (memcmp(str, "Crash kernel\n", 13) == 0) + break; + } + + fclose(fp); + if (!memcmp(str, "Crash kernel\n", 13) == 0 || (start == end)) + return 0; + else + return 1; +} |