diff options
author | Michael Neuling <mikey@neuling.org> | 2007-04-27 14:53:18 +1000 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2007-05-01 11:22:54 +0900 |
commit | 8ec6347996ce83c369edeee4bed0498dedda6b41 (patch) | |
tree | 534bc5b13fa7c06c49700d34d864a20afc18ccf6 /kexec/kexec.c | |
parent | b42483a7f148456186212abed9d3c4b2535d1d60 (diff) |
kexec: Added generic --reuseinitrd option
Adds a generic --reuseinitrd option and performs some sanity checks on
it. Can be used with the retain_initrd kernel option.
Signed-off-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec/kexec.c')
-rw-r--r-- | kexec/kexec.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/kexec/kexec.c b/kexec/kexec.c index 5d6dd97..9835405 100644 --- a/kexec/kexec.c +++ b/kexec/kexec.c @@ -748,6 +748,7 @@ void usage(void) " load code into.\n" " --mem-max=<addr> Specify the highest memory address to\n" " load code into.\n" + " --reuseinird Reuse initrd from first boot.\n" "\n" "Supported kernel file types and options: \n"); for (i = 0; i < file_types; i++) { @@ -772,6 +773,29 @@ static int kexec_loaded(void) return ret; } +/* check we retained the initrd */ +void check_reuse_initrd(void) +{ + FILE * fp; + char * line = NULL; + size_t len = 0; + ssize_t read; + + fp = fopen("/proc/cmdline", "r"); + if (fp == NULL) + die("unable to open /proc/cmdline\n"); + read = getline(&line, &len, fp); + if (strstr(line, "retain_initrd") == NULL) + die("unrecoverable error: current boot didn't " + "retain the initrd for reuse.\n"); +} + +/* Arch hook for reuse_initrd */ +void __attribute__((weak)) arch_reuse_initrd(void) +{ + die("--reuseinitrd not implemented on this architecture\n"); +} + int main(int argc, char *argv[]) { int do_load = 1; @@ -780,6 +804,7 @@ int main(int argc, char *argv[]) int do_sync = 1; int do_ifdown = 0; int do_unload = 0; + int do_reuse_initrd = 0; unsigned long kexec_flags = 0; char *type = 0; char *endptr; @@ -860,6 +885,9 @@ int main(int argc, char *argv[]) return 1; } break; + case OPT_REUSE_INITRD: + do_reuse_initrd = 1; + break; default: break; } @@ -890,6 +918,11 @@ int main(int argc, char *argv[]) } } + if (do_reuse_initrd){ + check_reuse_initrd(); + arch_reuse_initrd(); + } + if (do_unload) { result = k_unload(kexec_flags); } |