From: Robert Karszniewicz <r.karszniewicz@phytec.de>
To: barebox@lists.infradead.org
Subject: Re: [PATCH v3] bootm: add global.bootm.root_dev env var for booting via PARTUUID
Date: Wed, 19 Aug 2020 12:24:37 +0200 [thread overview]
Message-ID: <62828c67-f355-d10b-1aed-0f7b152b1b05@phytec.de> (raw)
In-Reply-To: <1597062008-184305-1-git-send-email-r.karszniewicz@phytec.de>
What's the status on this, please?
Greetings.
On 8/10/20 2:20 PM, Robert Karszniewicz wrote:
> Introduces a new env var which specifies which device is the rootfs
> device to be used in Linux, passed to Linux via bootargs, identified by
> the rootfs partition's PARTUUID.
>
> global.bootm.root_dev supplements global.bootm.appendroot, in that it
> overrides appendroot's naïve default, which picks the partition that the
> kernel resides on (global.bootm.image).
>
> Example:
> detect mmc2
> global.bootm.image='/mnt/mmc2.0/zImage'
> global.bootm.appendroot=1
> global.bootm.root_dev=/dev/mmc2.1
> boot mmc
>
> Signed-off-by: Robert Karszniewicz <r.karszniewicz@phytec.de>
> ---
> Changes from v2:
> - correct commit message line lengths
>
> Changes from v1:
> - minor commit message change
>
> Changes from RFC v2:
> - replaced path_get_linux_rootarg("invalid") by ERR_PTR(-EINVAL)
> - added error messages. (I've made them mutually exclusive to prevent
> NULL-pointer dereference)
>
> common/bootm.c | 25 +++++++++++++++++++++++--
> include/bootm.h | 2 ++
> 2 files changed, 25 insertions(+), 2 deletions(-)
>
> diff --git a/common/bootm.c b/common/bootm.c
> index 8fec1ee34dd8..7f951172ccf5 100644
> --- a/common/bootm.c
> +++ b/common/bootm.c
> @@ -64,6 +64,7 @@ void bootm_data_init_defaults(struct bootm_data *data)
> getenv_ul("global.bootm.image.loadaddr", &data->os_address);
> getenv_ul("global.bootm.initrd.loadaddr", &data->initrd_address);
> data->initrd_file = getenv_nonempty("global.bootm.initrd");
> + data->root_dev = getenv_nonempty("global.bootm.root_dev");
> data->verify = bootm_get_verify_mode();
> data->appendroot = bootm_appendroot;
> data->provide_machine_id = bootm_provide_machine_id;
> @@ -655,7 +656,25 @@ int bootm_boot(struct bootm_data *bootm_data)
> if (bootm_data->appendroot) {
> char *rootarg;
>
> - rootarg = path_get_linux_rootarg(data->os_file);
> + if (bootm_data->root_dev) {
> + const char *root_dev_name = devpath_to_name(bootm_data->root_dev);
> + const struct cdev *root_cdev = cdev_by_name(root_dev_name);
> +
> + if (root_cdev && root_cdev->partuuid[0] != 0) {
> + rootarg = basprintf("root=PARTUUID=%s", root_cdev->partuuid);
> + } else {
> + rootarg = ERR_PTR(-EINVAL);
> +
> + if (!root_cdev)
> + pr_err("no cdev found for %s, cannot set root= option\n",
> + root_dev_name);
> + else if (!root_cdev->partuuid[0])
> + pr_err("%s doesn't have a PARTUUID, cannot set root= option\n",
> + root_dev_name);
> + }
> + } else {
> + 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",
> @@ -742,6 +761,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("bootm.root_dev", NULL);
> globalvar_add_simple("bootm.tee", NULL);
> globalvar_add_simple_bool("bootm.appendroot", &bootm_appendroot);
> globalvar_add_simple_bool("bootm.provide_machine_id", &bootm_provide_machine_id);
> @@ -771,5 +791,6 @@ BAREBOX_MAGICVAR_NAMED(global_bootm_oftree, global.bootm.oftree, "bootm default
> BAREBOX_MAGICVAR_NAMED(global_bootm_tee, global.bootm.tee, "bootm default tee image");
> BAREBOX_MAGICVAR_NAMED(global_bootm_verify, global.bootm.verify, "bootm default verify level");
> BAREBOX_MAGICVAR_NAMED(global_bootm_verbose, global.bootm.verbose, "bootm default verbosity level (0=quiet)");
> -BAREBOX_MAGICVAR_NAMED(global_bootm_appendroot, global.bootm.appendroot, "Add root= option to Kernel to mount rootfs from the device the Kernel comes from");
> +BAREBOX_MAGICVAR_NAMED(global_bootm_appendroot, global.bootm.appendroot, "Add root= option to Kernel to mount rootfs from the device the Kernel comes from (default, device can be overridden via global.bootm.root_dev)");
> +BAREBOX_MAGICVAR_NAMED(global_bootm_root_dev, global.bootm.root_dev, "bootm default root device (overrides default device in global.bootm.appendroot)");
> BAREBOX_MAGICVAR_NAMED(global_bootm_provide_machine_id, global.bootm.provide_machine_id, "If true, add systemd.machine_id= with value of global.machine_id to Kernel");
> diff --git a/include/bootm.h b/include/bootm.h
> index 7782de7a476d..3628a7eea5b9 100644
> --- a/include/bootm.h
> +++ b/include/bootm.h
> @@ -18,6 +18,7 @@ struct bootm_data {
> const char *initrd_file;
> const char *oftree_file;
> const char *tee_file;
> + const char *root_dev;
> int verbose;
> enum bootm_verify verify;
> bool force;
> @@ -25,6 +26,7 @@ struct bootm_data {
> /*
> * appendroot - if true, try to add a suitable root= Kernel option to
> * mount the rootfs from the same device as the Kernel comes from.
> + * The default rootfs device can be overridden with root_dev.
> */
> bool appendroot;
> /*
>
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2020-08-19 10:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-10 12:20 Robert Karszniewicz
2020-08-19 10:24 ` Robert Karszniewicz [this message]
2020-08-20 7:05 ` Sascha Hauer
2020-08-20 12:53 ` Robert Karszniewicz
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=62828c67-f355-d10b-1aed-0f7b152b1b05@phytec.de \
--to=r.karszniewicz@phytec.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