|
|
e35838 |
From a1ae68d19b6e3534ead0aab04ca84de24962def7 Mon Sep 17 00:00:00 2001
|
|
|
e35838 |
From: "dyoung@redhat.com" <dyoung@redhat.com>
|
|
|
e35838 |
Date: Wed, 28 Oct 2015 13:41:35 +0800
|
|
|
e35838 |
Subject: [PATCH 1/3] fs2dt.c: move copy old root param as a new function
|
|
|
e35838 |
|
|
|
e35838 |
Split the copy old root param code to a new function dt_copy_old_root_param
|
|
|
e35838 |
Also add a global variable dt_no_old_root, do not copy root param when
|
|
|
e35838 |
dt_no_old_root == 1. It will be used in later patches.
|
|
|
e35838 |
|
|
|
e35838 |
Signed-off-by: Dave Young <dyoung@redhat.com>
|
|
|
e35838 |
Signed-off-by: Simon Horman <horms@verge.net.au>
|
|
|
e35838 |
---
|
|
|
e35838 |
kexec/fs2dt.c | 66 ++++++++++++++++++++++++++++++++++++-----------------------
|
|
|
e35838 |
kexec/fs2dt.h | 1 +
|
|
|
e35838 |
2 files changed, 41 insertions(+), 26 deletions(-)
|
|
|
e35838 |
|
|
|
e35838 |
diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
|
|
|
e35838 |
index d73e144..0ea785f 100644
|
|
|
e35838 |
--- a/kexec/fs2dt.c
|
|
|
e35838 |
+++ b/kexec/fs2dt.c
|
|
|
e35838 |
@@ -53,6 +53,7 @@ extern unsigned char reuse_initrd;
|
|
|
e35838 |
/* Used for enabling printing message from purgatory code
|
|
|
e35838 |
* Only has implemented for PPC64 */
|
|
|
e35838 |
int my_debug;
|
|
|
e35838 |
+int dt_no_old_root;
|
|
|
e35838 |
|
|
|
e35838 |
/* This provides the behaviour of hte existing ppc64 implementation */
|
|
|
e35838 |
static void pad_structure_block(size_t len) {
|
|
|
e35838 |
@@ -511,6 +512,37 @@ static int comparefunc(const struct dirent **dentry1,
|
|
|
e35838 |
return strcmp(str1, str2);
|
|
|
e35838 |
}
|
|
|
e35838 |
|
|
|
e35838 |
+/* grab root= from the old command line */
|
|
|
e35838 |
+static void dt_copy_old_root_param(void)
|
|
|
e35838 |
+{
|
|
|
e35838 |
+ FILE *fp;
|
|
|
e35838 |
+ char filename[MAXPATH];
|
|
|
e35838 |
+ char *last_cmdline = NULL;
|
|
|
e35838 |
+ char *p, *old_param;
|
|
|
e35838 |
+ size_t len = 0;
|
|
|
e35838 |
+
|
|
|
e35838 |
+ strcpy(filename, pathname);
|
|
|
e35838 |
+ strcat(filename, "bootargs");
|
|
|
e35838 |
+ fp = fopen(filename, "r");
|
|
|
e35838 |
+ if (fp) {
|
|
|
e35838 |
+ if (getline(&last_cmdline, &len, fp) == -1)
|
|
|
e35838 |
+ die("unable to read %s\n", filename);
|
|
|
e35838 |
+
|
|
|
e35838 |
+ p = strstr(last_cmdline, "root=");
|
|
|
e35838 |
+ if (p) {
|
|
|
e35838 |
+ old_param = strtok(p, " ");
|
|
|
e35838 |
+ len = strlen(local_cmdline);
|
|
|
e35838 |
+ if (len != 0)
|
|
|
e35838 |
+ strcat(local_cmdline, " ");
|
|
|
e35838 |
+ strcat(local_cmdline, old_param);
|
|
|
e35838 |
+ }
|
|
|
e35838 |
+ }
|
|
|
e35838 |
+ if (last_cmdline)
|
|
|
e35838 |
+ free(last_cmdline);
|
|
|
e35838 |
+
|
|
|
e35838 |
+ fclose(fp);
|
|
|
e35838 |
+}
|
|
|
e35838 |
+
|
|
|
e35838 |
/*
|
|
|
e35838 |
* put a node (directory) in the property structure. first properties
|
|
|
e35838 |
* then children.
|
|
|
e35838 |
@@ -579,8 +611,11 @@ static void putnode(void)
|
|
|
e35838 |
reserve(initrd_base, initrd_size);
|
|
|
e35838 |
}
|
|
|
e35838 |
|
|
|
e35838 |
- /* Add cmdline to the second kernel. Check to see if the new
|
|
|
e35838 |
- * cmdline has a root=. If not, use the old root= cmdline. */
|
|
|
e35838 |
+ /*
|
|
|
e35838 |
+ * Add cmdline to the second kernel. Use the old root= cmdline if there
|
|
|
e35838 |
+ * is no root= in the new command line and there's no --dt-no-old-root
|
|
|
e35838 |
+ * option being used.
|
|
|
e35838 |
+ */
|
|
|
e35838 |
if (!strcmp(basename,"chosen/")) {
|
|
|
e35838 |
size_t result;
|
|
|
e35838 |
size_t cmd_len = 0;
|
|
|
e35838 |
@@ -598,30 +633,9 @@ static void putnode(void)
|
|
|
e35838 |
param = strstr(local_cmdline, "root=");
|
|
|
e35838 |
}
|
|
|
e35838 |
|
|
|
e35838 |
- /* ... if not, grab root= from the old command line */
|
|
|
e35838 |
- if (!param) {
|
|
|
e35838 |
- FILE *fp;
|
|
|
e35838 |
- char *last_cmdline = NULL;
|
|
|
e35838 |
- char *old_param;
|
|
|
e35838 |
-
|
|
|
e35838 |
- strcpy(filename, pathname);
|
|
|
e35838 |
- strcat(filename, "bootargs");
|
|
|
e35838 |
- fp = fopen(filename, "r");
|
|
|
e35838 |
- if (fp) {
|
|
|
e35838 |
- if (getline(&last_cmdline, &cmd_len, fp) == -1)
|
|
|
e35838 |
- die("unable to read %s\n", filename);
|
|
|
e35838 |
-
|
|
|
e35838 |
- param = strstr(last_cmdline, "root=");
|
|
|
e35838 |
- if (param) {
|
|
|
e35838 |
- old_param = strtok(param, " ");
|
|
|
e35838 |
- if (cmd_len != 0)
|
|
|
e35838 |
- strcat(local_cmdline, " ");
|
|
|
e35838 |
- strcat(local_cmdline, old_param);
|
|
|
e35838 |
- }
|
|
|
e35838 |
- }
|
|
|
e35838 |
- if (last_cmdline)
|
|
|
e35838 |
- free(last_cmdline);
|
|
|
e35838 |
- }
|
|
|
e35838 |
+ if (!param && !dt_no_old_root)
|
|
|
e35838 |
+ dt_copy_old_root_param();
|
|
|
e35838 |
+
|
|
|
e35838 |
strcat(local_cmdline, " ");
|
|
|
e35838 |
cmd_len = strlen(local_cmdline);
|
|
|
e35838 |
cmd_len = cmd_len + 1;
|
|
|
e35838 |
diff --git a/kexec/fs2dt.h b/kexec/fs2dt.h
|
|
|
e35838 |
index 6c5c3b2..7633273 100644
|
|
|
e35838 |
--- a/kexec/fs2dt.h
|
|
|
e35838 |
+++ b/kexec/fs2dt.h
|
|
|
e35838 |
@@ -31,6 +31,7 @@ extern struct bootblock bb[1];
|
|
|
e35838 |
/* Used for enabling printing message from purgatory code
|
|
|
e35838 |
* Only has implemented for PPC64 */
|
|
|
e35838 |
int my_debug;
|
|
|
e35838 |
+extern int dt_no_old_root;
|
|
|
e35838 |
|
|
|
e35838 |
void reserve(unsigned long long where, unsigned long long length);
|
|
|
e35838 |
void create_flatten_tree(char **, off_t *, const char *);
|
|
|
e35838 |
--
|
|
|
e35838 |
2.5.0
|
|
|
e35838 |
|