summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Neuling <mikey@neuling.org>2007-04-27 14:53:18 +1000
committerSimon Horman <horms@verge.net.au>2007-05-01 11:22:54 +0900
commit8ec6347996ce83c369edeee4bed0498dedda6b41 (patch)
tree534bc5b13fa7c06c49700d34d864a20afc18ccf6
parentb42483a7f148456186212abed9d3c4b2535d1d60 (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>
-rw-r--r--kexec/kexec.c33
-rw-r--r--kexec/kexec.h2
2 files changed, 35 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);
}
diff --git a/kexec/kexec.h b/kexec/kexec.h
index 2b6ff81..4df5aba 100644
--- a/kexec/kexec.h
+++ b/kexec/kexec.h
@@ -163,6 +163,7 @@ extern int file_types;
#define OPT_MEM_MIN 256
#define OPT_MEM_MAX 257
#define OPT_MAX 258
+#define OPT_REUSE_INITRD 259
#define KEXEC_OPTIONS \
{ "help", 0, 0, OPT_HELP }, \
{ "version", 0, 0, OPT_VERSION }, \
@@ -175,6 +176,7 @@ extern int file_types;
{ "load-panic", 0, 0, OPT_PANIC }, \
{ "mem-min", 1, 0, OPT_MEM_MIN }, \
{ "mem-max", 1, 0, OPT_MEM_MAX }, \
+ { "reuseinitrd", 0, 0, OPT_REUSE_INITRD }, \
#define KEXEC_OPT_STR "hvdfxluet:p"