summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-04-29 10:53:51 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2016-05-04 11:58:46 +0200
commitf66990af3cf2e1bfda60938beeadcb98557d9487 (patch)
tree1396f22e661ba9d8fe12ba89922b73f6ec372484 /common
parenta9b18674c0ffefd08064dff898b1f621f8c258d5 (diff)
downloadbarebox-f66990af3cf2e1bfda60938beeadcb98557d9487.tar.gz
barebox-f66990af3cf2e1bfda60938beeadcb98557d9487.tar.xz
bootm: Optionally add a root= option to Kernel command line
It becomes a common case that the Kernel is loaded from the filesystem which later becomes the rootfs. This adds a possibility to let bootm automatically append the root= option to the kernel command line. This is done when global.bootm.appendroot is true. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/bootm.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/common/bootm.c b/common/bootm.c
index 6d22aab289..cad8c73efe 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -48,6 +48,8 @@ static struct image_handler *bootm_find_handler(enum filetype filetype,
return NULL;
}
+static int bootm_appendroot;
+
void bootm_data_init_defaults(struct bootm_data *data)
{
data->initrd_address = UIMAGE_INVALID_ADDRESS;
@@ -58,6 +60,7 @@ void bootm_data_init_defaults(struct bootm_data *data)
getenv_ul("global.bootm.initrd.loadaddr", &data->initrd_address);
data->initrd_file = getenv_nonempty("global.bootm.initrd");
data->verify = bootm_get_verify_mode();
+ data->appendroot = bootm_appendroot;
}
static enum bootm_verify bootm_verify_mode = BOOTM_VERIFY_HASH;
@@ -576,6 +579,18 @@ int bootm_boot(struct bootm_data *bootm_data)
}
}
+ if (bootm_data->appendroot) {
+ char *rootarg;
+
+ rootarg = path_get_linux_rootarg(data->os_file);
+ if (!IS_ERR(rootarg)) {
+ printf("Adding \"%s\" to Kernel commandline\n", rootarg);
+ globalvar_add_simple("linux.bootargs.bootm.appendroot",
+ rootarg);
+ free(rootarg);
+ }
+ }
+
printf("\nLoading %s '%s'", file_type_to_string(os_type),
data->os_file);
if (os_type == filetype_uimage &&
@@ -621,6 +636,7 @@ err_out:
if (data->of_root_node && data->of_root_node != of_get_root_node())
of_delete_node(data->of_root_node);
+ globalvar_remove("linux.bootargs.bootm.appendroot");
free(data->os_file);
free(data->oftree_file);
free(data->initrd_file);
@@ -634,6 +650,7 @@ static int bootm_init(void)
globalvar_add_simple("bootm.image", NULL);
globalvar_add_simple("bootm.image.loadaddr", NULL);
globalvar_add_simple("bootm.oftree", NULL);
+ globalvar_add_simple_bool("bootm.appendroot", &bootm_appendroot);
if (IS_ENABLED(CONFIG_CMD_BOOTM_INITRD)) {
globalvar_add_simple("bootm.initrd", NULL);
globalvar_add_simple("bootm.initrd.loadaddr", NULL);