From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 6/6] blspec: Automatically append rootarg
Date: Thu, 18 Jun 2015 09:43:44 +0200 [thread overview]
Message-ID: <1434613424-19989-7-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1434613424-19989-1-git-send-email-s.hauer@pengutronix.de>
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>
---
Documentation/user/booting-linux.rst | 7 +++++++
common/blspec.c | 29 ++++++++++++++++++++++++++++-
2 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/Documentation/user/booting-linux.rst b/Documentation/user/booting-linux.rst
index 6e7d155..39084e5 100644
--- a/Documentation/user/booting-linux.rst
+++ b/Documentation/user/booting-linux.rst
@@ -205,6 +205,13 @@ compatible NFS URI string must be passed to the boot command:
boot nfs://nfshost//path/
+Additionally to the options defined in the original spec barebox understands the
+``linux-appendroot`` option. This is a boolean value and if set to ``true`` barebox
+will automatically append a ``root=`` string to the Linux commandline based on the
+device where the entry is found on. This makes it possible to use the same rootfs
+image on different devices without having to specify a different root= option each
+time.
+
Network boot
------------
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);
--
2.1.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2015-06-18 7:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-18 7:43 Bootspec: Allow to automatically append root= option Sascha Hauer
2015-06-18 7:43 ` [PATCH 1/6] Add globalvar_add_simple_string function Sascha Hauer
2015-06-18 7:43 ` [PATCH 2/6] cdev: Add partuuid string to struct cdev Sascha Hauer
2015-06-18 7:43 ` [PATCH 3/6] fs: Add device parameter for Linux root= option Sascha Hauer
2015-06-18 7:43 ` [PATCH 4/6] fs: ubifs: Implement Linux rootarg Sascha Hauer
2015-06-18 7:43 ` [PATCH 5/6] fs: nfs: " Sascha Hauer
2015-06-18 7:43 ` Sascha Hauer [this message]
2015-06-30 7:26 ` [PATCH 6/6] blspec: Automatically append rootarg Marc Kleine-Budde
2015-07-01 6:58 ` Sascha Hauer
2015-07-01 7:22 ` Marc Kleine-Budde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1434613424-19989-7-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox