summaryrefslogtreecommitdiffstats
path: root/common/blspec.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-06-17 13:00:36 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2015-06-18 09:01:01 +0200
commit716fdbf18ca12feb81e26df729a5b8969e394e96 (patch)
tree230b39cb7d35df1fcdbbc04d965cc5dbc6263d05 /common/blspec.c
parent278d9b8ba6673e34b7ceb41212cf3e270a04d683 (diff)
downloadbarebox-716fdbf18ca12feb81e26df729a5b8969e394e96.tar.gz
blspec: Automatically append rootarg
This patch makes it possible to automatically add a suitable root= option for booting Linux from the same filesystem on which the bootspec entry has been found. This adds an additional 'linux-appendroot' option to bootspec which if set to 'true' will cause barebox to automatically add a root= option. This currently works for NFS, UBIFS and regular block devices like ATA, SD/MMC using the root=PARTUUID= mechanism. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/blspec.c')
-rw-r--r--common/blspec.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/common/blspec.c b/common/blspec.c
index 3506388..742065e 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -601,6 +601,29 @@ int blspec_scan_devicename(struct blspec *blspec, const char *devname)
return blspec_scan_device(blspec, dev);
}
+static int blspec_append_root(struct blspec_entry *entry)
+{
+ const char *appendroot;
+ char *rootarg;
+
+ appendroot = blspec_entry_var_get(entry, "linux-appendroot");
+ if (!appendroot || strcmp(appendroot, "true"))
+ return 0;
+
+ rootarg = path_get_linux_rootarg(entry->rootpath);
+ if (IS_ERR(rootarg)) {
+ pr_err("Getting root argument for %s failed with: %s\n",
+ entry->rootpath, strerror(-PTR_ERR(rootarg)));
+ return PTR_ERR(rootarg);
+ }
+
+ globalvar_add_simple("linux.bootargs.dyn.blspec.appendroot", rootarg);
+
+ free(rootarg);
+
+ return 0;
+}
+
/*
* blspec_boot - boot an entry
*
@@ -650,6 +673,10 @@ int blspec_boot(struct blspec_entry *entry, int verbose, int dryrun)
globalvar_add_simple("linux.bootargs.dyn.blspec", options);
+ ret = blspec_append_root(entry);
+ if (ret)
+ goto err_out;
+
pr_info("booting %s from %s\n", blspec_entry_var_get(entry, "title"),
entry->cdev ? dev_name(entry->cdev->dev) : "none");
@@ -668,7 +695,7 @@ int blspec_boot(struct blspec_entry *entry, int verbose, int dryrun)
ret = bootm_boot(&data);
if (ret)
pr_err("Booting failed\n");
-
+err_out:
free((char *)data.oftree_file);
free((char *)data.initrd_file);
free((char *)data.os_file);