mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] common: setting the root= command line parameter
@ 2025-11-24 10:16 Fabian Pflug
  2025-11-24 12:00 ` Ahmad Fatoum
  0 siblings, 1 reply; 41+ messages in thread
From: Fabian Pflug @ 2025-11-24 10:16 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug

In verified boot settings, it might not be wanted to have a root=
command line parameter for the kernel, because if the initramfs is not
configured, or barebox boots the kernel directly due to
misconfiguration, the device might boot correctly, but without verified
boot, because the kernel will parse root=

Allowing to change the parameter name will help circumvent such errors,
as there now needs to be multiple misconfigurations for the verified
boot to go wrong and the initramfs can use a the different name from the
commandline to get the rootfs.

Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
---
 common/Kconfig         | 13 +++++++++++++
 common/block.c         |  3 +--
 common/bootm.c         |  8 ++++----
 drivers/mci/mci-core.c |  2 +-
 fs/9p/vfs_super.c      |  2 +-
 fs/nfs.c               |  2 +-
 fs/squashfs/squashfs.c |  2 +-
 fs/ubifs/ubifs.c       |  2 +-
 8 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index d923d4c4b6..62797a9e69 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -1252,6 +1252,19 @@ config SERIAL_NUMBER_FIXUP_SYSTEMD_HOSTNAME
 	  This option without effect if global.bootm.provide_hostname
 	  is unset.
 
+config ROOT_COMMANDLINE_PARAMETER
+	string "parameter name for root partition"
+	default "root"
+	help
+	  When setting the root partition on the commandline string to the os, use
+	  this name as an indicator of the root partition.
+
+	  Changing this could be useful in verified boot contexts to not give the
+	  kernel the chance to boot a non-secure image, but still use the power of
+	  barebox to get the right disk for the rootfs.
+
+	  If unsure, leave as default (root)
+
 config SYSTEMD_OF_WATCHDOG
 	bool "inform devicetree-enabled kernel of used watchdog"
 	depends on WATCHDOG && OFTREE && FLEXIBLE_BOOTARGS
diff --git a/common/block.c b/common/block.c
index ca2ed37dbd..bb8b01c0a0 100644
--- a/common/block.c
+++ b/common/block.c
@@ -601,11 +601,10 @@ char *cdev_get_linux_rootarg(const struct cdev *partcdev)
 	if (blk->ops->get_rootarg)
 		rootarg = blk->ops->get_rootarg(blk, partcdev);
 	if (!rootarg && partcdev->partuuid[0] != 0)
-		rootarg = basprintf("root=PARTUUID=%s", partcdev->partuuid);
+		rootarg = basprintf(CONFIG_ROOT_COMMANDLINE_PARAMETER "=PARTUUID=%s", partcdev->partuuid);
 
 	if (IS_ENABLED(CONFIG_ROOTWAIT_BOOTARG) && blk->rootwait)
 		rootarg = linux_bootargs_append_rootwait(rootarg);
 
 	return rootarg;
 }
-
diff --git a/common/bootm.c b/common/bootm.c
index 17792b2a1d..4549bfeb8b 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -852,10 +852,10 @@ int bootm_boot(struct bootm_data *bootm_data)
 				rootarg = ERR_PTR(-EINVAL);
 
 				if (!root_cdev)
-					pr_err("no cdev found for %s, cannot set root= option\n",
+					pr_err("no cdev found for %s, cannot set " CONFIG_ROOT_COMMANDLINE_PARAMETER "= option\n",
 						root_dev_name);
 				else if (!root_cdev->partuuid[0])
-					pr_err("%s doesn't have a PARTUUID, cannot set root= option\n",
+					pr_err("%s doesn't have a PARTUUID, cannot set " CONFIG_ROOT_COMMANDLINE_PARAMETER "= option\n",
 						root_dev_name);
 			}
 
@@ -866,7 +866,7 @@ int bootm_boot(struct bootm_data *bootm_data)
 		}
 
 		if (IS_ERR(rootarg)) {
-			pr_err("Failed to append kernel cmdline parameter 'root='\n");
+			pr_err("Failed to append kernel cmdline parameter '" CONFIG_ROOT_COMMANDLINE_PARAMETER "='\n");
 		} else {
 			pr_info("Adding \"%s\" to Kernel commandline\n", rootarg);
 			globalvar_add_simple("linux.bootargs.bootm.appendroot",
@@ -1165,7 +1165,7 @@ BAREBOX_MAGICVAR(global.bootm.dryrun, "bootm default dryrun level");
 BAREBOX_MAGICVAR(global.bootm.verify, "bootm default verify level");
 BAREBOX_MAGICVAR(global.bootm.verbose, "bootm default verbosity level (0=quiet)");
 BAREBOX_MAGICVAR(global.bootm.earlycon, "Add earlycon option to Kernel for early log output");
-BAREBOX_MAGICVAR(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(global.bootm.appendroot, "Add " CONFIG_ROOT_COMMANDLINE_PARAMETER "= 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(global.bootm.root_dev, "bootm default root device (overrides default device in global.bootm.appendroot)");
 BAREBOX_MAGICVAR(global.bootm.provide_machine_id, "If true, append systemd.machine_id=$global.machine_id to Kernel command line");
 BAREBOX_MAGICVAR(global.bootm.provide_hostname, "If true, append systemd.hostname=$global.hostname to Kernel command line");
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 57825bc849..79cebe19f3 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -2691,7 +2691,7 @@ static char *mci_get_linux_mmcblkdev(struct block_device *blk,
 		 * skipping it.
 		 */
 		if (cdev_partname_equal(partcdev, cdev))
-			return basprintf("root=/dev/mmcblk%dp%d", id, partnum);
+			return basprintf(CONFIG_ROOT_COMMANDLINE_PARAMETER "=/dev/mmcblk%dp%d", id, partnum);
 		if (cdev->flags & DEVFS_PARTITION_FROM_TABLE)
 			partnum++;
 	}
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
index 6a451d9ef5..39a8529a4e 100644
--- a/fs/9p/vfs_super.c
+++ b/fs/9p/vfs_super.c
@@ -70,7 +70,7 @@ static void v9fs_set_rootarg(struct v9fs_session_info *v9ses,
 	trans = v9ses->clnt->trans_mod->name;
 	path = v9ses->aname;
 
-	str = basprintf("root=%s rootfstype=9p rootflags=trans=%s,msize=%d,"
+	str = basprintf(CONFIG_ROOT_COMMANDLINE_PARAMETER "=%s rootfstype=9p rootflags=trans=%s,msize=%d,"
 			"cache=loose,uname=%s,dfltuid=0,dfltgid=0,aname=%s",
 			tag, trans, v9ses->clnt->msize, tag, path);
 
diff --git a/fs/nfs.c b/fs/nfs.c
index 5c2476cd88..9db23c5d18 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -1558,7 +1558,7 @@ static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device *fsdev)
 	char *str, *tmp;
 	const char *bootargs;
 
-	str = basprintf("root=/dev/nfs nfsroot=%pI4:%s%s%s", &npriv->server, npriv->path,
+	str = basprintf(CONFIG_ROOT_COMMANDLINE_PARAMETER "=/dev/nfs nfsroot=%pI4:%s%s%s", &npriv->server, npriv->path,
 			  rootnfsopts[0] ? "," : "", rootnfsopts);
 
 	/* forward specific mount options on demand */
diff --git a/fs/squashfs/squashfs.c b/fs/squashfs/squashfs.c
index e30372627a..8267e3cba0 100644
--- a/fs/squashfs/squashfs.c
+++ b/fs/squashfs/squashfs.c
@@ -60,7 +60,7 @@ static void squashfs_set_rootarg(struct fs_device *fsdev)
 	ubi_get_device_info(vi.ubi_num, &di);
 	mtd = di.mtd;
 
-	str = basprintf("root=/dev/ubiblock%d_%d ubi.mtd=%s ubi.block=%d,%d rootfstype=squashfs",
+	str = basprintf(CONFIG_ROOT_COMMANDLINE_PARAMETER "=/dev/ubiblock%d_%d ubi.mtd=%s ubi.block=%d,%d rootfstype=squashfs",
 			vi.ubi_num, vi.vol_id, mtd->cdev.partname, vi.ubi_num, vi.vol_id);
 
 	fsdev_set_linux_rootarg(fsdev, str);
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 37986acbb2..34151a0c9f 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -442,7 +442,7 @@ static void ubifs_set_rootarg(struct ubifs_priv *priv,
 
 	mtd = di.mtd;
 
-	str = basprintf("root=ubi0:%s ubi.mtd=%s rootfstype=ubifs",
+	str = basprintf(CONFIG_ROOT_COMMANDLINE_PARAMETER "=ubi0:%s ubi.mtd=%s rootfstype=ubifs",
 			  vi.name, mtd->cdev.partname);
 
 	fsdev_set_linux_rootarg(fsdev, str);
-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH] common: setting the root= command line parameter
  2025-11-24 10:16 [PATCH] common: setting the root= command line parameter Fabian Pflug
@ 2025-11-24 12:00 ` Ahmad Fatoum
  2025-11-25 10:22   ` Fabian Pflug
  2025-11-26  6:42   ` [PATCH 0/4] make the root= command line parameter variable Fabian Pflug
  0 siblings, 2 replies; 41+ messages in thread
From: Ahmad Fatoum @ 2025-11-24 12:00 UTC (permalink / raw)
  To: Fabian Pflug, barebox

Hi Fabian,

On 11/24/25 11:16 AM, Fabian Pflug wrote:
> In verified boot settings, it might not be wanted to have a root=
> command line parameter for the kernel, because if the initramfs is not
> configured, or barebox boots the kernel directly due to
> misconfiguration, the device might boot correctly, but without verified
> boot, because the kernel will parse root=
> 
> Allowing to change the parameter name will help circumvent such errors,
> as there now needs to be multiple misconfigurations for the verified
> boot to go wrong and the initramfs can use a the different name from the
> commandline to get the rootfs.

Thanks for your patch!

This is a useful thing to have, but I think deciding replacement of
root= across all functionality at compile-time is too invasive:

Imagine you use the same barebox both for development and in release
mode (or you support runtime unlocking with a token).
When booting securely, you want to use verity_root= for example, but
when you do boot /mnt/nfs, you'll want barebox to fix up root= as before.

I thus think that this should be a $global.bootm.root_arg evaluated at
runtime instead.

By adding it to bootm_data_restore_defaults(), its value will then be
restored after the boot script has done executing.

What do you think?

Cheers,
Ahmad

> 
> Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
> ---
>  common/Kconfig         | 13 +++++++++++++
>  common/block.c         |  3 +--
>  common/bootm.c         |  8 ++++----
>  drivers/mci/mci-core.c |  2 +-
>  fs/9p/vfs_super.c      |  2 +-
>  fs/nfs.c               |  2 +-
>  fs/squashfs/squashfs.c |  2 +-
>  fs/ubifs/ubifs.c       |  2 +-
>  8 files changed, 23 insertions(+), 11 deletions(-)
> 
> diff --git a/common/Kconfig b/common/Kconfig
> index d923d4c4b6..62797a9e69 100644
> --- a/common/Kconfig
> +++ b/common/Kconfig
> @@ -1252,6 +1252,19 @@ config SERIAL_NUMBER_FIXUP_SYSTEMD_HOSTNAME
>  	  This option without effect if global.bootm.provide_hostname
>  	  is unset.
>  
> +config ROOT_COMMANDLINE_PARAMETER
> +	string "parameter name for root partition"
> +	default "root"
> +	help
> +	  When setting the root partition on the commandline string to the os, use
> +	  this name as an indicator of the root partition.
> +
> +	  Changing this could be useful in verified boot contexts to not give the
> +	  kernel the chance to boot a non-secure image, but still use the power of
> +	  barebox to get the right disk for the rootfs.
> +
> +	  If unsure, leave as default (root)
> +
>  config SYSTEMD_OF_WATCHDOG
>  	bool "inform devicetree-enabled kernel of used watchdog"
>  	depends on WATCHDOG && OFTREE && FLEXIBLE_BOOTARGS
> diff --git a/common/block.c b/common/block.c
> index ca2ed37dbd..bb8b01c0a0 100644
> --- a/common/block.c
> +++ b/common/block.c
> @@ -601,11 +601,10 @@ char *cdev_get_linux_rootarg(const struct cdev *partcdev)
>  	if (blk->ops->get_rootarg)
>  		rootarg = blk->ops->get_rootarg(blk, partcdev);
>  	if (!rootarg && partcdev->partuuid[0] != 0)
> -		rootarg = basprintf("root=PARTUUID=%s", partcdev->partuuid);
> +		rootarg = basprintf(CONFIG_ROOT_COMMANDLINE_PARAMETER "=PARTUUID=%s", partcdev->partuuid);
>  
>  	if (IS_ENABLED(CONFIG_ROOTWAIT_BOOTARG) && blk->rootwait)
>  		rootarg = linux_bootargs_append_rootwait(rootarg);
>  
>  	return rootarg;
>  }
> -
> diff --git a/common/bootm.c b/common/bootm.c
> index 17792b2a1d..4549bfeb8b 100644
> --- a/common/bootm.c
> +++ b/common/bootm.c
> @@ -852,10 +852,10 @@ int bootm_boot(struct bootm_data *bootm_data)
>  				rootarg = ERR_PTR(-EINVAL);
>  
>  				if (!root_cdev)
> -					pr_err("no cdev found for %s, cannot set root= option\n",
> +					pr_err("no cdev found for %s, cannot set " CONFIG_ROOT_COMMANDLINE_PARAMETER "= option\n",
>  						root_dev_name);
>  				else if (!root_cdev->partuuid[0])
> -					pr_err("%s doesn't have a PARTUUID, cannot set root= option\n",
> +					pr_err("%s doesn't have a PARTUUID, cannot set " CONFIG_ROOT_COMMANDLINE_PARAMETER "= option\n",
>  						root_dev_name);
>  			}
>  
> @@ -866,7 +866,7 @@ int bootm_boot(struct bootm_data *bootm_data)
>  		}
>  
>  		if (IS_ERR(rootarg)) {
> -			pr_err("Failed to append kernel cmdline parameter 'root='\n");
> +			pr_err("Failed to append kernel cmdline parameter '" CONFIG_ROOT_COMMANDLINE_PARAMETER "='\n");
>  		} else {
>  			pr_info("Adding \"%s\" to Kernel commandline\n", rootarg);
>  			globalvar_add_simple("linux.bootargs.bootm.appendroot",
> @@ -1165,7 +1165,7 @@ BAREBOX_MAGICVAR(global.bootm.dryrun, "bootm default dryrun level");
>  BAREBOX_MAGICVAR(global.bootm.verify, "bootm default verify level");
>  BAREBOX_MAGICVAR(global.bootm.verbose, "bootm default verbosity level (0=quiet)");
>  BAREBOX_MAGICVAR(global.bootm.earlycon, "Add earlycon option to Kernel for early log output");
> -BAREBOX_MAGICVAR(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(global.bootm.appendroot, "Add " CONFIG_ROOT_COMMANDLINE_PARAMETER "= 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(global.bootm.root_dev, "bootm default root device (overrides default device in global.bootm.appendroot)");
>  BAREBOX_MAGICVAR(global.bootm.provide_machine_id, "If true, append systemd.machine_id=$global.machine_id to Kernel command line");
>  BAREBOX_MAGICVAR(global.bootm.provide_hostname, "If true, append systemd.hostname=$global.hostname to Kernel command line");
> diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
> index 57825bc849..79cebe19f3 100644
> --- a/drivers/mci/mci-core.c
> +++ b/drivers/mci/mci-core.c
> @@ -2691,7 +2691,7 @@ static char *mci_get_linux_mmcblkdev(struct block_device *blk,
>  		 * skipping it.
>  		 */
>  		if (cdev_partname_equal(partcdev, cdev))
> -			return basprintf("root=/dev/mmcblk%dp%d", id, partnum);
> +			return basprintf(CONFIG_ROOT_COMMANDLINE_PARAMETER "=/dev/mmcblk%dp%d", id, partnum);
>  		if (cdev->flags & DEVFS_PARTITION_FROM_TABLE)
>  			partnum++;
>  	}
> diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
> index 6a451d9ef5..39a8529a4e 100644
> --- a/fs/9p/vfs_super.c
> +++ b/fs/9p/vfs_super.c
> @@ -70,7 +70,7 @@ static void v9fs_set_rootarg(struct v9fs_session_info *v9ses,
>  	trans = v9ses->clnt->trans_mod->name;
>  	path = v9ses->aname;
>  
> -	str = basprintf("root=%s rootfstype=9p rootflags=trans=%s,msize=%d,"
> +	str = basprintf(CONFIG_ROOT_COMMANDLINE_PARAMETER "=%s rootfstype=9p rootflags=trans=%s,msize=%d,"
>  			"cache=loose,uname=%s,dfltuid=0,dfltgid=0,aname=%s",
>  			tag, trans, v9ses->clnt->msize, tag, path);
>  
> diff --git a/fs/nfs.c b/fs/nfs.c
> index 5c2476cd88..9db23c5d18 100644
> --- a/fs/nfs.c
> +++ b/fs/nfs.c
> @@ -1558,7 +1558,7 @@ static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device *fsdev)
>  	char *str, *tmp;
>  	const char *bootargs;
>  
> -	str = basprintf("root=/dev/nfs nfsroot=%pI4:%s%s%s", &npriv->server, npriv->path,
> +	str = basprintf(CONFIG_ROOT_COMMANDLINE_PARAMETER "=/dev/nfs nfsroot=%pI4:%s%s%s", &npriv->server, npriv->path,
>  			  rootnfsopts[0] ? "," : "", rootnfsopts);
>  
>  	/* forward specific mount options on demand */
> diff --git a/fs/squashfs/squashfs.c b/fs/squashfs/squashfs.c
> index e30372627a..8267e3cba0 100644
> --- a/fs/squashfs/squashfs.c
> +++ b/fs/squashfs/squashfs.c
> @@ -60,7 +60,7 @@ static void squashfs_set_rootarg(struct fs_device *fsdev)
>  	ubi_get_device_info(vi.ubi_num, &di);
>  	mtd = di.mtd;
>  
> -	str = basprintf("root=/dev/ubiblock%d_%d ubi.mtd=%s ubi.block=%d,%d rootfstype=squashfs",
> +	str = basprintf(CONFIG_ROOT_COMMANDLINE_PARAMETER "=/dev/ubiblock%d_%d ubi.mtd=%s ubi.block=%d,%d rootfstype=squashfs",
>  			vi.ubi_num, vi.vol_id, mtd->cdev.partname, vi.ubi_num, vi.vol_id);
>  
>  	fsdev_set_linux_rootarg(fsdev, str);
> diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
> index 37986acbb2..34151a0c9f 100644
> --- a/fs/ubifs/ubifs.c
> +++ b/fs/ubifs/ubifs.c
> @@ -442,7 +442,7 @@ static void ubifs_set_rootarg(struct ubifs_priv *priv,
>  
>  	mtd = di.mtd;
>  
> -	str = basprintf("root=ubi0:%s ubi.mtd=%s rootfstype=ubifs",
> +	str = basprintf(CONFIG_ROOT_COMMANDLINE_PARAMETER "=ubi0:%s ubi.mtd=%s rootfstype=ubifs",
>  			  vi.name, mtd->cdev.partname);
>  
>  	fsdev_set_linux_rootarg(fsdev, str);

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |




^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH] common: setting the root= command line parameter
  2025-11-24 12:00 ` Ahmad Fatoum
@ 2025-11-25 10:22   ` Fabian Pflug
  2025-11-25 19:13     ` Ahmad Fatoum
  2025-11-26  6:42   ` [PATCH 0/4] make the root= command line parameter variable Fabian Pflug
  1 sibling, 1 reply; 41+ messages in thread
From: Fabian Pflug @ 2025-11-25 10:22 UTC (permalink / raw)
  To: Ahmad Fatoum, barebox

Hey :)

On Mon, 2025-11-24 at 13:00 +0100, Ahmad Fatoum wrote:
> Hi Fabian,
> 
> On 11/24/25 11:16 AM, Fabian Pflug wrote:
> > In verified boot settings, it might not be wanted to have a root=
> > command line parameter for the kernel, because if the initramfs is not
> > configured, or barebox boots the kernel directly due to
> > misconfiguration, the device might boot correctly, but without verified
> > boot, because the kernel will parse root=
> > 
> > Allowing to change the parameter name will help circumvent such errors,
> > as there now needs to be multiple misconfigurations for the verified
> > boot to go wrong and the initramfs can use a the different name from the
> > commandline to get the rootfs.
> 
> Thanks for your patch!
> 
> This is a useful thing to have, but I think deciding replacement of
> root= across all functionality at compile-time is too invasive:
> 
> Imagine you use the same barebox both for development and in release
> mode (or you support runtime unlocking with a token).
> When booting securely, you want to use verity_root= for example, but
> when you do boot /mnt/nfs, you'll want barebox to fix up root= as before.
> 
> I thus think that this should be a $global.bootm.root_arg evaluated at
> runtime instead.
> 
> By adding it to bootm_data_restore_defaults(), its value will then be
> restored after the boot script has done executing.
> 
> What do you think?


Do you want to have string-replacement in bootm, or should all of them query the value for root_arg?

Are you thinking something along the lines of:

--- a/common/bootm.c
+++ b/common/bootm.c
@@ -868,6 +868,11 @@ int bootm_boot(struct bootm_data *bootm_data)
                if (IS_ERR(rootarg)) {
                        pr_err("Failed to append kernel cmdline parameter 'root='\n");
                } else {
+                       if (bootm_data->prefix_root) {
+                               char* rootarg_old = rootarg;
+                               rootarg = xasprintf("%s%s",bootm_data->prefix_root, rootarg+5);
+                               free(rootarg_old);
+                       }
                        pr_info("Adding \"%s\" to Kernel commandline\n", rootarg);
                        globalvar_add_simple("linux.bootargs.bootm.appendroot",
                                             rootarg);


This could work as a hack, but it does seem error-prone.

Kind regards
Fabian

> 
> Cheers,
> Ahmad
> 
> > 
> > Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
> > ---
> >  common/Kconfig         | 13 +++++++++++++
> >  common/block.c         |  3 +--
> >  common/bootm.c         |  8 ++++----
> >  drivers/mci/mci-core.c |  2 +-
> >  fs/9p/vfs_super.c      |  2 +-
> >  fs/nfs.c               |  2 +-
> >  fs/squashfs/squashfs.c |  2 +-
> >  fs/ubifs/ubifs.c       |  2 +-
> >  8 files changed, 23 insertions(+), 11 deletions(-)
> > 
> > diff --git a/common/Kconfig b/common/Kconfig
> > index d923d4c4b6..62797a9e69 100644
> > --- a/common/Kconfig
> > +++ b/common/Kconfig
> > @@ -1252,6 +1252,19 @@ config SERIAL_NUMBER_FIXUP_SYSTEMD_HOSTNAME
> >  	  This option without effect if global.bootm.provide_hostname
> >  	  is unset.
> >  
> > +config ROOT_COMMANDLINE_PARAMETER
> > +	string "parameter name for root partition"
> > +	default "root"
> > +	help
> > +	  When setting the root partition on the commandline string to the os, use
> > +	  this name as an indicator of the root partition.
> > +
> > +	  Changing this could be useful in verified boot contexts to not give the
> > +	  kernel the chance to boot a non-secure image, but still use the power of
> > +	  barebox to get the right disk for the rootfs.
> > +
> > +	  If unsure, leave as default (root)
> > +
> >  config SYSTEMD_OF_WATCHDOG
> >  	bool "inform devicetree-enabled kernel of used watchdog"
> >  	depends on WATCHDOG && OFTREE && FLEXIBLE_BOOTARGS
> > diff --git a/common/block.c b/common/block.c
> > index ca2ed37dbd..bb8b01c0a0 100644
> > --- a/common/block.c
> > +++ b/common/block.c
> > @@ -601,11 +601,10 @@ char *cdev_get_linux_rootarg(const struct cdev *partcdev)
> >  	if (blk->ops->get_rootarg)
> >  		rootarg = blk->ops->get_rootarg(blk, partcdev);
> >  	if (!rootarg && partcdev->partuuid[0] != 0)
> > -		rootarg = basprintf("root=PARTUUID=%s", partcdev->partuuid);
> > +		rootarg = basprintf(CONFIG_ROOT_COMMANDLINE_PARAMETER "=PARTUUID=%s", partcdev->partuuid);
> >  
> >  	if (IS_ENABLED(CONFIG_ROOTWAIT_BOOTARG) && blk->rootwait)
> >  		rootarg = linux_bootargs_append_rootwait(rootarg);
> >  
> >  	return rootarg;
> >  }
> > -
> > diff --git a/common/bootm.c b/common/bootm.c
> > index 17792b2a1d..4549bfeb8b 100644
> > --- a/common/bootm.c
> > +++ b/common/bootm.c
> > @@ -852,10 +852,10 @@ int bootm_boot(struct bootm_data *bootm_data)
> >  				rootarg = ERR_PTR(-EINVAL);
> >  
> >  				if (!root_cdev)
> > -					pr_err("no cdev found for %s, cannot set root= option\n",
> > +					pr_err("no cdev found for %s, cannot set "
> > CONFIG_ROOT_COMMANDLINE_PARAMETER "= option\n",
> >  						root_dev_name);
> >  				else if (!root_cdev->partuuid[0])
> > -					pr_err("%s doesn't have a PARTUUID, cannot set root= option\n",
> > +					pr_err("%s doesn't have a PARTUUID, cannot set "
> > CONFIG_ROOT_COMMANDLINE_PARAMETER "= option\n",
> >  						root_dev_name);
> >  			}
> >  
> > @@ -866,7 +866,7 @@ int bootm_boot(struct bootm_data *bootm_data)
> >  		}
> >  
> >  		if (IS_ERR(rootarg)) {
> > -			pr_err("Failed to append kernel cmdline parameter 'root='\n");
> > +			pr_err("Failed to append kernel cmdline parameter '" CONFIG_ROOT_COMMANDLINE_PARAMETER
> > "='\n");
> >  		} else {
> >  			pr_info("Adding \"%s\" to Kernel commandline\n", rootarg);
> >  			globalvar_add_simple("linux.bootargs.bootm.appendroot",
> > @@ -1165,7 +1165,7 @@ BAREBOX_MAGICVAR(global.bootm.dryrun, "bootm default dryrun level");
> >  BAREBOX_MAGICVAR(global.bootm.verify, "bootm default verify level");
> >  BAREBOX_MAGICVAR(global.bootm.verbose, "bootm default verbosity level (0=quiet)");
> >  BAREBOX_MAGICVAR(global.bootm.earlycon, "Add earlycon option to Kernel for early log output");
> > -BAREBOX_MAGICVAR(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(global.bootm.appendroot, "Add " CONFIG_ROOT_COMMANDLINE_PARAMETER "= 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(global.bootm.root_dev, "bootm default root device (overrides default device in
> > global.bootm.appendroot)");
> >  BAREBOX_MAGICVAR(global.bootm.provide_machine_id, "If true, append systemd.machine_id=$global.machine_id to Kernel
> > command line");
> >  BAREBOX_MAGICVAR(global.bootm.provide_hostname, "If true, append systemd.hostname=$global.hostname to Kernel
> > command line");
> > diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
> > index 57825bc849..79cebe19f3 100644
> > --- a/drivers/mci/mci-core.c
> > +++ b/drivers/mci/mci-core.c
> > @@ -2691,7 +2691,7 @@ static char *mci_get_linux_mmcblkdev(struct block_device *blk,
> >  		 * skipping it.
> >  		 */
> >  		if (cdev_partname_equal(partcdev, cdev))
> > -			return basprintf("root=/dev/mmcblk%dp%d", id, partnum);
> > +			return basprintf(CONFIG_ROOT_COMMANDLINE_PARAMETER "=/dev/mmcblk%dp%d", id, partnum);
> >  		if (cdev->flags & DEVFS_PARTITION_FROM_TABLE)
> >  			partnum++;
> >  	}
> > diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
> > index 6a451d9ef5..39a8529a4e 100644
> > --- a/fs/9p/vfs_super.c
> > +++ b/fs/9p/vfs_super.c
> > @@ -70,7 +70,7 @@ static void v9fs_set_rootarg(struct v9fs_session_info *v9ses,
> >  	trans = v9ses->clnt->trans_mod->name;
> >  	path = v9ses->aname;
> >  
> > -	str = basprintf("root=%s rootfstype=9p rootflags=trans=%s,msize=%d,"
> > +	str = basprintf(CONFIG_ROOT_COMMANDLINE_PARAMETER "=%s rootfstype=9p rootflags=trans=%s,msize=%d,"
> >  			"cache=loose,uname=%s,dfltuid=0,dfltgid=0,aname=%s",
> >  			tag, trans, v9ses->clnt->msize, tag, path);
> >  
> > diff --git a/fs/nfs.c b/fs/nfs.c
> > index 5c2476cd88..9db23c5d18 100644
> > --- a/fs/nfs.c
> > +++ b/fs/nfs.c
> > @@ -1558,7 +1558,7 @@ static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device *fsdev)
> >  	char *str, *tmp;
> >  	const char *bootargs;
> >  
> > -	str = basprintf("root=/dev/nfs nfsroot=%pI4:%s%s%s", &npriv->server, npriv->path,
> > +	str = basprintf(CONFIG_ROOT_COMMANDLINE_PARAMETER "=/dev/nfs nfsroot=%pI4:%s%s%s", &npriv->server, npriv-
> > >path,
> >  			  rootnfsopts[0] ? "," : "", rootnfsopts);
> >  
> >  	/* forward specific mount options on demand */
> > diff --git a/fs/squashfs/squashfs.c b/fs/squashfs/squashfs.c
> > index e30372627a..8267e3cba0 100644
> > --- a/fs/squashfs/squashfs.c
> > +++ b/fs/squashfs/squashfs.c
> > @@ -60,7 +60,7 @@ static void squashfs_set_rootarg(struct fs_device *fsdev)
> >  	ubi_get_device_info(vi.ubi_num, &di);
> >  	mtd = di.mtd;
> >  
> > -	str = basprintf("root=/dev/ubiblock%d_%d ubi.mtd=%s ubi.block=%d,%d rootfstype=squashfs",
> > +	str = basprintf(CONFIG_ROOT_COMMANDLINE_PARAMETER "=/dev/ubiblock%d_%d ubi.mtd=%s ubi.block=%d,%d
> > rootfstype=squashfs",
> >  			vi.ubi_num, vi.vol_id, mtd->cdev.partname, vi.ubi_num, vi.vol_id);
> >  
> >  	fsdev_set_linux_rootarg(fsdev, str);
> > diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
> > index 37986acbb2..34151a0c9f 100644
> > --- a/fs/ubifs/ubifs.c
> > +++ b/fs/ubifs/ubifs.c
> > @@ -442,7 +442,7 @@ static void ubifs_set_rootarg(struct ubifs_priv *priv,
> >  
> >  	mtd = di.mtd;
> >  
> > -	str = basprintf("root=ubi0:%s ubi.mtd=%s rootfstype=ubifs",
> > +	str = basprintf(CONFIG_ROOT_COMMANDLINE_PARAMETER "=ubi0:%s ubi.mtd=%s rootfstype=ubifs",
> >  			  vi.name, mtd->cdev.partname);
> >  
> >  	fsdev_set_linux_rootarg(fsdev, str);



^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH] common: setting the root= command line parameter
  2025-11-25 10:22   ` Fabian Pflug
@ 2025-11-25 19:13     ` Ahmad Fatoum
  0 siblings, 0 replies; 41+ messages in thread
From: Ahmad Fatoum @ 2025-11-25 19:13 UTC (permalink / raw)
  To: Fabian Pflug, barebox

Hi,

On 11/25/25 11:22 AM, Fabian Pflug wrote:
> Hey :)
> 
> On Mon, 2025-11-24 at 13:00 +0100, Ahmad Fatoum wrote:
>> Hi Fabian,
>>
>> On 11/24/25 11:16 AM, Fabian Pflug wrote:
>>> In verified boot settings, it might not be wanted to have a root=
>>> command line parameter for the kernel, because if the initramfs is not
>>> configured, or barebox boots the kernel directly due to
>>> misconfiguration, the device might boot correctly, but without verified
>>> boot, because the kernel will parse root=
>>>
>>> Allowing to change the parameter name will help circumvent such errors,
>>> as there now needs to be multiple misconfigurations for the verified
>>> boot to go wrong and the initramfs can use a the different name from the
>>> commandline to get the rootfs.
>>
>> Thanks for your patch!
>>
>> This is a useful thing to have, but I think deciding replacement of
>> root= across all functionality at compile-time is too invasive:
>>
>> Imagine you use the same barebox both for development and in release
>> mode (or you support runtime unlocking with a token).
>> When booting securely, you want to use verity_root= for example, but
>> when you do boot /mnt/nfs, you'll want barebox to fix up root= as before.
>>
>> I thus think that this should be a $global.bootm.root_arg evaluated at
>> runtime instead.
>>
>> By adding it to bootm_data_restore_defaults(), its value will then be
>> restored after the boot script has done executing.
>>
>> What do you think?
> 
> 
> Do you want to have string-replacement in bootm, or should all of them query the value for root_arg?
> 
> Are you thinking something along the lines of:
> 
> --- a/common/bootm.c
> +++ b/common/bootm.c
> @@ -868,6 +868,11 @@ int bootm_boot(struct bootm_data *bootm_data)
>                 if (IS_ERR(rootarg)) {
>                         pr_err("Failed to append kernel cmdline parameter 'root='\n");
>                 } else {
> +                       if (bootm_data->prefix_root) {
> +                               char* rootarg_old = rootarg;
> +                               rootarg = xasprintf("%s%s",bootm_data->prefix_root, rootarg+5);
> +                               free(rootarg_old);
> +                       }
>                         pr_info("Adding \"%s\" to Kernel commandline\n", rootarg);
>                         globalvar_add_simple("linux.bootargs.bootm.appendroot",
>                                              rootarg);
> 
> 
> This could work as a hack, but it does seem error-prone.

I'd rather not rely on root= being at the beginning. Otherwise, there is
little robustness benefit over:

  $ devlookup -k -v ROOT /dev/mmc0.root-A
  $ global linux.bootargs.root=verity_${ROOT}

As discussed off-list, given that there is no simple way to retrofit it,
the API should be adapted, so file systems and cdevs report the root=
and the opts separately and it's then up to the consumer how to
concatenate them.

Cheers,
Ahmad

> 
> Kind regards
> Fabian
> 
>>
>> Cheers,
>> Ahmad
>>
>>>
>>> Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
>>> ---
>>>  common/Kconfig         | 13 +++++++++++++
>>>  common/block.c         |  3 +--
>>>  common/bootm.c         |  8 ++++----
>>>  drivers/mci/mci-core.c |  2 +-
>>>  fs/9p/vfs_super.c      |  2 +-
>>>  fs/nfs.c               |  2 +-
>>>  fs/squashfs/squashfs.c |  2 +-
>>>  fs/ubifs/ubifs.c       |  2 +-
>>>  8 files changed, 23 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/common/Kconfig b/common/Kconfig
>>> index d923d4c4b6..62797a9e69 100644
>>> --- a/common/Kconfig
>>> +++ b/common/Kconfig
>>> @@ -1252,6 +1252,19 @@ config SERIAL_NUMBER_FIXUP_SYSTEMD_HOSTNAME
>>>  	  This option without effect if global.bootm.provide_hostname
>>>  	  is unset.
>>>  
>>> +config ROOT_COMMANDLINE_PARAMETER
>>> +	string "parameter name for root partition"
>>> +	default "root"
>>> +	help
>>> +	  When setting the root partition on the commandline string to the os, use
>>> +	  this name as an indicator of the root partition.
>>> +
>>> +	  Changing this could be useful in verified boot contexts to not give the
>>> +	  kernel the chance to boot a non-secure image, but still use the power of
>>> +	  barebox to get the right disk for the rootfs.
>>> +
>>> +	  If unsure, leave as default (root)
>>> +
>>>  config SYSTEMD_OF_WATCHDOG
>>>  	bool "inform devicetree-enabled kernel of used watchdog"
>>>  	depends on WATCHDOG && OFTREE && FLEXIBLE_BOOTARGS
>>> diff --git a/common/block.c b/common/block.c
>>> index ca2ed37dbd..bb8b01c0a0 100644
>>> --- a/common/block.c
>>> +++ b/common/block.c
>>> @@ -601,11 +601,10 @@ char *cdev_get_linux_rootarg(const struct cdev *partcdev)
>>>  	if (blk->ops->get_rootarg)
>>>  		rootarg = blk->ops->get_rootarg(blk, partcdev);
>>>  	if (!rootarg && partcdev->partuuid[0] != 0)
>>> -		rootarg = basprintf("root=PARTUUID=%s", partcdev->partuuid);
>>> +		rootarg = basprintf(CONFIG_ROOT_COMMANDLINE_PARAMETER "=PARTUUID=%s", partcdev->partuuid);
>>>  
>>>  	if (IS_ENABLED(CONFIG_ROOTWAIT_BOOTARG) && blk->rootwait)
>>>  		rootarg = linux_bootargs_append_rootwait(rootarg);
>>>  
>>>  	return rootarg;
>>>  }
>>> -
>>> diff --git a/common/bootm.c b/common/bootm.c
>>> index 17792b2a1d..4549bfeb8b 100644
>>> --- a/common/bootm.c
>>> +++ b/common/bootm.c
>>> @@ -852,10 +852,10 @@ int bootm_boot(struct bootm_data *bootm_data)
>>>  				rootarg = ERR_PTR(-EINVAL);
>>>  
>>>  				if (!root_cdev)
>>> -					pr_err("no cdev found for %s, cannot set root= option\n",
>>> +					pr_err("no cdev found for %s, cannot set "
>>> CONFIG_ROOT_COMMANDLINE_PARAMETER "= option\n",
>>>  						root_dev_name);
>>>  				else if (!root_cdev->partuuid[0])
>>> -					pr_err("%s doesn't have a PARTUUID, cannot set root= option\n",
>>> +					pr_err("%s doesn't have a PARTUUID, cannot set "
>>> CONFIG_ROOT_COMMANDLINE_PARAMETER "= option\n",
>>>  						root_dev_name);
>>>  			}
>>>  
>>> @@ -866,7 +866,7 @@ int bootm_boot(struct bootm_data *bootm_data)
>>>  		}
>>>  
>>>  		if (IS_ERR(rootarg)) {
>>> -			pr_err("Failed to append kernel cmdline parameter 'root='\n");
>>> +			pr_err("Failed to append kernel cmdline parameter '" CONFIG_ROOT_COMMANDLINE_PARAMETER
>>> "='\n");
>>>  		} else {
>>>  			pr_info("Adding \"%s\" to Kernel commandline\n", rootarg);
>>>  			globalvar_add_simple("linux.bootargs.bootm.appendroot",
>>> @@ -1165,7 +1165,7 @@ BAREBOX_MAGICVAR(global.bootm.dryrun, "bootm default dryrun level");
>>>  BAREBOX_MAGICVAR(global.bootm.verify, "bootm default verify level");
>>>  BAREBOX_MAGICVAR(global.bootm.verbose, "bootm default verbosity level (0=quiet)");
>>>  BAREBOX_MAGICVAR(global.bootm.earlycon, "Add earlycon option to Kernel for early log output");
>>> -BAREBOX_MAGICVAR(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(global.bootm.appendroot, "Add " CONFIG_ROOT_COMMANDLINE_PARAMETER "= 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(global.bootm.root_dev, "bootm default root device (overrides default device in
>>> global.bootm.appendroot)");
>>>  BAREBOX_MAGICVAR(global.bootm.provide_machine_id, "If true, append systemd.machine_id=$global.machine_id to Kernel
>>> command line");
>>>  BAREBOX_MAGICVAR(global.bootm.provide_hostname, "If true, append systemd.hostname=$global.hostname to Kernel
>>> command line");
>>> diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
>>> index 57825bc849..79cebe19f3 100644
>>> --- a/drivers/mci/mci-core.c
>>> +++ b/drivers/mci/mci-core.c
>>> @@ -2691,7 +2691,7 @@ static char *mci_get_linux_mmcblkdev(struct block_device *blk,
>>>  		 * skipping it.
>>>  		 */
>>>  		if (cdev_partname_equal(partcdev, cdev))
>>> -			return basprintf("root=/dev/mmcblk%dp%d", id, partnum);
>>> +			return basprintf(CONFIG_ROOT_COMMANDLINE_PARAMETER "=/dev/mmcblk%dp%d", id, partnum);
>>>  		if (cdev->flags & DEVFS_PARTITION_FROM_TABLE)
>>>  			partnum++;
>>>  	}
>>> diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
>>> index 6a451d9ef5..39a8529a4e 100644
>>> --- a/fs/9p/vfs_super.c
>>> +++ b/fs/9p/vfs_super.c
>>> @@ -70,7 +70,7 @@ static void v9fs_set_rootarg(struct v9fs_session_info *v9ses,
>>>  	trans = v9ses->clnt->trans_mod->name;
>>>  	path = v9ses->aname;
>>>  
>>> -	str = basprintf("root=%s rootfstype=9p rootflags=trans=%s,msize=%d,"
>>> +	str = basprintf(CONFIG_ROOT_COMMANDLINE_PARAMETER "=%s rootfstype=9p rootflags=trans=%s,msize=%d,"
>>>  			"cache=loose,uname=%s,dfltuid=0,dfltgid=0,aname=%s",
>>>  			tag, trans, v9ses->clnt->msize, tag, path);
>>>  
>>> diff --git a/fs/nfs.c b/fs/nfs.c
>>> index 5c2476cd88..9db23c5d18 100644
>>> --- a/fs/nfs.c
>>> +++ b/fs/nfs.c
>>> @@ -1558,7 +1558,7 @@ static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device *fsdev)
>>>  	char *str, *tmp;
>>>  	const char *bootargs;
>>>  
>>> -	str = basprintf("root=/dev/nfs nfsroot=%pI4:%s%s%s", &npriv->server, npriv->path,
>>> +	str = basprintf(CONFIG_ROOT_COMMANDLINE_PARAMETER "=/dev/nfs nfsroot=%pI4:%s%s%s", &npriv->server, npriv-
>>>> path,
>>>  			  rootnfsopts[0] ? "," : "", rootnfsopts);
>>>  
>>>  	/* forward specific mount options on demand */
>>> diff --git a/fs/squashfs/squashfs.c b/fs/squashfs/squashfs.c
>>> index e30372627a..8267e3cba0 100644
>>> --- a/fs/squashfs/squashfs.c
>>> +++ b/fs/squashfs/squashfs.c
>>> @@ -60,7 +60,7 @@ static void squashfs_set_rootarg(struct fs_device *fsdev)
>>>  	ubi_get_device_info(vi.ubi_num, &di);
>>>  	mtd = di.mtd;
>>>  
>>> -	str = basprintf("root=/dev/ubiblock%d_%d ubi.mtd=%s ubi.block=%d,%d rootfstype=squashfs",
>>> +	str = basprintf(CONFIG_ROOT_COMMANDLINE_PARAMETER "=/dev/ubiblock%d_%d ubi.mtd=%s ubi.block=%d,%d
>>> rootfstype=squashfs",
>>>  			vi.ubi_num, vi.vol_id, mtd->cdev.partname, vi.ubi_num, vi.vol_id);
>>>  
>>>  	fsdev_set_linux_rootarg(fsdev, str);
>>> diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
>>> index 37986acbb2..34151a0c9f 100644
>>> --- a/fs/ubifs/ubifs.c
>>> +++ b/fs/ubifs/ubifs.c
>>> @@ -442,7 +442,7 @@ static void ubifs_set_rootarg(struct ubifs_priv *priv,
>>>  
>>>  	mtd = di.mtd;
>>>  
>>> -	str = basprintf("root=ubi0:%s ubi.mtd=%s rootfstype=ubifs",
>>> +	str = basprintf(CONFIG_ROOT_COMMANDLINE_PARAMETER "=ubi0:%s ubi.mtd=%s rootfstype=ubifs",
>>>  			  vi.name, mtd->cdev.partname);
>>>  
>>>  	fsdev_set_linux_rootarg(fsdev, str);
> 

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |




^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH 0/4] make the root= command line parameter variable
  2025-11-24 12:00 ` Ahmad Fatoum
  2025-11-25 10:22   ` Fabian Pflug
@ 2025-11-26  6:42   ` Fabian Pflug
  2025-11-26  6:42     ` [PATCH 1/4] block.h: renamed get_rootargs to get_root Fabian Pflug
                       ` (4 more replies)
  1 sibling, 5 replies; 41+ messages in thread
From: Fabian Pflug @ 2025-11-26  6:42 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug

This patchset introduces the bootm.root_arg variable. A dynamic way of
setting the root argument in fit image boot contexts, defaulting to
root, resulting in root=/dev/... during kernel boot, but allowing for
overwrites like verity_fs=/dev/..., which can be parsed by the
initramfs, but will not be parsed by the kernel, resulting in robuster
secure boot contexts, where the kernel does not accidental due to
misconfiguration mount the rootfs instead of the initramfs, resulting in
a non-verified boot.

Fabian Pflug (4):
  block.h: renamed get_rootargs to get_root
  fs: split rootargs into root and options
  bootm: use new api to get kernel command line params
  bootm: introduce bootm.root_arg variable

 common/block.c         | 36 ++++++++++++++++++--------
 common/bootm.c         | 38 +++++++++++++++++-----------
 drivers/mci/mci-core.c |  4 +--
 fs/9p/vfs_super.c      |  6 ++---
 fs/fs.c                | 57 +++++++++++++++++++++++++++++++-----------
 fs/nfs.c               |  4 +--
 fs/squashfs/squashfs.c | 13 ++++++----
 fs/ubifs/ubifs.c       | 12 +++++----
 include/block.h        |  8 +++++-
 include/bootm.h        |  1 +
 include/fs.h           |  6 +++--
 11 files changed, 126 insertions(+), 59 deletions(-)

-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH 1/4] block.h: renamed get_rootargs to get_root
  2025-11-26  6:42   ` [PATCH 0/4] make the root= command line parameter variable Fabian Pflug
@ 2025-11-26  6:42     ` Fabian Pflug
  2025-11-26  9:50       ` Ahmad Fatoum
  2025-11-26  6:42     ` [PATCH 2/4] fs: split rootargs into root and options Fabian Pflug
                       ` (3 subsequent siblings)
  4 siblings, 1 reply; 41+ messages in thread
From: Fabian Pflug @ 2025-11-26  6:42 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug

Don't return the full commandline-parameter, but instead just return the
root block/fs/etc. The functions downstream can add root= before.

This is the first commit in a series to make root= dynamic.

Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
---
 common/block.c         | 10 ++++++++--
 drivers/mci/mci-core.c |  4 ++--
 include/block.h        |  2 +-
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/common/block.c b/common/block.c
index ca2ed37dbd..ce3aee49b4 100644
--- a/common/block.c
+++ b/common/block.c
@@ -589,6 +589,7 @@ char *cdev_get_linux_rootarg(const struct cdev *partcdev)
 	const struct cdev *cdevm;
 	struct block_device *blk;
 	char *rootarg = NULL;
+	char* root = NULL;
 
 	if (!partcdev)
 		return NULL;
@@ -598,8 +599,13 @@ char *cdev_get_linux_rootarg(const struct cdev *partcdev)
 	if (!blk)
 		return NULL;
 
-	if (blk->ops->get_rootarg)
-		rootarg = blk->ops->get_rootarg(blk, partcdev);
+	if (blk->ops->get_root) {
+		root = blk->ops->get_root(blk, partcdev);
+		if(root) {
+			rootarg = basprintf("root=%s", root);
+			free(root);
+		}
+	}
 	if (!rootarg && partcdev->partuuid[0] != 0)
 		rootarg = basprintf("root=PARTUUID=%s", partcdev->partuuid);
 
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 57825bc849..206147cb93 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -2691,7 +2691,7 @@ static char *mci_get_linux_mmcblkdev(struct block_device *blk,
 		 * skipping it.
 		 */
 		if (cdev_partname_equal(partcdev, cdev))
-			return basprintf("root=/dev/mmcblk%dp%d", id, partnum);
+			return basprintf("/dev/mmcblk%dp%d", id, partnum);
 		if (cdev->flags & DEVFS_PARTITION_FROM_TABLE)
 			partnum++;
 	}
@@ -2703,7 +2703,7 @@ static struct block_device_ops mci_ops = {
 	.read = mci_sd_read,
 	.write = IS_ENABLED(CONFIG_MCI_WRITE) ? mci_sd_write : NULL,
 	.erase = IS_ENABLED(CONFIG_MCI_ERASE) ? mci_sd_erase : NULL,
-	.get_rootarg = IS_ENABLED(CONFIG_MMCBLKDEV_ROOTARG) ?
+	.get_root = IS_ENABLED(CONFIG_MMCBLKDEV_ROOTARG) ?
 		mci_get_linux_mmcblkdev : NULL,
 };
 
diff --git a/include/block.h b/include/block.h
index fc7a0a32fb..b277f590e4 100644
--- a/include/block.h
+++ b/include/block.h
@@ -14,7 +14,7 @@ struct block_device_ops {
 	int (*write)(struct block_device *, const void *buf, sector_t block, blkcnt_t num_blocks);
 	int (*erase)(struct block_device *blk, sector_t block, blkcnt_t num_blocks);
 	int (*flush)(struct block_device *);
-	char *(*get_rootarg)(struct block_device *blk, const struct cdev *partcdev);
+	char *(*get_root)(struct block_device *blk, const struct cdev *partcdev);
 };
 
 struct chunk;
-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH 2/4] fs: split rootargs into root and options
  2025-11-26  6:42   ` [PATCH 0/4] make the root= command line parameter variable Fabian Pflug
  2025-11-26  6:42     ` [PATCH 1/4] block.h: renamed get_rootargs to get_root Fabian Pflug
@ 2025-11-26  6:42     ` Fabian Pflug
  2025-11-26 10:13       ` Ahmad Fatoum
  2025-11-26 10:31       ` Ahmad Fatoum
  2025-11-26  6:42     ` [PATCH 3/4] bootm: use new api to get kernel command line params Fabian Pflug
                       ` (2 subsequent siblings)
  4 siblings, 2 replies; 41+ messages in thread
From: Fabian Pflug @ 2025-11-26  6:42 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug

The rootargs argument (root=/dev/etc rootwait) can be split into the
root and options parts, which makes it easier to manipulate them both
independently. This changes tries to be as backward compatible as
possible and does not change the behaviour of the get functions, but
introduces new ones to get both items seperatly.

Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
---
 common/block.c         | 42 ++++++++++++++++++-------------
 fs/9p/vfs_super.c      |  6 ++---
 fs/fs.c                | 57 +++++++++++++++++++++++++++++++-----------
 fs/nfs.c               |  4 +--
 fs/squashfs/squashfs.c | 13 ++++++----
 fs/ubifs/ubifs.c       | 12 +++++----
 include/block.h        |  6 +++++
 include/fs.h           |  6 +++--
 8 files changed, 98 insertions(+), 48 deletions(-)

diff --git a/common/block.c b/common/block.c
index ce3aee49b4..35e90dc4a6 100644
--- a/common/block.c
+++ b/common/block.c
@@ -584,34 +584,42 @@ const char *blk_type_str(enum blk_type type)
 	}
 }
 
-char *cdev_get_linux_rootarg(const struct cdev *partcdev)
-{
+void cdev_get_linux_root_and_opts(const struct cdev *partcdev, char** root, char** rootopts) {
+
 	const struct cdev *cdevm;
 	struct block_device *blk;
-	char *rootarg = NULL;
-	char* root = NULL;
+
+	*root = NULL;
+	*rootopts = NULL;
 
 	if (!partcdev)
-		return NULL;
+		return;
 
 	cdevm = partcdev->master ?: partcdev;
 	blk = cdev_get_block_device(cdevm);
 	if (!blk)
-		return NULL;
+		return;
 
-	if (blk->ops->get_root) {
-		root = blk->ops->get_root(blk, partcdev);
-		if(root) {
-			rootarg = basprintf("root=%s", root);
-			free(root);
-		}
-	}
-	if (!rootarg && partcdev->partuuid[0] != 0)
-		rootarg = basprintf("root=PARTUUID=%s", partcdev->partuuid);
+	if (blk->ops->get_root)
+		*root = blk->ops->get_root(blk, partcdev);
+	if (!*root && partcdev->partuuid[0] != 0)
+		*root = basprintf("PARTUUID=%s", partcdev->partuuid);
 
 	if (IS_ENABLED(CONFIG_ROOTWAIT_BOOTARG) && blk->rootwait)
-		rootarg = linux_bootargs_append_rootwait(rootarg);
+		*rootopts = xasprintf("rootwait=%d", linux_rootwait_secs);
 
-	return rootarg;
+	return;
 }
 
+char *cdev_get_linux_rootarg(const struct cdev *partcdev)
+{
+	char* root;
+	char* rootopts;
+
+	cdev_get_linux_root_and_opts(partcdev, &root, &rootopts);
+	if(!root)
+		return NULL;
+	if(rootopts)
+		return xasprintf("root=%s %s", root, rootopts);
+	return xasprintf("root=%s", root);
+}
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
index 6a451d9ef5..efc9a9193d 100644
--- a/fs/9p/vfs_super.c
+++ b/fs/9p/vfs_super.c
@@ -70,11 +70,11 @@ static void v9fs_set_rootarg(struct v9fs_session_info *v9ses,
 	trans = v9ses->clnt->trans_mod->name;
 	path = v9ses->aname;
 
-	str = basprintf("root=%s rootfstype=9p rootflags=trans=%s,msize=%d,"
+	str = basprintf("rootfstype=9p rootflags=trans=%s,msize=%d,"
 			"cache=loose,uname=%s,dfltuid=0,dfltgid=0,aname=%s",
-			tag, trans, v9ses->clnt->msize, tag, path);
+			trans, v9ses->clnt->msize, tag, path);
 
-	fsdev_set_linux_rootarg(fsdev, str);
+	fsdev_set_linux_root_options(fsdev, tag, str);
 
 	free(str);
 }
diff --git a/fs/fs.c b/fs/fs.c
index 528299e039..c4f805d308 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -1226,12 +1226,26 @@ void mount_all(void)
 	}
 }
 
-void fsdev_set_linux_rootarg(struct fs_device *fsdev, const char *str)
+void fsdev_set_linux_root_options(struct fs_device *fsdev, const char *root, const char *rootopts)
 {
-	fsdev->linux_rootarg = xstrdup(str);
+	fsdev->linux_root = xstrdup(root);
+	fsdev->linux_rootopts = xstrdup(rootopts);
 
-	dev_add_param_fixed(&fsdev->dev, "linux.bootargs",
-			    "%s", fsdev->linux_rootarg);
+	dev_add_param_fixed(&fsdev->dev, "linux.bootargs.root",
+			    "%s", fsdev->linux_root);
+	dev_add_param_fixed(&fsdev->dev, "linux.bootargs.rootopts",
+			    "%s", fsdev->linux_rootopts);
+}
+
+void fsdev_get_linux_root_options(struct fs_device *fsdev, char **root, char **rootopts)
+{
+	if(fsdev) {
+		*root = dev_get_param(&fsdev->dev, "linux.bootargs.root");
+		*rootopts = dev_get_param(&fsdev->dev, "linux.bootargs.rootopts");
+	} else {
+		*root = NULL;
+		*rootopts = NULL;
+	}
 }
 
 /**
@@ -1245,17 +1259,27 @@ void fsdev_set_linux_rootarg(struct fs_device *fsdev, const char *str)
 char *path_get_linux_rootarg(const char *path)
 {
 	struct fs_device *fsdev;
-	const char *str;
+	char *root;
+	char *rootopts;
+	char *rootarg;
 
 	fsdev = get_fsdevice_by_path(AT_FDCWD, path);
 	if (!fsdev)
 		return ERR_PTR(-EINVAL);
 
-	str = dev_get_param(&fsdev->dev, "linux.bootargs");
-	if (!str)
-		return ERR_PTR(-ENOSYS);
+	fsdev_get_linux_root_options(fsdev, &root, &rootopts);
 
-	return xstrdup(str);
+	if(!root)
+		return ERR_PTR(-EINVAL);
+
+	if(rootopts) {
+		rootarg = xasprintf("root=%s %s", root, rootopts);
+		free(rootopts);
+	} else {
+		rootarg = xasprintf("root=%s", root);
+	}
+	free(root);
+	return rootarg;
 }
 
 /**
@@ -3249,12 +3273,17 @@ int mount(const char *device, const char *fsname, const char *pathname,
 
 	fsdev->vfsmount.mnt_root = fsdev->sb.s_root;
 
-	if (!fsdev->linux_rootarg) {
-		char *str;
+	if (!fsdev->linux_root) {
+		char *root;
+		char *rootopts;
 
-		str = cdev_get_linux_rootarg(fsdev->cdev);
-		if (str)
-			fsdev_set_linux_rootarg(fsdev, str);
+		cdev_get_linux_root_and_opts(fsdev->cdev, &root, &rootopts);
+		if (root) {
+			fsdev_set_linux_root_options(fsdev, root, rootopts);
+			free(root);
+			if(rootopts)
+				free(rootopts);
+		}
 	}
 
 	path_put(&path);
diff --git a/fs/nfs.c b/fs/nfs.c
index 5c2476cd88..0b40c56ff3 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -1558,7 +1558,7 @@ static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device *fsdev)
 	char *str, *tmp;
 	const char *bootargs;
 
-	str = basprintf("root=/dev/nfs nfsroot=%pI4:%s%s%s", &npriv->server, npriv->path,
+	str = basprintf("nfsroot=%pI4:%s%s%s", &npriv->server, npriv->path,
 			  rootnfsopts[0] ? "," : "", rootnfsopts);
 
 	/* forward specific mount options on demand */
@@ -1584,7 +1584,7 @@ static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device *fsdev)
 	if (IS_ENABLED(CONFIG_ROOTWAIT_BOOTARG))
 		str = linux_bootargs_append_rootwait(str);
 
-	fsdev_set_linux_rootarg(fsdev, str);
+	fsdev_set_linux_root_options(fsdev, "/dev/nfs", str);
 
 	free(str);
 }
diff --git a/fs/squashfs/squashfs.c b/fs/squashfs/squashfs.c
index e30372627a..365aa1f219 100644
--- a/fs/squashfs/squashfs.c
+++ b/fs/squashfs/squashfs.c
@@ -46,7 +46,8 @@ static void squashfs_set_rootarg(struct fs_device *fsdev)
 	struct ubi_volume_info vi = {};
 	struct ubi_device_info di = {};
 	struct mtd_info *mtd;
-	char *str;
+	char *root;
+	char *rootopts;
 
 	if (!IS_ENABLED(CONFIG_MTD_UBI))
 		return;
@@ -60,12 +61,14 @@ static void squashfs_set_rootarg(struct fs_device *fsdev)
 	ubi_get_device_info(vi.ubi_num, &di);
 	mtd = di.mtd;
 
-	str = basprintf("root=/dev/ubiblock%d_%d ubi.mtd=%s ubi.block=%d,%d rootfstype=squashfs",
-			vi.ubi_num, vi.vol_id, mtd->cdev.partname, vi.ubi_num, vi.vol_id);
+	root = basprintf("/dev/ubiblock%d_%d", vi.ubi_num, vi.vol_id);
+	rootopts = basprintf("ubi.mtd=%s ubi.block=%d,%d rootfstype=squashfs",
+			mtd->cdev.partname, vi.ubi_num, vi.vol_id);
 
-	fsdev_set_linux_rootarg(fsdev, str);
+	fsdev_set_linux_root_options(fsdev, root, rootopts);
 
-	free(str);
+	free(root);
+	free(rootopts);
 }
 
 static struct inode *squashfs_alloc_inode(struct super_block *sb)
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 37986acbb2..9cc35fa273 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -435,19 +435,21 @@ static void ubifs_set_rootarg(struct ubifs_priv *priv,
 	struct ubi_volume_info vi = {};
 	struct ubi_device_info di = {};
 	struct mtd_info *mtd;
-	char *str;
+	char *root;
+	char *rootopts;
 
 	ubi_get_volume_info(priv->ubi, &vi);
 	ubi_get_device_info(vi.ubi_num, &di);
 
 	mtd = di.mtd;
 
-	str = basprintf("root=ubi0:%s ubi.mtd=%s rootfstype=ubifs",
-			  vi.name, mtd->cdev.partname);
+	root = basprintf("ubi0:%s", vi.name);
+	rootopts = basprintf("ubi.mtd=%s rootfstype=ubifs", mtd->cdev.partname);
 
-	fsdev_set_linux_rootarg(fsdev, str);
+	fsdev_set_linux_root_options(fsdev, root, rootopts);
 
-	free(str);
+	free(root);
+	free(rootopts);
 }
 
 static int ubifs_probe(struct device *dev)
diff --git a/include/block.h b/include/block.h
index b277f590e4..ddab8bfe60 100644
--- a/include/block.h
+++ b/include/block.h
@@ -85,6 +85,7 @@ static inline int block_flush(struct block_device *blk)
 #ifdef CONFIG_BLOCK
 unsigned file_list_add_blockdevs(struct file_list *files);
 char *cdev_get_linux_rootarg(const struct cdev *partcdev);
+void cdev_get_linux_root_and_opts(const struct cdev *partcdev, char** root, char** rootopts);
 #else
 static inline unsigned file_list_add_blockdevs(struct file_list *files)
 {
@@ -94,6 +95,11 @@ static inline char *cdev_get_linux_rootarg(const struct cdev *partcdev)
 {
 	return NULL;
 }
+static inline void cdev_get_linux_root_and_opts(const struct cdev *partcdev, char** root, char** rootopts)
+{
+	root = NULL;
+	rootopts = NULL;
+}
 #endif
 
 static inline bool cdev_is_block_device(const struct cdev *cdev)
diff --git a/include/fs.h b/include/fs.h
index 98c482bbf2..c50437d609 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -90,7 +90,8 @@ struct fs_device {
 	char *path;
 	struct list_head list;
 	char *options;
-	char *linux_rootarg;
+	char *linux_root;
+	char *linux_rootopts;
 
 	struct super_block sb;
 
@@ -159,7 +160,8 @@ const char *cdev_mount_default(struct cdev *cdev, const char *fsoptions);
 const char *cdev_mount(struct cdev *cdev);
 void mount_all(void);
 
-void fsdev_set_linux_rootarg(struct fs_device *fsdev, const char *str);
+void fsdev_set_linux_root_options(struct fs_device *fsdev, const char *root, const char* rootopts);
+void fsdev_get_linux_root_options(struct fs_device *fsdev, char **root, char **rootopts);
 char *path_get_linux_rootarg(const char *path);
 
 static inline const char *devpath_to_name(const char *devpath)
-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH 3/4] bootm: use new api to get kernel command line params
  2025-11-26  6:42   ` [PATCH 0/4] make the root= command line parameter variable Fabian Pflug
  2025-11-26  6:42     ` [PATCH 1/4] block.h: renamed get_rootargs to get_root Fabian Pflug
  2025-11-26  6:42     ` [PATCH 2/4] fs: split rootargs into root and options Fabian Pflug
@ 2025-11-26  6:42     ` Fabian Pflug
  2025-11-26 10:25       ` Ahmad Fatoum
  2025-11-26  6:42     ` [PATCH 4/4] bootm: introduce bootm.root_arg variable Fabian Pflug
  2025-11-27 10:57     ` [PATCH v2 0/4] make the root= command line parameter variable Fabian Pflug
  4 siblings, 1 reply; 41+ messages in thread
From: Fabian Pflug @ 2025-11-26  6:42 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug

Getting root device adn root kernel options seperatily any combining
them in this function instead of getting the full string from the helper
functions. This is in preperation for replacing the root= string in the
kernel commandline with something defined during runtime.

Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
---
 common/bootm.c | 34 ++++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 17792b2a1d..5d7dc00e3e 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -4,6 +4,7 @@
 #include <bootm.h>
 #include <bootm-overrides.h>
 #include <fs.h>
+#include <fcntl.h>
 #include <malloc.h>
 #include <memory.h>
 #include <block.h>
@@ -841,33 +842,38 @@ int bootm_boot(struct bootm_data *bootm_data)
 	}
 
 	if (bootm_data->appendroot) {
-		char *rootarg;
+		char *root;
+		char *rootopts;
 
 		if (bootm_data->root_dev) {
 			const char *root_dev_name = devpath_to_name(bootm_data->root_dev);
 			struct cdev *root_cdev = cdev_open_by_name(root_dev_name, O_RDONLY);
 
-			rootarg = cdev_get_linux_rootarg(root_cdev);
-			if (!rootarg) {
-				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);
-			}
+			cdev_get_linux_root_and_opts(root_cdev, &root, &rootopts);
 
 			if (root_cdev)
 				cdev_close(root_cdev);
+			else
+				pr_err("no cdev found for %s, cannot set root= option\n", root_dev_name);
 		} else {
-			rootarg = path_get_linux_rootarg(data->os_file);
+			struct fs_device *fsdev = get_fsdevice_by_path(AT_FDCWD, data->os_file);
+			if(fsdev)
+				fsdev_get_linux_root_options(fsdev, &root, &rootopts);
+			else
+				pr_err("no fsdevice under path: %s\n", data->os_file);
 		}
 
-		if (IS_ERR(rootarg)) {
+		if (!root) {
 			pr_err("Failed to append kernel cmdline parameter 'root='\n");
 		} else {
+			char *rootarg;
+			if(rootopts) {
+				rootarg = xasprintf("root=%s %s", root, rootopts);
+				free(rootopts);
+			} else {
+				rootarg = xasprintf("root=%s", root);
+			}
+			free(root);
 			pr_info("Adding \"%s\" to Kernel commandline\n", rootarg);
 			globalvar_add_simple("linux.bootargs.bootm.appendroot",
 					     rootarg);
-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH 4/4] bootm: introduce bootm.root_arg variable
  2025-11-26  6:42   ` [PATCH 0/4] make the root= command line parameter variable Fabian Pflug
                       ` (2 preceding siblings ...)
  2025-11-26  6:42     ` [PATCH 3/4] bootm: use new api to get kernel command line params Fabian Pflug
@ 2025-11-26  6:42     ` Fabian Pflug
  2025-11-26 10:28       ` Ahmad Fatoum
  2025-11-27 10:57     ` [PATCH v2 0/4] make the root= command line parameter variable Fabian Pflug
  4 siblings, 1 reply; 41+ messages in thread
From: Fabian Pflug @ 2025-11-26  6:42 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug

The bootm.root_arg variable will be responsible for the root= part of
the kernel commandline if bootm.appendroot is set and a root device has
been selected.
root_arg allows to replace the root=/dev/... with verity=/dev/..., which
is useful in a verified boot context, where you pass the root file
system to the initramfs, but do not want the kernel to be able to parse
and mount the rootfs. With renaming the root= to something different,
you make sure, that the kernel does not mount the rootfs.

Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
---
 common/bootm.c  | 8 ++++++--
 include/bootm.h | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 5d7dc00e3e..a1aba06f0e 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -69,6 +69,7 @@ void bootm_data_init_defaults(struct bootm_data *data)
 		data->initrd_file = getenv_nonempty("global.bootm.initrd");
 	}
 	data->root_dev = getenv_nonempty("global.bootm.root_dev");
+	data->root_arg = getenv_nonempty("global.bootm.root_arg");
 	data->verify = bootm_get_verify_mode();
 	data->appendroot = bootm_appendroot;
 	data->provide_machine_id = bootm_provide_machine_id;
@@ -88,6 +89,7 @@ void bootm_data_restore_defaults(const struct bootm_data *data)
 		globalvar_set("bootm.initrd", data->initrd_file);
 	}
 	globalvar_set("bootm.root_dev", data->root_dev);
+	globalvar_set("bootm.root_arg", data->root_arg);
 	bootm_set_verify_mode(data->verify);
 	bootm_appendroot = data->appendroot;
 	bootm_provide_machine_id = data->provide_machine_id;
@@ -868,10 +870,10 @@ int bootm_boot(struct bootm_data *bootm_data)
 		} else {
 			char *rootarg;
 			if(rootopts) {
-				rootarg = xasprintf("root=%s %s", root, rootopts);
+				rootarg = xasprintf("%s=%s %s", bootm_data->root_arg, root, rootopts);
 				free(rootopts);
 			} else {
-				rootarg = xasprintf("root=%s", root);
+				rootarg = xasprintf("%s=%s", bootm_data->root_arg, root);
 			}
 			free(root);
 			pr_info("Adding \"%s\" to Kernel commandline\n", rootarg);
@@ -1116,6 +1118,7 @@ static int bootm_init(void)
 	globalvar_add_simple("bootm.image.loadaddr", NULL);
 	globalvar_add_simple("bootm.oftree", NULL);
 	globalvar_add_simple("bootm.root_dev", NULL);
+	globalvar_add_simple("bootm.root_arg", "root");
 	globalvar_add_simple("bootm.tee", NULL);
 	globalvar_add_simple_bool("bootm.appendroot", &bootm_appendroot);
 	globalvar_add_simple_bool("bootm.earlycon", &bootm_earlycon);
@@ -1173,5 +1176,6 @@ BAREBOX_MAGICVAR(global.bootm.verbose, "bootm default verbosity level (0=quiet)"
 BAREBOX_MAGICVAR(global.bootm.earlycon, "Add earlycon option to Kernel for early log output");
 BAREBOX_MAGICVAR(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(global.bootm.root_dev, "bootm default root device (overrides default device in global.bootm.appendroot)");
+BAREBOX_MAGICVAR(global.bootm.root_arg, "bootm default name arg for the root partition (normally 'root' for root=/dev/...)");
 BAREBOX_MAGICVAR(global.bootm.provide_machine_id, "If true, append systemd.machine_id=$global.machine_id to Kernel command line");
 BAREBOX_MAGICVAR(global.bootm.provide_hostname, "If true, append systemd.hostname=$global.hostname to Kernel command line");
diff --git a/include/bootm.h b/include/bootm.h
index b35deb25bf..43f4258885 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -19,6 +19,7 @@ struct bootm_data {
 	const char *oftree_file;
 	const char *tee_file;
 	const char *root_dev;
+	const char *root_arg;
 	int verbose;
 	enum bootm_verify verify;
 	bool force;
-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH 1/4] block.h: renamed get_rootargs to get_root
  2025-11-26  6:42     ` [PATCH 1/4] block.h: renamed get_rootargs to get_root Fabian Pflug
@ 2025-11-26  9:50       ` Ahmad Fatoum
  0 siblings, 0 replies; 41+ messages in thread
From: Ahmad Fatoum @ 2025-11-26  9:50 UTC (permalink / raw)
  To: Fabian Pflug, barebox

On 11/26/25 7:42 AM, Fabian Pflug wrote:
> Don't return the full commandline-parameter, but instead just return the
> root block/fs/etc. The functions downstream can add root= before.
> 
> This is the first commit in a series to make root= dynamic.
> 
> Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

Small code formatting nitpicks below,

> ---
>  common/block.c         | 10 ++++++++--
>  drivers/mci/mci-core.c |  4 ++--
>  include/block.h        |  2 +-
>  3 files changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/common/block.c b/common/block.c
> index ca2ed37dbd..ce3aee49b4 100644
> --- a/common/block.c
> +++ b/common/block.c
> @@ -589,6 +589,7 @@ char *cdev_get_linux_rootarg(const struct cdev *partcdev)
>  	const struct cdev *cdevm;
>  	struct block_device *blk;
>  	char *rootarg = NULL;
> +	char* root = NULL;


Nitpick: Kernel coding style is * next to the variable.

>  
>  	if (!partcdev)
>  		return NULL;
> @@ -598,8 +599,13 @@ char *cdev_get_linux_rootarg(const struct cdev *partcdev)
>  	if (!blk)
>  		return NULL;
>  
> -	if (blk->ops->get_rootarg)
> -		rootarg = blk->ops->get_rootarg(blk, partcdev);
> +	if (blk->ops->get_root) {
> +		root = blk->ops->get_root(blk, partcdev);
> +		if(root) {

Nitpick: Space after if(

> +			rootarg = basprintf("root=%s", root);
> +			free(root);
> +		}
> +	}
>  	if (!rootarg && partcdev->partuuid[0] != 0)
>  		rootarg = basprintf("root=PARTUUID=%s", partcdev->partuuid);
>  
> diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
> index 57825bc849..206147cb93 100644
> --- a/drivers/mci/mci-core.c
> +++ b/drivers/mci/mci-core.c
> @@ -2691,7 +2691,7 @@ static char *mci_get_linux_mmcblkdev(struct block_device *blk,
>  		 * skipping it.
>  		 */
>  		if (cdev_partname_equal(partcdev, cdev))
> -			return basprintf("root=/dev/mmcblk%dp%d", id, partnum);
> +			return basprintf("/dev/mmcblk%dp%d", id, partnum);
>  		if (cdev->flags & DEVFS_PARTITION_FROM_TABLE)
>  			partnum++;
>  	}
> @@ -2703,7 +2703,7 @@ static struct block_device_ops mci_ops = {
>  	.read = mci_sd_read,
>  	.write = IS_ENABLED(CONFIG_MCI_WRITE) ? mci_sd_write : NULL,
>  	.erase = IS_ENABLED(CONFIG_MCI_ERASE) ? mci_sd_erase : NULL,
> -	.get_rootarg = IS_ENABLED(CONFIG_MMCBLKDEV_ROOTARG) ?
> +	.get_root = IS_ENABLED(CONFIG_MMCBLKDEV_ROOTARG) ?
>  		mci_get_linux_mmcblkdev : NULL,
>  };
>  
> diff --git a/include/block.h b/include/block.h
> index fc7a0a32fb..b277f590e4 100644
> --- a/include/block.h
> +++ b/include/block.h
> @@ -14,7 +14,7 @@ struct block_device_ops {
>  	int (*write)(struct block_device *, const void *buf, sector_t block, blkcnt_t num_blocks);
>  	int (*erase)(struct block_device *blk, sector_t block, blkcnt_t num_blocks);
>  	int (*flush)(struct block_device *);
> -	char *(*get_rootarg)(struct block_device *blk, const struct cdev *partcdev);
> +	char *(*get_root)(struct block_device *blk, const struct cdev *partcdev);
>  };
>  
>  struct chunk;

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |




^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH 2/4] fs: split rootargs into root and options
  2025-11-26  6:42     ` [PATCH 2/4] fs: split rootargs into root and options Fabian Pflug
@ 2025-11-26 10:13       ` Ahmad Fatoum
  2025-11-26 10:31       ` Ahmad Fatoum
  1 sibling, 0 replies; 41+ messages in thread
From: Ahmad Fatoum @ 2025-11-26 10:13 UTC (permalink / raw)
  To: Fabian Pflug, barebox

Hi Fabian,

On 11/26/25 7:42 AM, Fabian Pflug wrote:
> The rootargs argument (root=/dev/etc rootwait) can be split into the
> root and options parts, which makes it easier to manipulate them both
> independently. This changes tries to be as backward compatible as
> possible and does not change the behaviour of the get functions, but
> introduces new ones to get both items seperatly.
> 
> Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>

Just some code style nitpicks below,

> ---
>  common/block.c         | 42 ++++++++++++++++++-------------
>  fs/9p/vfs_super.c      |  6 ++---
>  fs/fs.c                | 57 +++++++++++++++++++++++++++++++-----------
>  fs/nfs.c               |  4 +--
>  fs/squashfs/squashfs.c | 13 ++++++----
>  fs/ubifs/ubifs.c       | 12 +++++----
>  include/block.h        |  6 +++++
>  include/fs.h           |  6 +++--
>  8 files changed, 98 insertions(+), 48 deletions(-)
> 
> diff --git a/common/block.c b/common/block.c
> index ce3aee49b4..35e90dc4a6 100644
> --- a/common/block.c
> +++ b/common/block.c
> @@ -584,34 +584,42 @@ const char *blk_type_str(enum blk_type type)
>  	}
>  }
>  
> -char *cdev_get_linux_rootarg(const struct cdev *partcdev)
> -{
> +void cdev_get_linux_root_and_opts(const struct cdev *partcdev, char** root, char** rootopts) {

space before the **

> +
>  	const struct cdev *cdevm;
>  	struct block_device *blk;
> -	char *rootarg = NULL;
> -	char* root = NULL;
> +
> +	*root = NULL;
> +	*rootopts = NULL;

Convention elsewhere in the codebase is to set output parameters only on
success. This allows users to specify default values and they will not
be overridden on error. Please drop these and maybe return an error code
instead from the function (or one of the arguments ;).

>  
>  	if (!partcdev)
> -		return NULL;
> +		return;
>  
>  	cdevm = partcdev->master ?: partcdev;
>  	blk = cdev_get_block_device(cdevm);
>  	if (!blk)
> -		return NULL;
> +		return;
>  
> -	if (blk->ops->get_root) {
> -		root = blk->ops->get_root(blk, partcdev);
> -		if(root) {
> -			rootarg = basprintf("root=%s", root);
> -			free(root);
> -		}
> -	}
> -	if (!rootarg && partcdev->partuuid[0] != 0)
> -		rootarg = basprintf("root=PARTUUID=%s", partcdev->partuuid);
> +	if (blk->ops->get_root)
> +		*root = blk->ops->get_root(blk, partcdev);
> +	if (!*root && partcdev->partuuid[0] != 0)
> +		*root = basprintf("PARTUUID=%s", partcdev->partuuid);

Please assign to local variable and only set on success.

>  
>  	if (IS_ENABLED(CONFIG_ROOTWAIT_BOOTARG) && blk->rootwait)
> -		rootarg = linux_bootargs_append_rootwait(rootarg);
> +		*rootopts = xasprintf("rootwait=%d", linux_rootwait_secs);

xasprintf and basprintf are aliases nowadays. I prefer xasprintf as it
makes it clearer that the function panics on OOM. I wouldn't mix both in
the same function.

>  
> -	return rootarg;
> +	return;
>  }
>  
> +char *cdev_get_linux_rootarg(const struct cdev *partcdev)
> +{
> +	char* root;
> +	char* rootopts;
> +
> +	cdev_get_linux_root_and_opts(partcdev, &root, &rootopts);
> +	if(!root)
> +		return NULL;
> +	if(rootopts)
> +		return xasprintf("root=%s %s", root, rootopts);
> +	return xasprintf("root=%s", root);
> +}
> diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
> index 6a451d9ef5..efc9a9193d 100644
> --- a/fs/9p/vfs_super.c
> +++ b/fs/9p/vfs_super.c
> @@ -70,11 +70,11 @@ static void v9fs_set_rootarg(struct v9fs_session_info *v9ses,
>  	trans = v9ses->clnt->trans_mod->name;
>  	path = v9ses->aname;
>  
> -	str = basprintf("root=%s rootfstype=9p rootflags=trans=%s,msize=%d,"
> +	str = basprintf("rootfstype=9p rootflags=trans=%s,msize=%d,"
>  			"cache=loose,uname=%s,dfltuid=0,dfltgid=0,aname=%s",
> -			tag, trans, v9ses->clnt->msize, tag, path);
> +			trans, v9ses->clnt->msize, tag, path);
>  
> -	fsdev_set_linux_rootarg(fsdev, str);
> +	fsdev_set_linux_root_options(fsdev, tag, str);
>  
>  	free(str);
>  }
> diff --git a/fs/fs.c b/fs/fs.c
> index 528299e039..c4f805d308 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -1226,12 +1226,26 @@ void mount_all(void)
>  	}
>  }
>  
> -void fsdev_set_linux_rootarg(struct fs_device *fsdev, const char *str)
> +void fsdev_set_linux_root_options(struct fs_device *fsdev, const char *root, const char *rootopts)
>  {
> -	fsdev->linux_rootarg = xstrdup(str);
> +	fsdev->linux_root = xstrdup(root);
> +	fsdev->linux_rootopts = xstrdup(rootopts);
>  
> -	dev_add_param_fixed(&fsdev->dev, "linux.bootargs",
> -			    "%s", fsdev->linux_rootarg);
> +	dev_add_param_fixed(&fsdev->dev, "linux.bootargs.root",
> +			    "%s", fsdev->linux_root);
> +	dev_add_param_fixed(&fsdev->dev, "linux.bootargs.rootopts",
> +			    "%s", fsdev->linux_rootopts);
> +}
> +
> +void fsdev_get_linux_root_options(struct fs_device *fsdev, char **root, char **rootopts)
> +{
> +	if(fsdev) {

space missing

> +		*root = dev_get_param(&fsdev->dev, "linux.bootargs.root");
> +		*rootopts = dev_get_param(&fsdev->dev, "linux.bootargs.rootopts");
> +	} else {
> +		*root = NULL;
> +		*rootopts = NULL;

As mentioned above, this is not how other functions do it in barebox
(and the kernel for that matter).

> +	}
>  }
>  
>  /**
> @@ -1245,17 +1259,27 @@ void fsdev_set_linux_rootarg(struct fs_device *fsdev, const char *str)
>  char *path_get_linux_rootarg(const char *path)
>  {
>  	struct fs_device *fsdev;
> -	const char *str;
> +	char *root;
> +	char *rootopts;
> +	char *rootarg;
>  
>  	fsdev = get_fsdevice_by_path(AT_FDCWD, path);
>  	if (!fsdev)
>  		return ERR_PTR(-EINVAL);
>  
> -	str = dev_get_param(&fsdev->dev, "linux.bootargs");
> -	if (!str)
> -		return ERR_PTR(-ENOSYS);
> +	fsdev_get_linux_root_options(fsdev, &root, &rootopts);
>  
> -	return xstrdup(str);
> +	if(!root)
> +		return ERR_PTR(-EINVAL);
> +
> +	if(rootopts) {

space

> +		rootarg = xasprintf("root=%s %s", root, rootopts);
> +		free(rootopts);

move this to the end (free checks for NULL already) and then you can
just have

if(rootopts)
	rootarg = xasprintf("root=%s %s", root, rootopts);
else
	rootarg = xasprintf("root=%s", root);

makes code slightly easier to read IMO.

> +	} else {
> +		rootarg = xasprintf("root=%s", root);
> +	}
> +	free(root);
> +	return rootarg;
>  }
>  
>  /**
> @@ -3249,12 +3273,17 @@ int mount(const char *device, const char *fsname, const char *pathname,
>  
>  	fsdev->vfsmount.mnt_root = fsdev->sb.s_root;
>  
> -	if (!fsdev->linux_rootarg) {
> -		char *str;
> +	if (!fsdev->linux_root) {
> +		char *root;
> +		char *rootopts;
>  
> -		str = cdev_get_linux_rootarg(fsdev->cdev);
> -		if (str)
> -			fsdev_set_linux_rootarg(fsdev, str);
> +		cdev_get_linux_root_and_opts(fsdev->cdev, &root, &rootopts);
> +		if (root) {
> +			fsdev_set_linux_root_options(fsdev, root, rootopts);
> +			free(root);
> +			if(rootopts)
> +				free(rootopts);

if not needed.

> +		}
>  	}
>  
>  	path_put(&path);
> diff --git a/fs/nfs.c b/fs/nfs.c
> index 5c2476cd88..0b40c56ff3 100644
> --- a/fs/nfs.c
> +++ b/fs/nfs.c
> @@ -1558,7 +1558,7 @@ static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device *fsdev)
>  	char *str, *tmp;
>  	const char *bootargs;
>  
> -	str = basprintf("root=/dev/nfs nfsroot=%pI4:%s%s%s", &npriv->server, npriv->path,
> +	str = basprintf("nfsroot=%pI4:%s%s%s", &npriv->server, npriv->path,
>  			  rootnfsopts[0] ? "," : "", rootnfsopts);
>  
>  	/* forward specific mount options on demand */
> @@ -1584,7 +1584,7 @@ static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device *fsdev)
>  	if (IS_ENABLED(CONFIG_ROOTWAIT_BOOTARG))
>  		str = linux_bootargs_append_rootwait(str);
>  
> -	fsdev_set_linux_rootarg(fsdev, str);
> +	fsdev_set_linux_root_options(fsdev, "/dev/nfs", str);
>  
>  	free(str);
>  }
> diff --git a/fs/squashfs/squashfs.c b/fs/squashfs/squashfs.c
> index e30372627a..365aa1f219 100644
> --- a/fs/squashfs/squashfs.c
> +++ b/fs/squashfs/squashfs.c
> @@ -46,7 +46,8 @@ static void squashfs_set_rootarg(struct fs_device *fsdev)
>  	struct ubi_volume_info vi = {};
>  	struct ubi_device_info di = {};
>  	struct mtd_info *mtd;
> -	char *str;
> +	char *root;
> +	char *rootopts;
>  
>  	if (!IS_ENABLED(CONFIG_MTD_UBI))
>  		return;
> @@ -60,12 +61,14 @@ static void squashfs_set_rootarg(struct fs_device *fsdev)
>  	ubi_get_device_info(vi.ubi_num, &di);
>  	mtd = di.mtd;
>  
> -	str = basprintf("root=/dev/ubiblock%d_%d ubi.mtd=%s ubi.block=%d,%d rootfstype=squashfs",
> -			vi.ubi_num, vi.vol_id, mtd->cdev.partname, vi.ubi_num, vi.vol_id);
> +	root = basprintf("/dev/ubiblock%d_%d", vi.ubi_num, vi.vol_id);
> +	rootopts = basprintf("ubi.mtd=%s ubi.block=%d,%d rootfstype=squashfs",
> +			mtd->cdev.partname, vi.ubi_num, vi.vol_id);
>  
> -	fsdev_set_linux_rootarg(fsdev, str);
> +	fsdev_set_linux_root_options(fsdev, root, rootopts);
>  
> -	free(str);
> +	free(root);
> +	free(rootopts);
>  }
>  
>  static struct inode *squashfs_alloc_inode(struct super_block *sb)
> diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
> index 37986acbb2..9cc35fa273 100644
> --- a/fs/ubifs/ubifs.c
> +++ b/fs/ubifs/ubifs.c
> @@ -435,19 +435,21 @@ static void ubifs_set_rootarg(struct ubifs_priv *priv,
>  	struct ubi_volume_info vi = {};
>  	struct ubi_device_info di = {};
>  	struct mtd_info *mtd;
> -	char *str;
> +	char *root;
> +	char *rootopts;
>  
>  	ubi_get_volume_info(priv->ubi, &vi);
>  	ubi_get_device_info(vi.ubi_num, &di);
>  
>  	mtd = di.mtd;
>  
> -	str = basprintf("root=ubi0:%s ubi.mtd=%s rootfstype=ubifs",
> -			  vi.name, mtd->cdev.partname);
> +	root = basprintf("ubi0:%s", vi.name);
> +	rootopts = basprintf("ubi.mtd=%s rootfstype=ubifs", mtd->cdev.partname);
>  
> -	fsdev_set_linux_rootarg(fsdev, str);
> +	fsdev_set_linux_root_options(fsdev, root, rootopts);
>  
> -	free(str);
> +	free(root);
> +	free(rootopts);
>  }
>  
>  static int ubifs_probe(struct device *dev)
> diff --git a/include/block.h b/include/block.h
> index b277f590e4..ddab8bfe60 100644
> --- a/include/block.h
> +++ b/include/block.h
> @@ -85,6 +85,7 @@ static inline int block_flush(struct block_device *blk)
>  #ifdef CONFIG_BLOCK
>  unsigned file_list_add_blockdevs(struct file_list *files);
>  char *cdev_get_linux_rootarg(const struct cdev *partcdev);
> +void cdev_get_linux_root_and_opts(const struct cdev *partcdev, char** root, char** rootopts);
>  #else
>  static inline unsigned file_list_add_blockdevs(struct file_list *files)
>  {
> @@ -94,6 +95,11 @@ static inline char *cdev_get_linux_rootarg(const struct cdev *partcdev)
>  {
>  	return NULL;
>  }
> +static inline void cdev_get_linux_root_and_opts(const struct cdev *partcdev, char** root, char** rootopts)
> +{
> +	root = NULL;
> +	rootopts = NULL;

drop

> +}
>  #endif
>  
>  static inline bool cdev_is_block_device(const struct cdev *cdev)
> diff --git a/include/fs.h b/include/fs.h
> index 98c482bbf2..c50437d609 100644
> --- a/include/fs.h
> +++ b/include/fs.h
> @@ -90,7 +90,8 @@ struct fs_device {
>  	char *path;
>  	struct list_head list;
>  	char *options;
> -	char *linux_rootarg;
> +	char *linux_root;
> +	char *linux_rootopts;
>  
>  	struct super_block sb;
>  
> @@ -159,7 +160,8 @@ const char *cdev_mount_default(struct cdev *cdev, const char *fsoptions);
>  const char *cdev_mount(struct cdev *cdev);
>  void mount_all(void);
>  
> -void fsdev_set_linux_rootarg(struct fs_device *fsdev, const char *str);
> +void fsdev_set_linux_root_options(struct fs_device *fsdev, const char *root, const char* rootopts);
> +void fsdev_get_linux_root_options(struct fs_device *fsdev, char **root, char **rootopts);
>  char *path_get_linux_rootarg(const char *path);
>  
>  static inline const char *devpath_to_name(const char *devpath)

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |




^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH 3/4] bootm: use new api to get kernel command line params
  2025-11-26  6:42     ` [PATCH 3/4] bootm: use new api to get kernel command line params Fabian Pflug
@ 2025-11-26 10:25       ` Ahmad Fatoum
  2025-11-26 11:29         ` Fabian Pflug
  0 siblings, 1 reply; 41+ messages in thread
From: Ahmad Fatoum @ 2025-11-26 10:25 UTC (permalink / raw)
  To: Fabian Pflug, barebox


On 11/26/25 7:42 AM, Fabian Pflug wrote:
> Getting root device adn root kernel options seperatily any combining

device and root kernel options seperatly and combining

> them in this function instead of getting the full string from the helper
> functions. This is in preperation for replacing the root= string in the

preparation

> kernel commandline with something defined during runtime.
> 
> Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
> ---
>  common/bootm.c | 34 ++++++++++++++++++++--------------
>  1 file changed, 20 insertions(+), 14 deletions(-)
> 
> diff --git a/common/bootm.c b/common/bootm.c
> index 17792b2a1d..5d7dc00e3e 100644
> --- a/common/bootm.c
> +++ b/common/bootm.c
> @@ -4,6 +4,7 @@
>  #include <bootm.h>
>  #include <bootm-overrides.h>
>  #include <fs.h>
> +#include <fcntl.h>
>  #include <malloc.h>
>  #include <memory.h>
>  #include <block.h>
> @@ -841,33 +842,38 @@ int bootm_boot(struct bootm_data *bootm_data)
>  	}
>  
>  	if (bootm_data->appendroot) {
> -		char *rootarg;
> +		char *root;
> +		char *rootopts;
>  
>  		if (bootm_data->root_dev) {
>  			const char *root_dev_name = devpath_to_name(bootm_data->root_dev);
>  			struct cdev *root_cdev = cdev_open_by_name(root_dev_name, O_RDONLY);
>  
> -			rootarg = cdev_get_linux_rootarg(root_cdev);
> -			if (!rootarg) {
> -				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);

This warning is useful, because it's very confusing otherwise when a MBR
disk image is created without a NT signature.

> -			}
> +			cdev_get_linux_root_and_opts(root_cdev, &root, &rootopts);
>  
>  			if (root_cdev)
>  				cdev_close(root_cdev);
> +			else
> +				pr_err("no cdev found for %s, cannot set root= option\n", root_dev_name);
>  		} else {
> -			rootarg = path_get_linux_rootarg(data->os_file);

path_get_linux_rootarg() is stale now right? Can you squash its removal
into the patch that gets rid of linux.bootargs?

> +			struct fs_device *fsdev = get_fsdevice_by_path(AT_FDCWD, data->os_file);
> +			if(fsdev)
> +				fsdev_get_linux_root_options(fsdev, &root, &rootopts);
> +			else
> +				pr_err("no fsdevice under path: %s\n", data->os_file);
>  		}
>  
> -		if (IS_ERR(rootarg)) {
> +		if (!root) {
>  			pr_err("Failed to append kernel cmdline parameter 'root='\n");
>  		} else {
> +			char *rootarg;
> +			if(rootopts) {
> +				rootarg = xasprintf("root=%s %s", root, rootopts);
> +				free(rootopts);
> +			} else {
> +				rootarg = xasprintf("root=%s", root);
> +			}

I wonder if we should add a helper into a header that does this, given
how many times this is repeated...

char *format_root_bootarg(char *root, char *rootopts);

which consumes (and frees) two pointers and returns a new buffer..

Cheers,
Ahmad

> +			free(root);
>  			pr_info("Adding \"%s\" to Kernel commandline\n", rootarg);
>  			globalvar_add_simple("linux.bootargs.bootm.appendroot",
>  					     rootarg);

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |




^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH 4/4] bootm: introduce bootm.root_arg variable
  2025-11-26  6:42     ` [PATCH 4/4] bootm: introduce bootm.root_arg variable Fabian Pflug
@ 2025-11-26 10:28       ` Ahmad Fatoum
  0 siblings, 0 replies; 41+ messages in thread
From: Ahmad Fatoum @ 2025-11-26 10:28 UTC (permalink / raw)
  To: Fabian Pflug, barebox


On 11/26/25 7:42 AM, Fabian Pflug wrote:
> The bootm.root_arg variable will be responsible for the root= part of
> the kernel commandline if bootm.appendroot is set and a root device has
> been selected.
> root_arg allows to replace the root=/dev/... with verity=/dev/..., which
> is useful in a verified boot context, where you pass the root file
> system to the initramfs, but do not want the kernel to be able to parse
> and mount the rootfs. With renaming the root= to something different,
> you make sure, that the kernel does not mount the rootfs.
> 
> Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
> ---
>  common/bootm.c  | 8 ++++++--
>  include/bootm.h | 1 +
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/common/bootm.c b/common/bootm.c
> index 5d7dc00e3e..a1aba06f0e 100644
> --- a/common/bootm.c
> +++ b/common/bootm.c
> @@ -69,6 +69,7 @@ void bootm_data_init_defaults(struct bootm_data *data)
>  		data->initrd_file = getenv_nonempty("global.bootm.initrd");
>  	}
>  	data->root_dev = getenv_nonempty("global.bootm.root_dev");
> +	data->root_arg = getenv_nonempty("global.bootm.root_arg");
>  	data->verify = bootm_get_verify_mode();
>  	data->appendroot = bootm_appendroot;
>  	data->provide_machine_id = bootm_provide_machine_id;
> @@ -88,6 +89,7 @@ void bootm_data_restore_defaults(const struct bootm_data *data)
>  		globalvar_set("bootm.initrd", data->initrd_file);
>  	}
>  	globalvar_set("bootm.root_dev", data->root_dev);
> +	globalvar_set("bootm.root_arg", data->root_arg);
>  	bootm_set_verify_mode(data->verify);
>  	bootm_appendroot = data->appendroot;
>  	bootm_provide_machine_id = data->provide_machine_id;
> @@ -868,10 +870,10 @@ int bootm_boot(struct bootm_data *bootm_data)
>  		} else {
>  			char *rootarg;
>  			if(rootopts) {
> -				rootarg = xasprintf("root=%s %s", root, rootopts);
> +				rootarg = xasprintf("%s=%s %s", bootm_data->root_arg, root, rootopts);
>  				free(rootopts);
>  			} else {
> -				rootarg = xasprintf("root=%s", root);
> +				rootarg = xasprintf("%s=%s", bootm_data->root_arg, root);
>  			}
>  			free(root);
>  			pr_info("Adding \"%s\" to Kernel commandline\n", rootarg);
> @@ -1116,6 +1118,7 @@ static int bootm_init(void)
>  	globalvar_add_simple("bootm.image.loadaddr", NULL);
>  	globalvar_add_simple("bootm.oftree", NULL);
>  	globalvar_add_simple("bootm.root_dev", NULL);
> +	globalvar_add_simple("bootm.root_arg", "root");
>  	globalvar_add_simple("bootm.tee", NULL);
>  	globalvar_add_simple_bool("bootm.appendroot", &bootm_appendroot);
>  	globalvar_add_simple_bool("bootm.earlycon", &bootm_earlycon);
> @@ -1173,5 +1176,6 @@ BAREBOX_MAGICVAR(global.bootm.verbose, "bootm default verbosity level (0=quiet)"
>  BAREBOX_MAGICVAR(global.bootm.earlycon, "Add earlycon option to Kernel for early log output");
>  BAREBOX_MAGICVAR(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(global.bootm.root_dev, "bootm default root device (overrides default device in global.bootm.appendroot)");
> +BAREBOX_MAGICVAR(global.bootm.root_arg, "bootm default name arg for the root partition (normally 'root' for root=/dev/...)");

s/default name arg/default parameter name/

?

>  BAREBOX_MAGICVAR(global.bootm.provide_machine_id, "If true, append systemd.machine_id=$global.machine_id to Kernel command line");
>  BAREBOX_MAGICVAR(global.bootm.provide_hostname, "If true, append systemd.hostname=$global.hostname to Kernel command line");
> diff --git a/include/bootm.h b/include/bootm.h
> index b35deb25bf..43f4258885 100644
> --- a/include/bootm.h
> +++ b/include/bootm.h
> @@ -19,6 +19,7 @@ struct bootm_data {
>  	const char *oftree_file;
>  	const char *tee_file;
>  	const char *root_dev;
> +	const char *root_arg;
>  	int verbose;
>  	enum bootm_verify verify;
>  	bool force;

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |




^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH 2/4] fs: split rootargs into root and options
  2025-11-26  6:42     ` [PATCH 2/4] fs: split rootargs into root and options Fabian Pflug
  2025-11-26 10:13       ` Ahmad Fatoum
@ 2025-11-26 10:31       ` Ahmad Fatoum
  1 sibling, 0 replies; 41+ messages in thread
From: Ahmad Fatoum @ 2025-11-26 10:31 UTC (permalink / raw)
  To: Fabian Pflug, barebox

Hi,

On 11/26/25 7:42 AM, Fabian Pflug wrote:
> The rootargs argument (root=/dev/etc rootwait) can be split into the
> root and options parts, which makes it easier to manipulate them both
> independently. This changes tries to be as backward compatible as
> possible and does not change the behaviour of the get functions, but
> introduces new ones to get both items seperatly.
> 
> Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
> ---
>  common/block.c         | 42 ++++++++++++++++++-------------
>  fs/9p/vfs_super.c      |  6 ++---
>  fs/fs.c                | 57 +++++++++++++++++++++++++++++++-----------
>  fs/nfs.c               |  4 +--
>  fs/squashfs/squashfs.c | 13 ++++++----
>  fs/ubifs/ubifs.c       | 12 +++++----
>  include/block.h        |  6 +++++
>  include/fs.h           |  6 +++--
>  8 files changed, 98 insertions(+), 48 deletions(-)
> 
> diff --git a/common/block.c b/common/block.c
> index ce3aee49b4..35e90dc4a6 100644
> --- a/common/block.c
> +++ b/common/block.c
> @@ -584,34 +584,42 @@ const char *blk_type_str(enum blk_type type)
>  	}
>  }
>  
> -char *cdev_get_linux_rootarg(const struct cdev *partcdev)
> -{
> +void cdev_get_linux_root_and_opts(const struct cdev *partcdev, char** root, char** rootopts) {
> +
>  	const struct cdev *cdevm;
>  	struct block_device *blk;
> -	char *rootarg = NULL;
> -	char* root = NULL;
> +
> +	*root = NULL;
> +	*rootopts = NULL;
>  
>  	if (!partcdev)
> -		return NULL;
> +		return;
>  
>  	cdevm = partcdev->master ?: partcdev;
>  	blk = cdev_get_block_device(cdevm);
>  	if (!blk)
> -		return NULL;
> +		return;
>  
> -	if (blk->ops->get_root) {
> -		root = blk->ops->get_root(blk, partcdev);
> -		if(root) {
> -			rootarg = basprintf("root=%s", root);
> -			free(root);
> -		}
> -	}
> -	if (!rootarg && partcdev->partuuid[0] != 0)
> -		rootarg = basprintf("root=PARTUUID=%s", partcdev->partuuid);
> +	if (blk->ops->get_root)
> +		*root = blk->ops->get_root(blk, partcdev);
> +	if (!*root && partcdev->partuuid[0] != 0)
> +		*root = basprintf("PARTUUID=%s", partcdev->partuuid);
>  
>  	if (IS_ENABLED(CONFIG_ROOTWAIT_BOOTARG) && blk->rootwait)
> -		rootarg = linux_bootargs_append_rootwait(rootarg);
> +		*rootopts = xasprintf("rootwait=%d", linux_rootwait_secs);
>  
> -	return rootarg;
> +	return;
>  }
>  
> +char *cdev_get_linux_rootarg(const struct cdev *partcdev)
> +{
> +	char* root;
> +	char* rootopts;
> +
> +	cdev_get_linux_root_and_opts(partcdev, &root, &rootopts);
> +	if(!root)
> +		return NULL;
> +	if(rootopts)
> +		return xasprintf("root=%s %s", root, rootopts);
> +	return xasprintf("root=%s", root);
> +}
> diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
> index 6a451d9ef5..efc9a9193d 100644
> --- a/fs/9p/vfs_super.c
> +++ b/fs/9p/vfs_super.c
> @@ -70,11 +70,11 @@ static void v9fs_set_rootarg(struct v9fs_session_info *v9ses,
>  	trans = v9ses->clnt->trans_mod->name;
>  	path = v9ses->aname;
>  
> -	str = basprintf("root=%s rootfstype=9p rootflags=trans=%s,msize=%d,"
> +	str = basprintf("rootfstype=9p rootflags=trans=%s,msize=%d,"
>  			"cache=loose,uname=%s,dfltuid=0,dfltgid=0,aname=%s",
> -			tag, trans, v9ses->clnt->msize, tag, path);
> +			trans, v9ses->clnt->msize, tag, path);
>  
> -	fsdev_set_linux_rootarg(fsdev, str);
> +	fsdev_set_linux_root_options(fsdev, tag, str);
>  
>  	free(str);
>  }
> diff --git a/fs/fs.c b/fs/fs.c
> index 528299e039..c4f805d308 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -1226,12 +1226,26 @@ void mount_all(void)
>  	}
>  }
>  
> -void fsdev_set_linux_rootarg(struct fs_device *fsdev, const char *str)
> +void fsdev_set_linux_root_options(struct fs_device *fsdev, const char *root, const char *rootopts)
>  {
> -	fsdev->linux_rootarg = xstrdup(str);
> +	fsdev->linux_root = xstrdup(root);
> +	fsdev->linux_rootopts = xstrdup(rootopts);
>  
> -	dev_add_param_fixed(&fsdev->dev, "linux.bootargs",
> -			    "%s", fsdev->linux_rootarg);
> +	dev_add_param_fixed(&fsdev->dev, "linux.bootargs.root",
> +			    "%s", fsdev->linux_root);
> +	dev_add_param_fixed(&fsdev->dev, "linux.bootargs.rootopts",
> +			    "%s", fsdev->linux_rootopts);

Please add an entry to
Documentation/migration-guides/migration-master.rst documenting that
this variable has been replaced for file system devices by
"root={linux.bootargs.root} {linux.bootargs.rootopts}".

Thanks,
Ahmad

> +}
> +
> +void fsdev_get_linux_root_options(struct fs_device *fsdev, char **root, char **rootopts)
> +{
> +	if(fsdev) {
> +		*root = dev_get_param(&fsdev->dev, "linux.bootargs.root");
> +		*rootopts = dev_get_param(&fsdev->dev, "linux.bootargs.rootopts");
> +	} else {
> +		*root = NULL;
> +		*rootopts = NULL;
> +	}
>  }
>  
>  /**
> @@ -1245,17 +1259,27 @@ void fsdev_set_linux_rootarg(struct fs_device *fsdev, const char *str)
>  char *path_get_linux_rootarg(const char *path)
>  {
>  	struct fs_device *fsdev;
> -	const char *str;
> +	char *root;
> +	char *rootopts;
> +	char *rootarg;
>  
>  	fsdev = get_fsdevice_by_path(AT_FDCWD, path);
>  	if (!fsdev)
>  		return ERR_PTR(-EINVAL);
>  
> -	str = dev_get_param(&fsdev->dev, "linux.bootargs");
> -	if (!str)
> -		return ERR_PTR(-ENOSYS);
> +	fsdev_get_linux_root_options(fsdev, &root, &rootopts);
>  
> -	return xstrdup(str);
> +	if(!root)
> +		return ERR_PTR(-EINVAL);
> +
> +	if(rootopts) {
> +		rootarg = xasprintf("root=%s %s", root, rootopts);
> +		free(rootopts);
> +	} else {
> +		rootarg = xasprintf("root=%s", root);
> +	}
> +	free(root);
> +	return rootarg;
>  }
>  
>  /**
> @@ -3249,12 +3273,17 @@ int mount(const char *device, const char *fsname, const char *pathname,
>  
>  	fsdev->vfsmount.mnt_root = fsdev->sb.s_root;
>  
> -	if (!fsdev->linux_rootarg) {
> -		char *str;
> +	if (!fsdev->linux_root) {
> +		char *root;
> +		char *rootopts;
>  
> -		str = cdev_get_linux_rootarg(fsdev->cdev);
> -		if (str)
> -			fsdev_set_linux_rootarg(fsdev, str);
> +		cdev_get_linux_root_and_opts(fsdev->cdev, &root, &rootopts);
> +		if (root) {
> +			fsdev_set_linux_root_options(fsdev, root, rootopts);
> +			free(root);
> +			if(rootopts)
> +				free(rootopts);
> +		}
>  	}
>  
>  	path_put(&path);
> diff --git a/fs/nfs.c b/fs/nfs.c
> index 5c2476cd88..0b40c56ff3 100644
> --- a/fs/nfs.c
> +++ b/fs/nfs.c
> @@ -1558,7 +1558,7 @@ static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device *fsdev)
>  	char *str, *tmp;
>  	const char *bootargs;
>  
> -	str = basprintf("root=/dev/nfs nfsroot=%pI4:%s%s%s", &npriv->server, npriv->path,
> +	str = basprintf("nfsroot=%pI4:%s%s%s", &npriv->server, npriv->path,
>  			  rootnfsopts[0] ? "," : "", rootnfsopts);
>  
>  	/* forward specific mount options on demand */
> @@ -1584,7 +1584,7 @@ static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device *fsdev)
>  	if (IS_ENABLED(CONFIG_ROOTWAIT_BOOTARG))
>  		str = linux_bootargs_append_rootwait(str);
>  
> -	fsdev_set_linux_rootarg(fsdev, str);
> +	fsdev_set_linux_root_options(fsdev, "/dev/nfs", str);
>  
>  	free(str);
>  }
> diff --git a/fs/squashfs/squashfs.c b/fs/squashfs/squashfs.c
> index e30372627a..365aa1f219 100644
> --- a/fs/squashfs/squashfs.c
> +++ b/fs/squashfs/squashfs.c
> @@ -46,7 +46,8 @@ static void squashfs_set_rootarg(struct fs_device *fsdev)
>  	struct ubi_volume_info vi = {};
>  	struct ubi_device_info di = {};
>  	struct mtd_info *mtd;
> -	char *str;
> +	char *root;
> +	char *rootopts;
>  
>  	if (!IS_ENABLED(CONFIG_MTD_UBI))
>  		return;
> @@ -60,12 +61,14 @@ static void squashfs_set_rootarg(struct fs_device *fsdev)
>  	ubi_get_device_info(vi.ubi_num, &di);
>  	mtd = di.mtd;
>  
> -	str = basprintf("root=/dev/ubiblock%d_%d ubi.mtd=%s ubi.block=%d,%d rootfstype=squashfs",
> -			vi.ubi_num, vi.vol_id, mtd->cdev.partname, vi.ubi_num, vi.vol_id);
> +	root = basprintf("/dev/ubiblock%d_%d", vi.ubi_num, vi.vol_id);
> +	rootopts = basprintf("ubi.mtd=%s ubi.block=%d,%d rootfstype=squashfs",
> +			mtd->cdev.partname, vi.ubi_num, vi.vol_id);
>  
> -	fsdev_set_linux_rootarg(fsdev, str);
> +	fsdev_set_linux_root_options(fsdev, root, rootopts);
>  
> -	free(str);
> +	free(root);
> +	free(rootopts);
>  }
>  
>  static struct inode *squashfs_alloc_inode(struct super_block *sb)
> diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
> index 37986acbb2..9cc35fa273 100644
> --- a/fs/ubifs/ubifs.c
> +++ b/fs/ubifs/ubifs.c
> @@ -435,19 +435,21 @@ static void ubifs_set_rootarg(struct ubifs_priv *priv,
>  	struct ubi_volume_info vi = {};
>  	struct ubi_device_info di = {};
>  	struct mtd_info *mtd;
> -	char *str;
> +	char *root;
> +	char *rootopts;
>  
>  	ubi_get_volume_info(priv->ubi, &vi);
>  	ubi_get_device_info(vi.ubi_num, &di);
>  
>  	mtd = di.mtd;
>  
> -	str = basprintf("root=ubi0:%s ubi.mtd=%s rootfstype=ubifs",
> -			  vi.name, mtd->cdev.partname);
> +	root = basprintf("ubi0:%s", vi.name);
> +	rootopts = basprintf("ubi.mtd=%s rootfstype=ubifs", mtd->cdev.partname);
>  
> -	fsdev_set_linux_rootarg(fsdev, str);
> +	fsdev_set_linux_root_options(fsdev, root, rootopts);
>  
> -	free(str);
> +	free(root);
> +	free(rootopts);
>  }
>  
>  static int ubifs_probe(struct device *dev)
> diff --git a/include/block.h b/include/block.h
> index b277f590e4..ddab8bfe60 100644
> --- a/include/block.h
> +++ b/include/block.h
> @@ -85,6 +85,7 @@ static inline int block_flush(struct block_device *blk)
>  #ifdef CONFIG_BLOCK
>  unsigned file_list_add_blockdevs(struct file_list *files);
>  char *cdev_get_linux_rootarg(const struct cdev *partcdev);
> +void cdev_get_linux_root_and_opts(const struct cdev *partcdev, char** root, char** rootopts);
>  #else
>  static inline unsigned file_list_add_blockdevs(struct file_list *files)
>  {
> @@ -94,6 +95,11 @@ static inline char *cdev_get_linux_rootarg(const struct cdev *partcdev)
>  {
>  	return NULL;
>  }
> +static inline void cdev_get_linux_root_and_opts(const struct cdev *partcdev, char** root, char** rootopts)
> +{
> +	root = NULL;
> +	rootopts = NULL;
> +}
>  #endif
>  
>  static inline bool cdev_is_block_device(const struct cdev *cdev)
> diff --git a/include/fs.h b/include/fs.h
> index 98c482bbf2..c50437d609 100644
> --- a/include/fs.h
> +++ b/include/fs.h
> @@ -90,7 +90,8 @@ struct fs_device {
>  	char *path;
>  	struct list_head list;
>  	char *options;
> -	char *linux_rootarg;
> +	char *linux_root;
> +	char *linux_rootopts;
>  
>  	struct super_block sb;
>  
> @@ -159,7 +160,8 @@ const char *cdev_mount_default(struct cdev *cdev, const char *fsoptions);
>  const char *cdev_mount(struct cdev *cdev);
>  void mount_all(void);
>  
> -void fsdev_set_linux_rootarg(struct fs_device *fsdev, const char *str);
> +void fsdev_set_linux_root_options(struct fs_device *fsdev, const char *root, const char* rootopts);
> +void fsdev_get_linux_root_options(struct fs_device *fsdev, char **root, char **rootopts);
>  char *path_get_linux_rootarg(const char *path);
>  
>  static inline const char *devpath_to_name(const char *devpath)

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |




^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH 3/4] bootm: use new api to get kernel command line params
  2025-11-26 10:25       ` Ahmad Fatoum
@ 2025-11-26 11:29         ` Fabian Pflug
  2025-11-26 11:33           ` Ahmad Fatoum
  0 siblings, 1 reply; 41+ messages in thread
From: Fabian Pflug @ 2025-11-26 11:29 UTC (permalink / raw)
  To: Ahmad Fatoum, barebox

Hey :)

On Wed, 2025-11-26 at 11:25 +0100, Ahmad Fatoum wrote:
> 
> On 11/26/25 7:42 AM, Fabian Pflug wrote:
> > Getting root device adn root kernel options seperatily any combining
> 
> device and root kernel options seperatly and combining
> 
> > them in this function instead of getting the full string from the helper
> > functions. This is in preperation for replacing the root= string in the
> 
> preparation
> 
> > kernel commandline with something defined during runtime.
> > 
> > Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
> > ---
> >  common/bootm.c | 34 ++++++++++++++++++++--------------
> >  1 file changed, 20 insertions(+), 14 deletions(-)
> > 
> > diff --git a/common/bootm.c b/common/bootm.c
> > index 17792b2a1d..5d7dc00e3e 100644
> > --- a/common/bootm.c
> > +++ b/common/bootm.c
> > @@ -4,6 +4,7 @@
> >  #include <bootm.h>
> >  #include <bootm-overrides.h>
> >  #include <fs.h>
> > +#include <fcntl.h>
> >  #include <malloc.h>
> >  #include <memory.h>
> >  #include <block.h>
> > @@ -841,33 +842,38 @@ int bootm_boot(struct bootm_data *bootm_data)
> >  	}
> >  
> >  	if (bootm_data->appendroot) {
> > -		char *rootarg;
> > +		char *root;
> > +		char *rootopts;
> >  
> >  		if (bootm_data->root_dev) {
> >  			const char *root_dev_name = devpath_to_name(bootm_data->root_dev);
> >  			struct cdev *root_cdev = cdev_open_by_name(root_dev_name, O_RDONLY);
> >  
> > -			rootarg = cdev_get_linux_rootarg(root_cdev);
> > -			if (!rootarg) {
> > -				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);
> 
> This warning is useful, because it's very confusing otherwise when a MBR
> disk image is created without a NT signature.
> 
> > -			}
> > +			cdev_get_linux_root_and_opts(root_cdev, &root, &rootopts);
> >  
> >  			if (root_cdev)
> >  				cdev_close(root_cdev);
> > +			else
> > +				pr_err("no cdev found for %s, cannot set root= option\n", root_dev_name);
> >  		} else {
> > -			rootarg = path_get_linux_rootarg(data->os_file);
> 
> path_get_linux_rootarg() is stale now right? Can you squash its removal
> into the patch that gets rid of linux.bootargs?

Then we would have a case, where the function is used, but not available anymore resulting in an unbuildable system,
which I would like to avoid. I can remove it in an extra commit after this one.

> 
> > +			struct fs_device *fsdev = get_fsdevice_by_path(AT_FDCWD, data->os_file);
> > +			if(fsdev)
> > +				fsdev_get_linux_root_options(fsdev, &root, &rootopts);
> > +			else
> > +				pr_err("no fsdevice under path: %s\n", data->os_file);
> >  		}
> >  
> > -		if (IS_ERR(rootarg)) {
> > +		if (!root) {
> >  			pr_err("Failed to append kernel cmdline parameter 'root='\n");
> >  		} else {
> > +			char *rootarg;
> > +			if(rootopts) {
> > +				rootarg = xasprintf("root=%s %s", root, rootopts);
> > +				free(rootopts);
> > +			} else {
> > +				rootarg = xasprintf("root=%s", root);
> > +			}
> 
> I wonder if we should add a helper into a header that does this, given
> how many times this is repeated...
> 
> char *format_root_bootarg(char *root, char *rootopts);
> 
> which consumes (and frees) two pointers and returns a new buffer..

Good thinking. But where do we add it?
* fs.h
* block.h
* bootargs.h

And also, do we add a third parameter? because I will re replaced in the next commit with "%s=%s %s"

And since you proposed to get rid of path_get_linux_rootarg it will be used with two parameters in one place
(cdev_get_linux_rootarg) and with three at the other. (bootm_boot)

Kind regard
Fabian


> 
> Cheers,
> Ahmad
> 
> > +			free(root);
> >  			pr_info("Adding \"%s\" to Kernel commandline\n", rootarg);
> >  			globalvar_add_simple("linux.bootargs.bootm.appendroot",
> >  					     rootarg);



^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH 3/4] bootm: use new api to get kernel command line params
  2025-11-26 11:29         ` Fabian Pflug
@ 2025-11-26 11:33           ` Ahmad Fatoum
  0 siblings, 0 replies; 41+ messages in thread
From: Ahmad Fatoum @ 2025-11-26 11:33 UTC (permalink / raw)
  To: Fabian Pflug, barebox

Hi,

On 11/26/25 12:29 PM, Fabian Pflug wrote:
> Hey :)
> 
> On Wed, 2025-11-26 at 11:25 +0100, Ahmad Fatoum wrote:
>>
>> On 11/26/25 7:42 AM, Fabian Pflug wrote:
>>> Getting root device adn root kernel options seperatily any combining
>>
>> device and root kernel options seperatly and combining
>>
>>> them in this function instead of getting the full string from the helper
>>> functions. This is in preperation for replacing the root= string in the
>>
>> preparation
>>
>>> kernel commandline with something defined during runtime.
>>>
>>> Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
>>> ---
>>>  common/bootm.c | 34 ++++++++++++++++++++--------------
>>>  1 file changed, 20 insertions(+), 14 deletions(-)
>>>
>>> diff --git a/common/bootm.c b/common/bootm.c
>>> index 17792b2a1d..5d7dc00e3e 100644
>>> --- a/common/bootm.c
>>> +++ b/common/bootm.c
>>> @@ -4,6 +4,7 @@
>>>  #include <bootm.h>
>>>  #include <bootm-overrides.h>
>>>  #include <fs.h>
>>> +#include <fcntl.h>
>>>  #include <malloc.h>
>>>  #include <memory.h>
>>>  #include <block.h>
>>> @@ -841,33 +842,38 @@ int bootm_boot(struct bootm_data *bootm_data)
>>>  	}
>>>  
>>>  	if (bootm_data->appendroot) {
>>> -		char *rootarg;
>>> +		char *root;
>>> +		char *rootopts;
>>>  
>>>  		if (bootm_data->root_dev) {
>>>  			const char *root_dev_name = devpath_to_name(bootm_data->root_dev);
>>>  			struct cdev *root_cdev = cdev_open_by_name(root_dev_name, O_RDONLY);
>>>  
>>> -			rootarg = cdev_get_linux_rootarg(root_cdev);
>>> -			if (!rootarg) {
>>> -				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);
>>
>> This warning is useful, because it's very confusing otherwise when a MBR
>> disk image is created without a NT signature.
>>
>>> -			}
>>> +			cdev_get_linux_root_and_opts(root_cdev, &root, &rootopts);
>>>  
>>>  			if (root_cdev)
>>>  				cdev_close(root_cdev);
>>> +			else
>>> +				pr_err("no cdev found for %s, cannot set root= option\n", root_dev_name);
>>>  		} else {
>>> -			rootarg = path_get_linux_rootarg(data->os_file);
>>
>> path_get_linux_rootarg() is stale now right? Can you squash its removal
>> into the patch that gets rid of linux.bootargs?
> 
> Then we would have a case, where the function is used, but not available anymore resulting in an unbuildable system,
> which I would like to avoid. I can remove it in an extra commit after this one.

You will have of course to change the users not to call it anymore.
If you add a later commit removing it, you still have an intermittent
breakage that would trip up a bisect or am I missing something?

> 
>>
>>> +			struct fs_device *fsdev = get_fsdevice_by_path(AT_FDCWD, data->os_file);
>>> +			if(fsdev)
>>> +				fsdev_get_linux_root_options(fsdev, &root, &rootopts);
>>> +			else
>>> +				pr_err("no fsdevice under path: %s\n", data->os_file);
>>>  		}
>>>  
>>> -		if (IS_ERR(rootarg)) {
>>> +		if (!root) {
>>>  			pr_err("Failed to append kernel cmdline parameter 'root='\n");
>>>  		} else {
>>> +			char *rootarg;
>>> +			if(rootopts) {
>>> +				rootarg = xasprintf("root=%s %s", root, rootopts);
>>> +				free(rootopts);
>>> +			} else {
>>> +				rootarg = xasprintf("root=%s", root);
>>> +			}
>>
>> I wonder if we should add a helper into a header that does this, given
>> how many times this is repeated...
>>
>> char *format_root_bootarg(char *root, char *rootopts);
>>
>> which consumes (and frees) two pointers and returns a new buffer..
> 
> Good thinking. But where do we add it?
> * fs.h
> * block.h
> * bootargs.h

bootargs.h sounds suitable.

> 
> And also, do we add a third parameter? because I will re replaced in the next commit with "%s=%s %s"

Noticed that too when I read that far. Ye, three arguments sounds good
to me.

> And since you proposed to get rid of path_get_linux_rootarg it will be used with two parameters in one place
> (cdev_get_linux_rootarg) and with three at the other. (bootm_boot)

Can't follow, but I might when I see the code :-)

Cheers,
Ahmad

> 
> Kind regard
> Fabian
> 
> 
>>
>> Cheers,
>> Ahmad
>>
>>> +			free(root);
>>>  			pr_info("Adding \"%s\" to Kernel commandline\n", rootarg);
>>>  			globalvar_add_simple("linux.bootargs.bootm.appendroot",
>>>  					     rootarg);
> 

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |




^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v2 0/4] make the root= command line parameter variable
  2025-11-26  6:42   ` [PATCH 0/4] make the root= command line parameter variable Fabian Pflug
                       ` (3 preceding siblings ...)
  2025-11-26  6:42     ` [PATCH 4/4] bootm: introduce bootm.root_arg variable Fabian Pflug
@ 2025-11-27 10:57     ` Fabian Pflug
  2025-11-27 10:57       ` [PATCH v2 1/4] block.h: renamed get_rootargs to get_root Fabian Pflug
                         ` (4 more replies)
  4 siblings, 5 replies; 41+ messages in thread
From: Fabian Pflug @ 2025-11-27 10:57 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug

This is v2 of the patchset with the review feedback from Ahmad on the
first set worked in.

This patchset introduces the bootm.root_arg variable. A dynamic way of
setting the root argument in fit image boot contexts, defaulting to
root, resulting in root=/dev/... during kernel boot, but allowing for
overwrites like verity_fs=/dev/..., which can be parsed by the
initramfs, but will not be parsed by the kernel, resulting in robuster
secure boot contexts, where the kernel does not accidental due to
misconfiguration mount the rootfs instead of the initramfs, resulting in
a non-verified boot.

Fabian Pflug (4):
  block.h: renamed get_rootargs to get_root
  fs: split rootargs into root and options
  bootm: use new api to get kernel command line params
  bootm: introduce bootm.root_arg variable

 .../migration-guides/migration-master.rst     | 15 ++++++
 common/block.c                                | 38 +++++++++----
 common/bootm.c                                | 37 +++++++++----
 drivers/mci/mci-core.c                        |  4 +-
 fs/9p/vfs_super.c                             |  6 +--
 fs/fs.c                                       | 53 ++++++++-----------
 fs/nfs.c                                      |  4 +-
 fs/squashfs/squashfs.c                        | 13 +++--
 fs/ubifs/ubifs.c                              | 12 +++--
 include/block.h                               |  7 ++-
 include/bootargs.h                            | 11 ++++
 include/bootm.h                               |  1 +
 include/fs.h                                  |  7 +--
 13 files changed, 135 insertions(+), 73 deletions(-)
 create mode 100644 Documentation/migration-guides/migration-master.rst

-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v2 1/4] block.h: renamed get_rootargs to get_root
  2025-11-27 10:57     ` [PATCH v2 0/4] make the root= command line parameter variable Fabian Pflug
@ 2025-11-27 10:57       ` Fabian Pflug
  2025-11-27 11:08         ` Ahmad Fatoum
  2025-11-27 10:57       ` [PATCH v2 2/4] fs: split rootargs into root and options Fabian Pflug
                         ` (3 subsequent siblings)
  4 siblings, 1 reply; 41+ messages in thread
From: Fabian Pflug @ 2025-11-27 10:57 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug

Don't return the full commandline-parameter, but instead just return the
root block/fs/etc. The functions downstream can add root= before.

This is the first commit in a series to make root= dynamic.

Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
---

Fixed nitpicks

 common/block.c         | 10 ++++++++--
 drivers/mci/mci-core.c |  4 ++--
 include/block.h        |  2 +-
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/common/block.c b/common/block.c
index ca2ed37dbd..ce998243b4 100644
--- a/common/block.c
+++ b/common/block.c
@@ -589,6 +589,7 @@ char *cdev_get_linux_rootarg(const struct cdev *partcdev)
 	const struct cdev *cdevm;
 	struct block_device *blk;
 	char *rootarg = NULL;
+	char *root = NULL;
 
 	if (!partcdev)
 		return NULL;
@@ -598,8 +599,13 @@ char *cdev_get_linux_rootarg(const struct cdev *partcdev)
 	if (!blk)
 		return NULL;
 
-	if (blk->ops->get_rootarg)
-		rootarg = blk->ops->get_rootarg(blk, partcdev);
+	if (blk->ops->get_root) {
+		root = blk->ops->get_root(blk, partcdev);
+		if (root) {
+			rootarg = basprintf("root=%s", root);
+			free(root);
+		}
+	}
 	if (!rootarg && partcdev->partuuid[0] != 0)
 		rootarg = basprintf("root=PARTUUID=%s", partcdev->partuuid);
 
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 57825bc849..206147cb93 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -2691,7 +2691,7 @@ static char *mci_get_linux_mmcblkdev(struct block_device *blk,
 		 * skipping it.
 		 */
 		if (cdev_partname_equal(partcdev, cdev))
-			return basprintf("root=/dev/mmcblk%dp%d", id, partnum);
+			return basprintf("/dev/mmcblk%dp%d", id, partnum);
 		if (cdev->flags & DEVFS_PARTITION_FROM_TABLE)
 			partnum++;
 	}
@@ -2703,7 +2703,7 @@ static struct block_device_ops mci_ops = {
 	.read = mci_sd_read,
 	.write = IS_ENABLED(CONFIG_MCI_WRITE) ? mci_sd_write : NULL,
 	.erase = IS_ENABLED(CONFIG_MCI_ERASE) ? mci_sd_erase : NULL,
-	.get_rootarg = IS_ENABLED(CONFIG_MMCBLKDEV_ROOTARG) ?
+	.get_root = IS_ENABLED(CONFIG_MMCBLKDEV_ROOTARG) ?
 		mci_get_linux_mmcblkdev : NULL,
 };
 
diff --git a/include/block.h b/include/block.h
index fc7a0a32fb..b277f590e4 100644
--- a/include/block.h
+++ b/include/block.h
@@ -14,7 +14,7 @@ struct block_device_ops {
 	int (*write)(struct block_device *, const void *buf, sector_t block, blkcnt_t num_blocks);
 	int (*erase)(struct block_device *blk, sector_t block, blkcnt_t num_blocks);
 	int (*flush)(struct block_device *);
-	char *(*get_rootarg)(struct block_device *blk, const struct cdev *partcdev);
+	char *(*get_root)(struct block_device *blk, const struct cdev *partcdev);
 };
 
 struct chunk;
-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v2 2/4] fs: split rootargs into root and options
  2025-11-27 10:57     ` [PATCH v2 0/4] make the root= command line parameter variable Fabian Pflug
  2025-11-27 10:57       ` [PATCH v2 1/4] block.h: renamed get_rootargs to get_root Fabian Pflug
@ 2025-11-27 10:57       ` Fabian Pflug
  2025-11-27 10:57       ` [PATCH v2 3/4] bootm: use new api to get kernel command line params Fabian Pflug
                         ` (2 subsequent siblings)
  4 siblings, 0 replies; 41+ messages in thread
From: Fabian Pflug @ 2025-11-27 10:57 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug

The rootargs argument (root=/dev/etc rootwait) can be split into the
root and options parts, which makes it easier to manipulate them both
independently. This changes tries to be as backward compatible as
possible and does not change the behaviour of the get functions, but
introduces new ones to get both items seperatly.

Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
---

Added migration-master.rst
Fixed nitpicks
Assign return variables only on success
use xasprintf instead of basprintf in block.c

 .../migration-guides/migration-master.rst     | 15 ++++++
 common/block.c                                | 44 ++++++++++-------
 fs/9p/vfs_super.c                             |  6 +--
 fs/fs.c                                       | 47 +++++++++++++------
 fs/nfs.c                                      |  4 +-
 fs/squashfs/squashfs.c                        | 13 +++--
 fs/ubifs/ubifs.c                              | 12 +++--
 include/block.h                               |  5 ++
 include/bootargs.h                            | 11 +++++
 include/fs.h                                  |  6 ++-
 10 files changed, 115 insertions(+), 48 deletions(-)
 create mode 100644 Documentation/migration-guides/migration-master.rst

diff --git a/Documentation/migration-guides/migration-master.rst b/Documentation/migration-guides/migration-master.rst
new file mode 100644
index 0000000000..0d6cfcad57
--- /dev/null
+++ b/Documentation/migration-guides/migration-master.rst
@@ -0,0 +1,15 @@
+Filesystems
+-----------
+
+{linux.bootargs} is replaced with "root={linux.bootargs.root} {linux.bootargs.rootopts}"
+
+The variable linux.bootargs has been replaced by the two variables
+linux.bootargs.root and linux.bootargs.rootopts, splitting the previous bootargs
+into three parts. A nonexistent fixed "root=", then the root filesystem and then
+additional optional params for this particular filesystem.
+
+for example the previous
+    linux.bootargs="root=/dev/nfs nfsroot=192.168.1.1:/rootfs"
+becomes
+    linux.bootargs.root="/dev/nfs"
+    linux.bootargs.rootopts="nfsroot=192.168.1.1:/rootfs"
diff --git a/common/block.c b/common/block.c
index ce998243b4..d59175f579 100644
--- a/common/block.c
+++ b/common/block.c
@@ -584,34 +584,44 @@ const char *blk_type_str(enum blk_type type)
 	}
 }
 
-char *cdev_get_linux_rootarg(const struct cdev *partcdev)
-{
+int cdev_get_linux_root_and_opts(const struct cdev *partcdev, char **root, char **rootopts) {
+
 	const struct cdev *cdevm;
 	struct block_device *blk;
-	char *rootarg = NULL;
-	char *root = NULL;
+	char *root_local = NULL;
 
 	if (!partcdev)
-		return NULL;
+		return -EINVAL;
 
 	cdevm = partcdev->master ?: partcdev;
 	blk = cdev_get_block_device(cdevm);
 	if (!blk)
-		return NULL;
+		return -EINVAL;
 
-	if (blk->ops->get_root) {
-		root = blk->ops->get_root(blk, partcdev);
-		if (root) {
-			rootarg = basprintf("root=%s", root);
-			free(root);
-		}
-	}
-	if (!rootarg && partcdev->partuuid[0] != 0)
-		rootarg = basprintf("root=PARTUUID=%s", partcdev->partuuid);
+	if (blk->ops->get_root)
+		root_local = blk->ops->get_root(blk, partcdev);
+	if (!root_local && partcdev->partuuid[0] != 0)
+		root_local = xasprintf("PARTUUID=%s", partcdev->partuuid);
+
+	if (!root_local)
+		return -ENODEV;
 
 	if (IS_ENABLED(CONFIG_ROOTWAIT_BOOTARG) && blk->rootwait)
-		rootarg = linux_bootargs_append_rootwait(rootarg);
+		*rootopts = xasprintf("rootwait=%d", linux_rootwait_secs);
 
-	return rootarg;
+	root = root_local
+	return 0;
 }
 
+char *cdev_get_linux_rootarg(const struct cdev *partcdev)
+{
+	int err;
+	char* root;
+	char* rootopts;
+
+	err = cdev_get_linux_root_and_opts(partcdev, &root, &rootopts);
+	if (IS_ERR(err))
+		return NULL;
+
+	return format_root_bootarg("root", root, rootopts);
+}
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
index 6a451d9ef5..efc9a9193d 100644
--- a/fs/9p/vfs_super.c
+++ b/fs/9p/vfs_super.c
@@ -70,11 +70,11 @@ static void v9fs_set_rootarg(struct v9fs_session_info *v9ses,
 	trans = v9ses->clnt->trans_mod->name;
 	path = v9ses->aname;
 
-	str = basprintf("root=%s rootfstype=9p rootflags=trans=%s,msize=%d,"
+	str = basprintf("rootfstype=9p rootflags=trans=%s,msize=%d,"
 			"cache=loose,uname=%s,dfltuid=0,dfltgid=0,aname=%s",
-			tag, trans, v9ses->clnt->msize, tag, path);
+			trans, v9ses->clnt->msize, tag, path);
 
-	fsdev_set_linux_rootarg(fsdev, str);
+	fsdev_set_linux_root_options(fsdev, tag, str);
 
 	free(str);
 }
diff --git a/fs/fs.c b/fs/fs.c
index 528299e039..f3b759b20a 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -14,6 +14,7 @@
  *
  */
 
+#include <bootargs.h>
 #include <common.h>
 #include <command.h>
 #include <fs.h>
@@ -1226,12 +1227,23 @@ void mount_all(void)
 	}
 }
 
-void fsdev_set_linux_rootarg(struct fs_device *fsdev, const char *str)
+void fsdev_set_linux_root_options(struct fs_device *fsdev, const char *root, const char *rootopts)
 {
-	fsdev->linux_rootarg = xstrdup(str);
+	fsdev->linux_root = xstrdup(root);
+	fsdev->linux_rootopts = xstrdup(rootopts);
 
-	dev_add_param_fixed(&fsdev->dev, "linux.bootargs",
-			    "%s", fsdev->linux_rootarg);
+	dev_add_param_fixed(&fsdev->dev, "linux.bootargs.root",
+			    "%s", fsdev->linux_root);
+	dev_add_param_fixed(&fsdev->dev, "linux.bootargs.rootopts",
+			    "%s", fsdev->linux_rootopts);
+}
+
+void fsdev_get_linux_root_options(struct fs_device *fsdev, char **root, char **rootopts)
+{
+	if (fsdev) {
+		*root = dev_get_param(&fsdev->dev, "linux.bootargs.root");
+		*rootopts = dev_get_param(&fsdev->dev, "linux.bootargs.rootopts");
+	}
 }
 
 /**
@@ -1245,17 +1257,19 @@ void fsdev_set_linux_rootarg(struct fs_device *fsdev, const char *str)
 char *path_get_linux_rootarg(const char *path)
 {
 	struct fs_device *fsdev;
-	const char *str;
+	char *root = NULL;
+	char *rootopts = NULL;
 
 	fsdev = get_fsdevice_by_path(AT_FDCWD, path);
 	if (!fsdev)
 		return ERR_PTR(-EINVAL);
 
-	str = dev_get_param(&fsdev->dev, "linux.bootargs");
-	if (!str)
-		return ERR_PTR(-ENOSYS);
+	fsdev_get_linux_root_options(fsdev, &root, &rootopts);
 
-	return xstrdup(str);
+	if (!root)
+		return ERR_PTR(-EINVAL);
+
+	return format_root_bootarg("root", root, rootopts);
 }
 
 /**
@@ -3249,12 +3263,17 @@ int mount(const char *device, const char *fsname, const char *pathname,
 
 	fsdev->vfsmount.mnt_root = fsdev->sb.s_root;
 
-	if (!fsdev->linux_rootarg) {
-		char *str;
+	if (!fsdev->linux_root) {
+		char *root;
+		char *rootopts;
 
-		str = cdev_get_linux_rootarg(fsdev->cdev);
-		if (str)
-			fsdev_set_linux_rootarg(fsdev, str);
+		cdev_get_linux_root_and_opts(fsdev->cdev, &root, &rootopts);
+		if (root) {
+			fsdev_set_linux_root_options(fsdev, root, rootopts);
+			free(root);
+			if(rootopts)
+				free(rootopts);
+		}
 	}
 
 	path_put(&path);
diff --git a/fs/nfs.c b/fs/nfs.c
index 5c2476cd88..0b40c56ff3 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -1558,7 +1558,7 @@ static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device *fsdev)
 	char *str, *tmp;
 	const char *bootargs;
 
-	str = basprintf("root=/dev/nfs nfsroot=%pI4:%s%s%s", &npriv->server, npriv->path,
+	str = basprintf("nfsroot=%pI4:%s%s%s", &npriv->server, npriv->path,
 			  rootnfsopts[0] ? "," : "", rootnfsopts);
 
 	/* forward specific mount options on demand */
@@ -1584,7 +1584,7 @@ static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device *fsdev)
 	if (IS_ENABLED(CONFIG_ROOTWAIT_BOOTARG))
 		str = linux_bootargs_append_rootwait(str);
 
-	fsdev_set_linux_rootarg(fsdev, str);
+	fsdev_set_linux_root_options(fsdev, "/dev/nfs", str);
 
 	free(str);
 }
diff --git a/fs/squashfs/squashfs.c b/fs/squashfs/squashfs.c
index e30372627a..365aa1f219 100644
--- a/fs/squashfs/squashfs.c
+++ b/fs/squashfs/squashfs.c
@@ -46,7 +46,8 @@ static void squashfs_set_rootarg(struct fs_device *fsdev)
 	struct ubi_volume_info vi = {};
 	struct ubi_device_info di = {};
 	struct mtd_info *mtd;
-	char *str;
+	char *root;
+	char *rootopts;
 
 	if (!IS_ENABLED(CONFIG_MTD_UBI))
 		return;
@@ -60,12 +61,14 @@ static void squashfs_set_rootarg(struct fs_device *fsdev)
 	ubi_get_device_info(vi.ubi_num, &di);
 	mtd = di.mtd;
 
-	str = basprintf("root=/dev/ubiblock%d_%d ubi.mtd=%s ubi.block=%d,%d rootfstype=squashfs",
-			vi.ubi_num, vi.vol_id, mtd->cdev.partname, vi.ubi_num, vi.vol_id);
+	root = basprintf("/dev/ubiblock%d_%d", vi.ubi_num, vi.vol_id);
+	rootopts = basprintf("ubi.mtd=%s ubi.block=%d,%d rootfstype=squashfs",
+			mtd->cdev.partname, vi.ubi_num, vi.vol_id);
 
-	fsdev_set_linux_rootarg(fsdev, str);
+	fsdev_set_linux_root_options(fsdev, root, rootopts);
 
-	free(str);
+	free(root);
+	free(rootopts);
 }
 
 static struct inode *squashfs_alloc_inode(struct super_block *sb)
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 37986acbb2..9cc35fa273 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -435,19 +435,21 @@ static void ubifs_set_rootarg(struct ubifs_priv *priv,
 	struct ubi_volume_info vi = {};
 	struct ubi_device_info di = {};
 	struct mtd_info *mtd;
-	char *str;
+	char *root;
+	char *rootopts;
 
 	ubi_get_volume_info(priv->ubi, &vi);
 	ubi_get_device_info(vi.ubi_num, &di);
 
 	mtd = di.mtd;
 
-	str = basprintf("root=ubi0:%s ubi.mtd=%s rootfstype=ubifs",
-			  vi.name, mtd->cdev.partname);
+	root = basprintf("ubi0:%s", vi.name);
+	rootopts = basprintf("ubi.mtd=%s rootfstype=ubifs", mtd->cdev.partname);
 
-	fsdev_set_linux_rootarg(fsdev, str);
+	fsdev_set_linux_root_options(fsdev, root, rootopts);
 
-	free(str);
+	free(root);
+	free(rootopts);
 }
 
 static int ubifs_probe(struct device *dev)
diff --git a/include/block.h b/include/block.h
index b277f590e4..ff18dcded0 100644
--- a/include/block.h
+++ b/include/block.h
@@ -85,6 +85,7 @@ static inline int block_flush(struct block_device *blk)
 #ifdef CONFIG_BLOCK
 unsigned file_list_add_blockdevs(struct file_list *files);
 char *cdev_get_linux_rootarg(const struct cdev *partcdev);
+int cdev_get_linux_root_and_opts(const struct cdev *partcdev, char** root, char** rootopts);
 #else
 static inline unsigned file_list_add_blockdevs(struct file_list *files)
 {
@@ -94,6 +95,10 @@ static inline char *cdev_get_linux_rootarg(const struct cdev *partcdev)
 {
 	return NULL;
 }
+static inline void cdev_get_linux_root_and_opts(const struct cdev *partcdev, char** root, char** rootopts)
+{
+	return -ENOSYS;
+}
 #endif
 
 static inline bool cdev_is_block_device(const struct cdev *cdev)
diff --git a/include/bootargs.h b/include/bootargs.h
index 1cf88bd380..45cd10ac3d 100644
--- a/include/bootargs.h
+++ b/include/bootargs.h
@@ -26,4 +26,15 @@ static inline char *linux_bootargs_append_rootwait(char *rootarg)
 }
 #endif
 
+static inline char *format_root_bootarg(const char *root_arg, char *root, char *rootopts) {
+	char *bootarg;
+	if (rootopts)
+		bootarg = xasprintf("%s=%s %s", root_arg, root, rootopts)
+	else
+		bootarg = xasprintf("%s=%s", root_arg, root)
+	free(root)
+	free(rootopts)
+	return bootarg
+}
+
 #endif /* __BOOTARGS_H */
diff --git a/include/fs.h b/include/fs.h
index 98c482bbf2..c50437d609 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -90,7 +90,8 @@ struct fs_device {
 	char *path;
 	struct list_head list;
 	char *options;
-	char *linux_rootarg;
+	char *linux_root;
+	char *linux_rootopts;
 
 	struct super_block sb;
 
@@ -159,7 +160,8 @@ const char *cdev_mount_default(struct cdev *cdev, const char *fsoptions);
 const char *cdev_mount(struct cdev *cdev);
 void mount_all(void);
 
-void fsdev_set_linux_rootarg(struct fs_device *fsdev, const char *str);
+void fsdev_set_linux_root_options(struct fs_device *fsdev, const char *root, const char* rootopts);
+void fsdev_get_linux_root_options(struct fs_device *fsdev, char **root, char **rootopts);
 char *path_get_linux_rootarg(const char *path);
 
 static inline const char *devpath_to_name(const char *devpath)
-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v2 3/4] bootm: use new api to get kernel command line params
  2025-11-27 10:57     ` [PATCH v2 0/4] make the root= command line parameter variable Fabian Pflug
  2025-11-27 10:57       ` [PATCH v2 1/4] block.h: renamed get_rootargs to get_root Fabian Pflug
  2025-11-27 10:57       ` [PATCH v2 2/4] fs: split rootargs into root and options Fabian Pflug
@ 2025-11-27 10:57       ` Fabian Pflug
  2025-11-27 10:57       ` [PATCH v2 4/4] bootm: introduce bootm.root_arg variable Fabian Pflug
  2025-11-27 14:25       ` [PATCH v3 0/4] make the root= command line parameter variable Fabian Pflug
  4 siblings, 0 replies; 41+ messages in thread
From: Fabian Pflug @ 2025-11-27 10:57 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug

Getting root device adn root kernel options seperatily any combining
them in this function instead of getting the full string from the helper
functions. This is in preperation for replacing the root= string in the
kernel commandline with something defined during runtime.

Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
---

restore warning for PARTUUID

 common/bootm.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 17792b2a1d..562e469552 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -4,6 +4,7 @@
 #include <bootm.h>
 #include <bootm-overrides.h>
 #include <fs.h>
+#include <fcntl.h>
 #include <malloc.h>
 #include <memory.h>
 #include <block.h>
@@ -841,33 +842,40 @@ int bootm_boot(struct bootm_data *bootm_data)
 	}
 
 	if (bootm_data->appendroot) {
-		char *rootarg;
+		char *root = NULL;
+		char *rootopts = NULL;
 
 		if (bootm_data->root_dev) {
 			const char *root_dev_name = devpath_to_name(bootm_data->root_dev);
 			struct cdev *root_cdev = cdev_open_by_name(root_dev_name, O_RDONLY);
+			int err;
 
-			rootarg = cdev_get_linux_rootarg(root_cdev);
-			if (!rootarg) {
-				rootarg = ERR_PTR(-EINVAL);
+			err = cdev_get_linux_root_and_opts(root_cdev, &root, &rootopts);
 
+			if (IS_ERR(err)) {
 				if (!root_cdev)
-					pr_err("no cdev found for %s, cannot set root= option\n",
-						root_dev_name);
+					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);
+					pr_err("%s doesn't have a PARTUUID, cannot set root= option\n", root_dev_name);
+				else
+					pr_err("could not determine root= from %s\n", root_dev_name);
 			}
 
 			if (root_cdev)
 				cdev_close(root_cdev);
 		} else {
-			rootarg = path_get_linux_rootarg(data->os_file);
+			struct fs_device *fsdev = get_fsdevice_by_path(AT_FDCWD, data->os_file);
+			if (fsdev)
+				fsdev_get_linux_root_options(fsdev, &root, &rootopts);
+			else
+				pr_err("no fsdevice under path: %s\n", data->os_file);
 		}
 
-		if (IS_ERR(rootarg)) {
+		if (!root) {
 			pr_err("Failed to append kernel cmdline parameter 'root='\n");
 		} else {
+			char *rootarg;
+			rootarg = format_root_bootarg("root", root, rootopts);
 			pr_info("Adding \"%s\" to Kernel commandline\n", rootarg);
 			globalvar_add_simple("linux.bootargs.bootm.appendroot",
 					     rootarg);
-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v2 4/4] bootm: introduce bootm.root_arg variable
  2025-11-27 10:57     ` [PATCH v2 0/4] make the root= command line parameter variable Fabian Pflug
                         ` (2 preceding siblings ...)
  2025-11-27 10:57       ` [PATCH v2 3/4] bootm: use new api to get kernel command line params Fabian Pflug
@ 2025-11-27 10:57       ` Fabian Pflug
  2025-11-27 14:25       ` [PATCH v3 0/4] make the root= command line parameter variable Fabian Pflug
  4 siblings, 0 replies; 41+ messages in thread
From: Fabian Pflug @ 2025-11-27 10:57 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug

The bootm.root_arg variable will be responsible for the root= part of
the kernel commandline if bootm.appendroot is set and a root device has
been selected.
root_arg allows to replace the root=/dev/... with verity=/dev/..., which
is useful in a verified boot context, where you pass the root file
system to the initramfs, but do not want the kernel to be able to parse
and mount the rootfs. With renaming the root= to something different,
you make sure, that the kernel does not mount the rootfs.

Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
---

added parameter to device text

 common/bootm.c  | 17 ++++++++++++-----
 fs/fs.c         | 26 --------------------------
 include/bootm.h |  1 +
 include/fs.h    |  1 -
 4 files changed, 13 insertions(+), 32 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 562e469552..42312227c2 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -69,6 +69,7 @@ void bootm_data_init_defaults(struct bootm_data *data)
 		data->initrd_file = getenv_nonempty("global.bootm.initrd");
 	}
 	data->root_dev = getenv_nonempty("global.bootm.root_dev");
+	data->root_arg = getenv_nonempty("global.bootm.root_arg");
 	data->verify = bootm_get_verify_mode();
 	data->appendroot = bootm_appendroot;
 	data->provide_machine_id = bootm_provide_machine_id;
@@ -88,6 +89,7 @@ void bootm_data_restore_defaults(const struct bootm_data *data)
 		globalvar_set("bootm.initrd", data->initrd_file);
 	}
 	globalvar_set("bootm.root_dev", data->root_dev);
+	globalvar_set("bootm.root_arg", data->root_arg);
 	bootm_set_verify_mode(data->verify);
 	bootm_appendroot = data->appendroot;
 	bootm_provide_machine_id = data->provide_machine_id;
@@ -854,11 +856,14 @@ int bootm_boot(struct bootm_data *bootm_data)
 
 			if (IS_ERR(err)) {
 				if (!root_cdev)
-					pr_err("no cdev found for %s, cannot set root= option\n", root_dev_name);
+					pr_err("no cdev found for %s, cannot set %s= option\n",
+						root_dev_name, bootm_data->root_arg);
 				else if (!root_cdev->partuuid[0])
-					pr_err("%s doesn't have a PARTUUID, cannot set root= option\n", root_dev_name);
+					pr_err("%s doesn't have a PARTUUID, cannot set %s= option\n",
+						root_dev_name, bootm_data->root_arg);
 				else
-					pr_err("could not determine root= from %s\n", root_dev_name);
+					pr_err("could not determine %s= from %s\n",
+						bootm_data->root_arg, root_dev_name);
 			}
 
 			if (root_cdev)
@@ -872,10 +877,10 @@ int bootm_boot(struct bootm_data *bootm_data)
 		}
 
 		if (!root) {
-			pr_err("Failed to append kernel cmdline parameter 'root='\n");
+			pr_err("Failed to append kernel cmdline parameter '%s='\n", bootm_data->root_arg);
 		} else {
 			char *rootarg;
-			rootarg = format_root_bootarg("root", root, rootopts);
+			rootarg = format_root_bootarg(bootm_data->root_arg, root, rootopts);
 			pr_info("Adding \"%s\" to Kernel commandline\n", rootarg);
 			globalvar_add_simple("linux.bootargs.bootm.appendroot",
 					     rootarg);
@@ -1118,6 +1123,7 @@ static int bootm_init(void)
 	globalvar_add_simple("bootm.image.loadaddr", NULL);
 	globalvar_add_simple("bootm.oftree", NULL);
 	globalvar_add_simple("bootm.root_dev", NULL);
+	globalvar_add_simple("bootm.root_arg", "root");
 	globalvar_add_simple("bootm.tee", NULL);
 	globalvar_add_simple_bool("bootm.appendroot", &bootm_appendroot);
 	globalvar_add_simple_bool("bootm.earlycon", &bootm_earlycon);
@@ -1175,5 +1181,6 @@ BAREBOX_MAGICVAR(global.bootm.verbose, "bootm default verbosity level (0=quiet)"
 BAREBOX_MAGICVAR(global.bootm.earlycon, "Add earlycon option to Kernel for early log output");
 BAREBOX_MAGICVAR(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(global.bootm.root_dev, "bootm default root device (overrides default device in global.bootm.appendroot)");
+BAREBOX_MAGICVAR(global.bootm.root_arg, "bootm default parameter name arg for the root partition (normally 'root' for root=/dev/...)");
 BAREBOX_MAGICVAR(global.bootm.provide_machine_id, "If true, append systemd.machine_id=$global.machine_id to Kernel command line");
 BAREBOX_MAGICVAR(global.bootm.provide_hostname, "If true, append systemd.hostname=$global.hostname to Kernel command line");
diff --git a/fs/fs.c b/fs/fs.c
index f3b759b20a..6540bcdd11 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -1246,32 +1246,6 @@ void fsdev_get_linux_root_options(struct fs_device *fsdev, char **root, char **r
 	}
 }
 
-/**
- * path_get_linux_rootarg() - Given a path return a suitable root= option for
- *                            Linux
- * @path: The path
- *
- * Return: A string containing the root= option or an ERR_PTR. the returned
- *         string must be freed by the caller.
- */
-char *path_get_linux_rootarg(const char *path)
-{
-	struct fs_device *fsdev;
-	char *root = NULL;
-	char *rootopts = NULL;
-
-	fsdev = get_fsdevice_by_path(AT_FDCWD, path);
-	if (!fsdev)
-		return ERR_PTR(-EINVAL);
-
-	fsdev_get_linux_root_options(fsdev, &root, &rootopts);
-
-	if (!root)
-		return ERR_PTR(-EINVAL);
-
-	return format_root_bootarg("root", root, rootopts);
-}
-
 /**
  * __is_tftp_fs() - return true when path is mounted on TFTP
  * @path: The path
diff --git a/include/bootm.h b/include/bootm.h
index b35deb25bf..43f4258885 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -19,6 +19,7 @@ struct bootm_data {
 	const char *oftree_file;
 	const char *tee_file;
 	const char *root_dev;
+	const char *root_arg;
 	int verbose;
 	enum bootm_verify verify;
 	bool force;
diff --git a/include/fs.h b/include/fs.h
index c50437d609..ddd93e93ec 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -162,7 +162,6 @@ void mount_all(void);
 
 void fsdev_set_linux_root_options(struct fs_device *fsdev, const char *root, const char* rootopts);
 void fsdev_get_linux_root_options(struct fs_device *fsdev, char **root, char **rootopts);
-char *path_get_linux_rootarg(const char *path);
 
 static inline const char *devpath_to_name(const char *devpath)
 {
-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 1/4] block.h: renamed get_rootargs to get_root
  2025-11-27 10:57       ` [PATCH v2 1/4] block.h: renamed get_rootargs to get_root Fabian Pflug
@ 2025-11-27 11:08         ` Ahmad Fatoum
  0 siblings, 0 replies; 41+ messages in thread
From: Ahmad Fatoum @ 2025-11-27 11:08 UTC (permalink / raw)
  To: Fabian Pflug, barebox

Hi,

On 11/27/25 11:57 AM, Fabian Pflug wrote:
> Don't return the full commandline-parameter, but instead just return the
> root block/fs/etc. The functions downstream can add root= before.
> 
> This is the first commit in a series to make root= dynamic.
> 
> Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

> +	char *root = NULL;

Scope could be reduced, but you don't need to resend just for that.

Thanks,
Ahmad


>  
>  	if (!partcdev)
>  		return NULL;
> @@ -598,8 +599,13 @@ char *cdev_get_linux_rootarg(const struct cdev *partcdev)
>  	if (!blk)
>  		return NULL;
>  
> -	if (blk->ops->get_rootarg)
> -		rootarg = blk->ops->get_rootarg(blk, partcdev);
> +	if (blk->ops->get_root) {
> +		root = blk->ops->get_root(blk, partcdev);
> +		if (root) {
> +			rootarg = basprintf("root=%s", root);
> +			free(root);
> +		}
> +	}
>  	if (!rootarg && partcdev->partuuid[0] != 0)
>  		rootarg = basprintf("root=PARTUUID=%s", partcdev->partuuid);
>  
> diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
> index 57825bc849..206147cb93 100644
> --- a/drivers/mci/mci-core.c
> +++ b/drivers/mci/mci-core.c
> @@ -2691,7 +2691,7 @@ static char *mci_get_linux_mmcblkdev(struct block_device *blk,
>  		 * skipping it.
>  		 */
>  		if (cdev_partname_equal(partcdev, cdev))
> -			return basprintf("root=/dev/mmcblk%dp%d", id, partnum);
> +			return basprintf("/dev/mmcblk%dp%d", id, partnum);
>  		if (cdev->flags & DEVFS_PARTITION_FROM_TABLE)
>  			partnum++;
>  	}
> @@ -2703,7 +2703,7 @@ static struct block_device_ops mci_ops = {
>  	.read = mci_sd_read,
>  	.write = IS_ENABLED(CONFIG_MCI_WRITE) ? mci_sd_write : NULL,
>  	.erase = IS_ENABLED(CONFIG_MCI_ERASE) ? mci_sd_erase : NULL,
> -	.get_rootarg = IS_ENABLED(CONFIG_MMCBLKDEV_ROOTARG) ?
> +	.get_root = IS_ENABLED(CONFIG_MMCBLKDEV_ROOTARG) ?
>  		mci_get_linux_mmcblkdev : NULL,
>  };
>  
> diff --git a/include/block.h b/include/block.h
> index fc7a0a32fb..b277f590e4 100644
> --- a/include/block.h
> +++ b/include/block.h
> @@ -14,7 +14,7 @@ struct block_device_ops {
>  	int (*write)(struct block_device *, const void *buf, sector_t block, blkcnt_t num_blocks);
>  	int (*erase)(struct block_device *blk, sector_t block, blkcnt_t num_blocks);
>  	int (*flush)(struct block_device *);
> -	char *(*get_rootarg)(struct block_device *blk, const struct cdev *partcdev);
> +	char *(*get_root)(struct block_device *blk, const struct cdev *partcdev);
>  };
>  
>  struct chunk;

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |




^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 0/4] make the root= command line parameter variable
  2025-11-27 10:57     ` [PATCH v2 0/4] make the root= command line parameter variable Fabian Pflug
                         ` (3 preceding siblings ...)
  2025-11-27 10:57       ` [PATCH v2 4/4] bootm: introduce bootm.root_arg variable Fabian Pflug
@ 2025-11-27 14:25       ` Fabian Pflug
  2025-11-27 14:25         ` [PATCH v3 1/4] block.h: renamed get_rootargs to get_root Fabian Pflug
                           ` (4 more replies)
  4 siblings, 5 replies; 41+ messages in thread
From: Fabian Pflug @ 2025-11-27 14:25 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug

Please ignore the v2 variant. I must have been drunk when writing it.

changes compared to v2:
- fix compile errors
- move format_root_bootarg into fs.c

Fabian Pflug (4):
  block.h: renamed get_rootargs to get_root
  fs: split rootargs into root and options
  bootm: use new api to get kernel command line params
  bootm: introduce bootm.root_arg variable

 .../migration-guides/migration-master.rst     | 15 +++++
 common/block.c                                | 38 ++++++++----
 common/bootm.c                                | 37 +++++++----
 drivers/mci/mci-core.c                        |  4 +-
 fs/9p/vfs_super.c                             |  6 +-
 fs/fs.c                                       | 62 ++++++++++---------
 fs/nfs.c                                      |  4 +-
 fs/squashfs/squashfs.c                        | 13 ++--
 fs/ubifs/ubifs.c                              | 12 ++--
 include/block.h                               |  7 ++-
 include/bootargs.h                            |  2 +
 include/bootm.h                               |  1 +
 include/fs.h                                  |  7 ++-
 13 files changed, 136 insertions(+), 72 deletions(-)
 create mode 100644 Documentation/migration-guides/migration-master.rst

-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 1/4] block.h: renamed get_rootargs to get_root
  2025-11-27 14:25       ` [PATCH v3 0/4] make the root= command line parameter variable Fabian Pflug
@ 2025-11-27 14:25         ` Fabian Pflug
  2025-11-28  9:45           ` Ahmad Fatoum
  2025-11-27 14:25         ` [PATCH v3 2/4] fs: split rootargs into root and options Fabian Pflug
                           ` (3 subsequent siblings)
  4 siblings, 1 reply; 41+ messages in thread
From: Fabian Pflug @ 2025-11-27 14:25 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug

Don't return the full commandline-parameter, but instead just return the
root block/fs/etc. The functions downstream can add root= before.

This is the first commit in a series to make root= dynamic.

Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
---
 common/block.c         | 10 ++++++++--
 drivers/mci/mci-core.c |  4 ++--
 include/block.h        |  2 +-
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/common/block.c b/common/block.c
index ca2ed37dbd..07c4d5d504 100644
--- a/common/block.c
+++ b/common/block.c
@@ -598,8 +598,14 @@ char *cdev_get_linux_rootarg(const struct cdev *partcdev)
 	if (!blk)
 		return NULL;
 
-	if (blk->ops->get_rootarg)
-		rootarg = blk->ops->get_rootarg(blk, partcdev);
+	if (blk->ops->get_root) {
+		char *root = NULL;
+		root = blk->ops->get_root(blk, partcdev);
+		if (root) {
+			rootarg = basprintf("root=%s", root);
+			free(root);
+		}
+	}
 	if (!rootarg && partcdev->partuuid[0] != 0)
 		rootarg = basprintf("root=PARTUUID=%s", partcdev->partuuid);
 
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 57825bc849..206147cb93 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -2691,7 +2691,7 @@ static char *mci_get_linux_mmcblkdev(struct block_device *blk,
 		 * skipping it.
 		 */
 		if (cdev_partname_equal(partcdev, cdev))
-			return basprintf("root=/dev/mmcblk%dp%d", id, partnum);
+			return basprintf("/dev/mmcblk%dp%d", id, partnum);
 		if (cdev->flags & DEVFS_PARTITION_FROM_TABLE)
 			partnum++;
 	}
@@ -2703,7 +2703,7 @@ static struct block_device_ops mci_ops = {
 	.read = mci_sd_read,
 	.write = IS_ENABLED(CONFIG_MCI_WRITE) ? mci_sd_write : NULL,
 	.erase = IS_ENABLED(CONFIG_MCI_ERASE) ? mci_sd_erase : NULL,
-	.get_rootarg = IS_ENABLED(CONFIG_MMCBLKDEV_ROOTARG) ?
+	.get_root = IS_ENABLED(CONFIG_MMCBLKDEV_ROOTARG) ?
 		mci_get_linux_mmcblkdev : NULL,
 };
 
diff --git a/include/block.h b/include/block.h
index fc7a0a32fb..b277f590e4 100644
--- a/include/block.h
+++ b/include/block.h
@@ -14,7 +14,7 @@ struct block_device_ops {
 	int (*write)(struct block_device *, const void *buf, sector_t block, blkcnt_t num_blocks);
 	int (*erase)(struct block_device *blk, sector_t block, blkcnt_t num_blocks);
 	int (*flush)(struct block_device *);
-	char *(*get_rootarg)(struct block_device *blk, const struct cdev *partcdev);
+	char *(*get_root)(struct block_device *blk, const struct cdev *partcdev);
 };
 
 struct chunk;
-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 2/4] fs: split rootargs into root and options
  2025-11-27 14:25       ` [PATCH v3 0/4] make the root= command line parameter variable Fabian Pflug
  2025-11-27 14:25         ` [PATCH v3 1/4] block.h: renamed get_rootargs to get_root Fabian Pflug
@ 2025-11-27 14:25         ` Fabian Pflug
  2025-11-28 10:01           ` Ahmad Fatoum
  2025-11-27 14:25         ` [PATCH v3 3/4] bootm: use new api to get kernel command line params Fabian Pflug
                           ` (2 subsequent siblings)
  4 siblings, 1 reply; 41+ messages in thread
From: Fabian Pflug @ 2025-11-27 14:25 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug

The rootargs argument (root=/dev/etc rootwait) can be split into the
root and options parts, which makes it easier to manipulate them both
independently. This changes tries to be as backward compatible as
possible and does not change the behaviour of the get functions, but
introduces new ones to get both items seperatly.

Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
---
 .../migration-guides/migration-master.rst     | 15 +++++
 common/block.c                                | 44 ++++++++------
 fs/9p/vfs_super.c                             |  6 +-
 fs/fs.c                                       | 58 ++++++++++++++-----
 fs/nfs.c                                      |  4 +-
 fs/squashfs/squashfs.c                        | 13 +++--
 fs/ubifs/ubifs.c                              | 12 ++--
 include/block.h                               |  5 ++
 include/bootargs.h                            |  2 +
 include/fs.h                                  |  6 +-
 10 files changed, 117 insertions(+), 48 deletions(-)
 create mode 100644 Documentation/migration-guides/migration-master.rst

diff --git a/Documentation/migration-guides/migration-master.rst b/Documentation/migration-guides/migration-master.rst
new file mode 100644
index 0000000000..0d6cfcad57
--- /dev/null
+++ b/Documentation/migration-guides/migration-master.rst
@@ -0,0 +1,15 @@
+Filesystems
+-----------
+
+{linux.bootargs} is replaced with "root={linux.bootargs.root} {linux.bootargs.rootopts}"
+
+The variable linux.bootargs has been replaced by the two variables
+linux.bootargs.root and linux.bootargs.rootopts, splitting the previous bootargs
+into three parts. A nonexistent fixed "root=", then the root filesystem and then
+additional optional params for this particular filesystem.
+
+for example the previous
+    linux.bootargs="root=/dev/nfs nfsroot=192.168.1.1:/rootfs"
+becomes
+    linux.bootargs.root="/dev/nfs"
+    linux.bootargs.rootopts="nfsroot=192.168.1.1:/rootfs"
diff --git a/common/block.c b/common/block.c
index 07c4d5d504..b46b9305c8 100644
--- a/common/block.c
+++ b/common/block.c
@@ -584,34 +584,44 @@ const char *blk_type_str(enum blk_type type)
 	}
 }
 
-char *cdev_get_linux_rootarg(const struct cdev *partcdev)
-{
+int cdev_get_linux_root_and_opts(const struct cdev *partcdev, char **root, char **rootopts) {
+
 	const struct cdev *cdevm;
 	struct block_device *blk;
-	char *rootarg = NULL;
+	char *root_local = NULL;
 
 	if (!partcdev)
-		return NULL;
+		return -EINVAL;
 
 	cdevm = partcdev->master ?: partcdev;
 	blk = cdev_get_block_device(cdevm);
 	if (!blk)
-		return NULL;
+		return -EINVAL;
 
-	if (blk->ops->get_root) {
-		char *root = NULL;
-		root = blk->ops->get_root(blk, partcdev);
-		if (root) {
-			rootarg = basprintf("root=%s", root);
-			free(root);
-		}
-	}
-	if (!rootarg && partcdev->partuuid[0] != 0)
-		rootarg = basprintf("root=PARTUUID=%s", partcdev->partuuid);
+	if (blk->ops->get_root)
+		root_local = blk->ops->get_root(blk, partcdev);
+	if (!root_local && partcdev->partuuid[0] != 0)
+		root_local = xasprintf("PARTUUID=%s", partcdev->partuuid);
+
+	if (!root_local)
+		return -ENODEV;
 
 	if (IS_ENABLED(CONFIG_ROOTWAIT_BOOTARG) && blk->rootwait)
-		rootarg = linux_bootargs_append_rootwait(rootarg);
+		*rootopts = xasprintf("rootwait=%d", linux_rootwait_secs);
 
-	return rootarg;
+	*root = root_local;
+	return 0;
 }
 
+char *cdev_get_linux_rootarg(const struct cdev *partcdev)
+{
+	int err;
+	char* root = NULL;
+	char* rootopts = NULL;
+
+	err = cdev_get_linux_root_and_opts(partcdev, &root, &rootopts);
+	if (err)
+		return NULL;
+
+	return format_root_bootarg("root", root, rootopts);
+}
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
index 6a451d9ef5..efc9a9193d 100644
--- a/fs/9p/vfs_super.c
+++ b/fs/9p/vfs_super.c
@@ -70,11 +70,11 @@ static void v9fs_set_rootarg(struct v9fs_session_info *v9ses,
 	trans = v9ses->clnt->trans_mod->name;
 	path = v9ses->aname;
 
-	str = basprintf("root=%s rootfstype=9p rootflags=trans=%s,msize=%d,"
+	str = basprintf("rootfstype=9p rootflags=trans=%s,msize=%d,"
 			"cache=loose,uname=%s,dfltuid=0,dfltgid=0,aname=%s",
-			tag, trans, v9ses->clnt->msize, tag, path);
+			trans, v9ses->clnt->msize, tag, path);
 
-	fsdev_set_linux_rootarg(fsdev, str);
+	fsdev_set_linux_root_options(fsdev, tag, str);
 
 	free(str);
 }
diff --git a/fs/fs.c b/fs/fs.c
index 528299e039..7e06b6fdc6 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -14,6 +14,7 @@
  *
  */
 
+#include <bootargs.h>
 #include <common.h>
 #include <command.h>
 #include <fs.h>
@@ -1226,12 +1227,34 @@ void mount_all(void)
 	}
 }
 
-void fsdev_set_linux_rootarg(struct fs_device *fsdev, const char *str)
+void fsdev_set_linux_root_options(struct fs_device *fsdev, const char *root, const char *rootopts)
 {
-	fsdev->linux_rootarg = xstrdup(str);
+	fsdev->linux_root = xstrdup(root);
+	fsdev->linux_rootopts = xstrdup(rootopts);
 
-	dev_add_param_fixed(&fsdev->dev, "linux.bootargs",
-			    "%s", fsdev->linux_rootarg);
+	dev_add_param_fixed(&fsdev->dev, "linux.bootargs.root",
+			    "%s", fsdev->linux_root);
+	dev_add_param_fixed(&fsdev->dev, "linux.bootargs.rootopts",
+			    "%s", fsdev->linux_rootopts);
+}
+
+void fsdev_get_linux_root_options(struct fs_device *fsdev, char **root, char **rootopts)
+{
+	if (fsdev) {
+		*root = dev_get_param(&fsdev->dev, "linux.bootargs.root");
+		*rootopts = dev_get_param(&fsdev->dev, "linux.bootargs.rootopts");
+	}
+}
+
+char *format_root_bootarg(const char *root_arg, char *root, char *rootopts) {
+	char *bootarg;
+	if (rootopts)
+		bootarg = xasprintf("%s=%s %s", root_arg, root, rootopts);
+	else
+		bootarg = xasprintf("%s=%s", root_arg, root);
+	free(root);
+	free(rootopts);
+	return bootarg;
 }
 
 /**
@@ -1245,17 +1268,19 @@ void fsdev_set_linux_rootarg(struct fs_device *fsdev, const char *str)
 char *path_get_linux_rootarg(const char *path)
 {
 	struct fs_device *fsdev;
-	const char *str;
+	char *root = NULL;
+	char *rootopts = NULL;
 
 	fsdev = get_fsdevice_by_path(AT_FDCWD, path);
 	if (!fsdev)
 		return ERR_PTR(-EINVAL);
 
-	str = dev_get_param(&fsdev->dev, "linux.bootargs");
-	if (!str)
-		return ERR_PTR(-ENOSYS);
+	fsdev_get_linux_root_options(fsdev, &root, &rootopts);
 
-	return xstrdup(str);
+	if (!root)
+		return ERR_PTR(-EINVAL);
+
+	return format_root_bootarg("root", root, rootopts);
 }
 
 /**
@@ -3249,12 +3274,17 @@ int mount(const char *device, const char *fsname, const char *pathname,
 
 	fsdev->vfsmount.mnt_root = fsdev->sb.s_root;
 
-	if (!fsdev->linux_rootarg) {
-		char *str;
+	if (!fsdev->linux_root) {
+		char *root;
+		char *rootopts;
 
-		str = cdev_get_linux_rootarg(fsdev->cdev);
-		if (str)
-			fsdev_set_linux_rootarg(fsdev, str);
+		cdev_get_linux_root_and_opts(fsdev->cdev, &root, &rootopts);
+		if (root) {
+			fsdev_set_linux_root_options(fsdev, root, rootopts);
+			free(root);
+			if(rootopts)
+				free(rootopts);
+		}
 	}
 
 	path_put(&path);
diff --git a/fs/nfs.c b/fs/nfs.c
index 5c2476cd88..0b40c56ff3 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -1558,7 +1558,7 @@ static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device *fsdev)
 	char *str, *tmp;
 	const char *bootargs;
 
-	str = basprintf("root=/dev/nfs nfsroot=%pI4:%s%s%s", &npriv->server, npriv->path,
+	str = basprintf("nfsroot=%pI4:%s%s%s", &npriv->server, npriv->path,
 			  rootnfsopts[0] ? "," : "", rootnfsopts);
 
 	/* forward specific mount options on demand */
@@ -1584,7 +1584,7 @@ static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device *fsdev)
 	if (IS_ENABLED(CONFIG_ROOTWAIT_BOOTARG))
 		str = linux_bootargs_append_rootwait(str);
 
-	fsdev_set_linux_rootarg(fsdev, str);
+	fsdev_set_linux_root_options(fsdev, "/dev/nfs", str);
 
 	free(str);
 }
diff --git a/fs/squashfs/squashfs.c b/fs/squashfs/squashfs.c
index e30372627a..365aa1f219 100644
--- a/fs/squashfs/squashfs.c
+++ b/fs/squashfs/squashfs.c
@@ -46,7 +46,8 @@ static void squashfs_set_rootarg(struct fs_device *fsdev)
 	struct ubi_volume_info vi = {};
 	struct ubi_device_info di = {};
 	struct mtd_info *mtd;
-	char *str;
+	char *root;
+	char *rootopts;
 
 	if (!IS_ENABLED(CONFIG_MTD_UBI))
 		return;
@@ -60,12 +61,14 @@ static void squashfs_set_rootarg(struct fs_device *fsdev)
 	ubi_get_device_info(vi.ubi_num, &di);
 	mtd = di.mtd;
 
-	str = basprintf("root=/dev/ubiblock%d_%d ubi.mtd=%s ubi.block=%d,%d rootfstype=squashfs",
-			vi.ubi_num, vi.vol_id, mtd->cdev.partname, vi.ubi_num, vi.vol_id);
+	root = basprintf("/dev/ubiblock%d_%d", vi.ubi_num, vi.vol_id);
+	rootopts = basprintf("ubi.mtd=%s ubi.block=%d,%d rootfstype=squashfs",
+			mtd->cdev.partname, vi.ubi_num, vi.vol_id);
 
-	fsdev_set_linux_rootarg(fsdev, str);
+	fsdev_set_linux_root_options(fsdev, root, rootopts);
 
-	free(str);
+	free(root);
+	free(rootopts);
 }
 
 static struct inode *squashfs_alloc_inode(struct super_block *sb)
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 37986acbb2..9cc35fa273 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -435,19 +435,21 @@ static void ubifs_set_rootarg(struct ubifs_priv *priv,
 	struct ubi_volume_info vi = {};
 	struct ubi_device_info di = {};
 	struct mtd_info *mtd;
-	char *str;
+	char *root;
+	char *rootopts;
 
 	ubi_get_volume_info(priv->ubi, &vi);
 	ubi_get_device_info(vi.ubi_num, &di);
 
 	mtd = di.mtd;
 
-	str = basprintf("root=ubi0:%s ubi.mtd=%s rootfstype=ubifs",
-			  vi.name, mtd->cdev.partname);
+	root = basprintf("ubi0:%s", vi.name);
+	rootopts = basprintf("ubi.mtd=%s rootfstype=ubifs", mtd->cdev.partname);
 
-	fsdev_set_linux_rootarg(fsdev, str);
+	fsdev_set_linux_root_options(fsdev, root, rootopts);
 
-	free(str);
+	free(root);
+	free(rootopts);
 }
 
 static int ubifs_probe(struct device *dev)
diff --git a/include/block.h b/include/block.h
index b277f590e4..ff18dcded0 100644
--- a/include/block.h
+++ b/include/block.h
@@ -85,6 +85,7 @@ static inline int block_flush(struct block_device *blk)
 #ifdef CONFIG_BLOCK
 unsigned file_list_add_blockdevs(struct file_list *files);
 char *cdev_get_linux_rootarg(const struct cdev *partcdev);
+int cdev_get_linux_root_and_opts(const struct cdev *partcdev, char** root, char** rootopts);
 #else
 static inline unsigned file_list_add_blockdevs(struct file_list *files)
 {
@@ -94,6 +95,10 @@ static inline char *cdev_get_linux_rootarg(const struct cdev *partcdev)
 {
 	return NULL;
 }
+static inline void cdev_get_linux_root_and_opts(const struct cdev *partcdev, char** root, char** rootopts)
+{
+	return -ENOSYS;
+}
 #endif
 
 static inline bool cdev_is_block_device(const struct cdev *cdev)
diff --git a/include/bootargs.h b/include/bootargs.h
index 1cf88bd380..6cb61750d1 100644
--- a/include/bootargs.h
+++ b/include/bootargs.h
@@ -26,4 +26,6 @@ static inline char *linux_bootargs_append_rootwait(char *rootarg)
 }
 #endif
 
+char *format_root_bootarg(const char *root_arg, char *root, char *rootopts);
+
 #endif /* __BOOTARGS_H */
diff --git a/include/fs.h b/include/fs.h
index 98c482bbf2..c50437d609 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -90,7 +90,8 @@ struct fs_device {
 	char *path;
 	struct list_head list;
 	char *options;
-	char *linux_rootarg;
+	char *linux_root;
+	char *linux_rootopts;
 
 	struct super_block sb;
 
@@ -159,7 +160,8 @@ const char *cdev_mount_default(struct cdev *cdev, const char *fsoptions);
 const char *cdev_mount(struct cdev *cdev);
 void mount_all(void);
 
-void fsdev_set_linux_rootarg(struct fs_device *fsdev, const char *str);
+void fsdev_set_linux_root_options(struct fs_device *fsdev, const char *root, const char* rootopts);
+void fsdev_get_linux_root_options(struct fs_device *fsdev, char **root, char **rootopts);
 char *path_get_linux_rootarg(const char *path);
 
 static inline const char *devpath_to_name(const char *devpath)
-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 3/4] bootm: use new api to get kernel command line params
  2025-11-27 14:25       ` [PATCH v3 0/4] make the root= command line parameter variable Fabian Pflug
  2025-11-27 14:25         ` [PATCH v3 1/4] block.h: renamed get_rootargs to get_root Fabian Pflug
  2025-11-27 14:25         ` [PATCH v3 2/4] fs: split rootargs into root and options Fabian Pflug
@ 2025-11-27 14:25         ` Fabian Pflug
  2025-11-28 10:04           ` Ahmad Fatoum
  2025-11-27 14:25         ` [PATCH v3 4/4] bootm: introduce bootm.root_arg variable Fabian Pflug
  2025-11-28 14:58         ` [PATCH v4 0/4] make the root= command line parameter variable Fabian Pflug
  4 siblings, 1 reply; 41+ messages in thread
From: Fabian Pflug @ 2025-11-27 14:25 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug

Getting root device adn root kernel options seperatily any combining
them in this function instead of getting the full string from the helper
functions. This is in preperation for replacing the root= string in the
kernel commandline with something defined during runtime.

Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
---
 common/bootm.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 17792b2a1d..8efe3426fe 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -1,9 +1,11 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 
 #include <common.h>
+#include <bootargs.h>
 #include <bootm.h>
 #include <bootm-overrides.h>
 #include <fs.h>
+#include <fcntl.h>
 #include <malloc.h>
 #include <memory.h>
 #include <block.h>
@@ -841,33 +843,39 @@ int bootm_boot(struct bootm_data *bootm_data)
 	}
 
 	if (bootm_data->appendroot) {
-		char *rootarg;
+		char *root = NULL;
+		char *rootopts = NULL;
 
 		if (bootm_data->root_dev) {
 			const char *root_dev_name = devpath_to_name(bootm_data->root_dev);
 			struct cdev *root_cdev = cdev_open_by_name(root_dev_name, O_RDONLY);
 
-			rootarg = cdev_get_linux_rootarg(root_cdev);
-			if (!rootarg) {
-				rootarg = ERR_PTR(-EINVAL);
+			ret = cdev_get_linux_root_and_opts(root_cdev, &root, &rootopts);
 
+			if (ret) {
 				if (!root_cdev)
-					pr_err("no cdev found for %s, cannot set root= option\n",
-						root_dev_name);
+					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);
+					pr_err("%s doesn't have a PARTUUID, cannot set root= option\n", root_dev_name);
+				else
+					pr_err("could not determine root= from %s\n", root_dev_name);
 			}
 
 			if (root_cdev)
 				cdev_close(root_cdev);
 		} else {
-			rootarg = path_get_linux_rootarg(data->os_file);
+			struct fs_device *fsdev = get_fsdevice_by_path(AT_FDCWD, data->os_file);
+			if (fsdev)
+				fsdev_get_linux_root_options(fsdev, &root, &rootopts);
+			else
+				pr_err("no fsdevice under path: %s\n", data->os_file);
 		}
 
-		if (IS_ERR(rootarg)) {
+		if (!root) {
 			pr_err("Failed to append kernel cmdline parameter 'root='\n");
 		} else {
+			char *rootarg;
+			rootarg = format_root_bootarg("root", root, rootopts);
 			pr_info("Adding \"%s\" to Kernel commandline\n", rootarg);
 			globalvar_add_simple("linux.bootargs.bootm.appendroot",
 					     rootarg);
-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v3 4/4] bootm: introduce bootm.root_arg variable
  2025-11-27 14:25       ` [PATCH v3 0/4] make the root= command line parameter variable Fabian Pflug
                           ` (2 preceding siblings ...)
  2025-11-27 14:25         ` [PATCH v3 3/4] bootm: use new api to get kernel command line params Fabian Pflug
@ 2025-11-27 14:25         ` Fabian Pflug
  2025-11-28 10:07           ` Ahmad Fatoum
  2025-11-28 14:58         ` [PATCH v4 0/4] make the root= command line parameter variable Fabian Pflug
  4 siblings, 1 reply; 41+ messages in thread
From: Fabian Pflug @ 2025-11-27 14:25 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug

The bootm.root_arg variable will be responsible for the root= part of
the kernel commandline if bootm.appendroot is set and a root device has
been selected.
root_arg allows to replace the root=/dev/... with verity=/dev/..., which
is useful in a verified boot context, where you pass the root file
system to the initramfs, but do not want the kernel to be able to parse
and mount the rootfs. With renaming the root= to something different,
you make sure, that the kernel does not mount the rootfs.

Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
---
 common/bootm.c  | 17 ++++++++++++-----
 fs/fs.c         | 26 --------------------------
 include/bootm.h |  1 +
 include/fs.h    |  1 -
 4 files changed, 13 insertions(+), 32 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 8efe3426fe..c00be384d0 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -70,6 +70,7 @@ void bootm_data_init_defaults(struct bootm_data *data)
 		data->initrd_file = getenv_nonempty("global.bootm.initrd");
 	}
 	data->root_dev = getenv_nonempty("global.bootm.root_dev");
+	data->root_arg = getenv_nonempty("global.bootm.root_arg");
 	data->verify = bootm_get_verify_mode();
 	data->appendroot = bootm_appendroot;
 	data->provide_machine_id = bootm_provide_machine_id;
@@ -89,6 +90,7 @@ void bootm_data_restore_defaults(const struct bootm_data *data)
 		globalvar_set("bootm.initrd", data->initrd_file);
 	}
 	globalvar_set("bootm.root_dev", data->root_dev);
+	globalvar_set("bootm.root_arg", data->root_arg);
 	bootm_set_verify_mode(data->verify);
 	bootm_appendroot = data->appendroot;
 	bootm_provide_machine_id = data->provide_machine_id;
@@ -854,11 +856,14 @@ int bootm_boot(struct bootm_data *bootm_data)
 
 			if (ret) {
 				if (!root_cdev)
-					pr_err("no cdev found for %s, cannot set root= option\n", root_dev_name);
+					pr_err("no cdev found for %s, cannot set %s= option\n",
+						root_dev_name, bootm_data->root_arg);
 				else if (!root_cdev->partuuid[0])
-					pr_err("%s doesn't have a PARTUUID, cannot set root= option\n", root_dev_name);
+					pr_err("%s doesn't have a PARTUUID, cannot set %s= option\n",
+						root_dev_name, bootm_data->root_arg);
 				else
-					pr_err("could not determine root= from %s\n", root_dev_name);
+					pr_err("could not determine %s= from %s\n",
+						bootm_data->root_arg, root_dev_name);
 			}
 
 			if (root_cdev)
@@ -872,10 +877,10 @@ int bootm_boot(struct bootm_data *bootm_data)
 		}
 
 		if (!root) {
-			pr_err("Failed to append kernel cmdline parameter 'root='\n");
+			pr_err("Failed to append kernel cmdline parameter '%s='\n", bootm_data->root_arg);
 		} else {
 			char *rootarg;
-			rootarg = format_root_bootarg("root", root, rootopts);
+			rootarg = format_root_bootarg(bootm_data->root_arg, root, rootopts);
 			pr_info("Adding \"%s\" to Kernel commandline\n", rootarg);
 			globalvar_add_simple("linux.bootargs.bootm.appendroot",
 					     rootarg);
@@ -1118,6 +1123,7 @@ static int bootm_init(void)
 	globalvar_add_simple("bootm.image.loadaddr", NULL);
 	globalvar_add_simple("bootm.oftree", NULL);
 	globalvar_add_simple("bootm.root_dev", NULL);
+	globalvar_add_simple("bootm.root_arg", "root");
 	globalvar_add_simple("bootm.tee", NULL);
 	globalvar_add_simple_bool("bootm.appendroot", &bootm_appendroot);
 	globalvar_add_simple_bool("bootm.earlycon", &bootm_earlycon);
@@ -1175,5 +1181,6 @@ BAREBOX_MAGICVAR(global.bootm.verbose, "bootm default verbosity level (0=quiet)"
 BAREBOX_MAGICVAR(global.bootm.earlycon, "Add earlycon option to Kernel for early log output");
 BAREBOX_MAGICVAR(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(global.bootm.root_dev, "bootm default root device (overrides default device in global.bootm.appendroot)");
+BAREBOX_MAGICVAR(global.bootm.root_arg, "bootm default parameter name arg for the root partition (normally 'root' for root=/dev/...)");
 BAREBOX_MAGICVAR(global.bootm.provide_machine_id, "If true, append systemd.machine_id=$global.machine_id to Kernel command line");
 BAREBOX_MAGICVAR(global.bootm.provide_hostname, "If true, append systemd.hostname=$global.hostname to Kernel command line");
diff --git a/fs/fs.c b/fs/fs.c
index 7e06b6fdc6..76375431ff 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -1257,32 +1257,6 @@ char *format_root_bootarg(const char *root_arg, char *root, char *rootopts) {
 	return bootarg;
 }
 
-/**
- * path_get_linux_rootarg() - Given a path return a suitable root= option for
- *                            Linux
- * @path: The path
- *
- * Return: A string containing the root= option or an ERR_PTR. the returned
- *         string must be freed by the caller.
- */
-char *path_get_linux_rootarg(const char *path)
-{
-	struct fs_device *fsdev;
-	char *root = NULL;
-	char *rootopts = NULL;
-
-	fsdev = get_fsdevice_by_path(AT_FDCWD, path);
-	if (!fsdev)
-		return ERR_PTR(-EINVAL);
-
-	fsdev_get_linux_root_options(fsdev, &root, &rootopts);
-
-	if (!root)
-		return ERR_PTR(-EINVAL);
-
-	return format_root_bootarg("root", root, rootopts);
-}
-
 /**
  * __is_tftp_fs() - return true when path is mounted on TFTP
  * @path: The path
diff --git a/include/bootm.h b/include/bootm.h
index b35deb25bf..43f4258885 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -19,6 +19,7 @@ struct bootm_data {
 	const char *oftree_file;
 	const char *tee_file;
 	const char *root_dev;
+	const char *root_arg;
 	int verbose;
 	enum bootm_verify verify;
 	bool force;
diff --git a/include/fs.h b/include/fs.h
index c50437d609..ddd93e93ec 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -162,7 +162,6 @@ void mount_all(void);
 
 void fsdev_set_linux_root_options(struct fs_device *fsdev, const char *root, const char* rootopts);
 void fsdev_get_linux_root_options(struct fs_device *fsdev, char **root, char **rootopts);
-char *path_get_linux_rootarg(const char *path);
 
 static inline const char *devpath_to_name(const char *devpath)
 {
-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 1/4] block.h: renamed get_rootargs to get_root
  2025-11-27 14:25         ` [PATCH v3 1/4] block.h: renamed get_rootargs to get_root Fabian Pflug
@ 2025-11-28  9:45           ` Ahmad Fatoum
  0 siblings, 0 replies; 41+ messages in thread
From: Ahmad Fatoum @ 2025-11-28  9:45 UTC (permalink / raw)
  To: Fabian Pflug, barebox

Hi,

On 11/27/25 3:25 PM, Fabian Pflug wrote:
> Don't return the full commandline-parameter, but instead just return the
> root block/fs/etc. The functions downstream can add root= before.
> 
> This is the first commit in a series to make root= dynamic.
> 
> Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

> ---
>  common/block.c         | 10 ++++++++--
>  drivers/mci/mci-core.c |  4 ++--
>  include/block.h        |  2 +-
>  3 files changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/common/block.c b/common/block.c
> index ca2ed37dbd..07c4d5d504 100644
> --- a/common/block.c
> +++ b/common/block.c
> @@ -598,8 +598,14 @@ char *cdev_get_linux_rootarg(const struct cdev *partcdev)
>  	if (!blk)
>  		return NULL;
>  
> -	if (blk->ops->get_rootarg)
> -		rootarg = blk->ops->get_rootarg(blk, partcdev);
> +	if (blk->ops->get_root) {
> +		char *root = NULL;
> +		root = blk->ops->get_root(blk, partcdev);
> +		if (root) {
> +			rootarg = basprintf("root=%s", root);
> +			free(root);
> +		}
> +	}
>  	if (!rootarg && partcdev->partuuid[0] != 0)
>  		rootarg = basprintf("root=PARTUUID=%s", partcdev->partuuid);
>  
> diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
> index 57825bc849..206147cb93 100644
> --- a/drivers/mci/mci-core.c
> +++ b/drivers/mci/mci-core.c
> @@ -2691,7 +2691,7 @@ static char *mci_get_linux_mmcblkdev(struct block_device *blk,
>  		 * skipping it.
>  		 */
>  		if (cdev_partname_equal(partcdev, cdev))
> -			return basprintf("root=/dev/mmcblk%dp%d", id, partnum);
> +			return basprintf("/dev/mmcblk%dp%d", id, partnum);
>  		if (cdev->flags & DEVFS_PARTITION_FROM_TABLE)
>  			partnum++;
>  	}
> @@ -2703,7 +2703,7 @@ static struct block_device_ops mci_ops = {
>  	.read = mci_sd_read,
>  	.write = IS_ENABLED(CONFIG_MCI_WRITE) ? mci_sd_write : NULL,
>  	.erase = IS_ENABLED(CONFIG_MCI_ERASE) ? mci_sd_erase : NULL,
> -	.get_rootarg = IS_ENABLED(CONFIG_MMCBLKDEV_ROOTARG) ?
> +	.get_root = IS_ENABLED(CONFIG_MMCBLKDEV_ROOTARG) ?
>  		mci_get_linux_mmcblkdev : NULL,
>  };
>  
> diff --git a/include/block.h b/include/block.h
> index fc7a0a32fb..b277f590e4 100644
> --- a/include/block.h
> +++ b/include/block.h
> @@ -14,7 +14,7 @@ struct block_device_ops {
>  	int (*write)(struct block_device *, const void *buf, sector_t block, blkcnt_t num_blocks);
>  	int (*erase)(struct block_device *blk, sector_t block, blkcnt_t num_blocks);
>  	int (*flush)(struct block_device *);
> -	char *(*get_rootarg)(struct block_device *blk, const struct cdev *partcdev);
> +	char *(*get_root)(struct block_device *blk, const struct cdev *partcdev);
>  };
>  
>  struct chunk;

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |




^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 2/4] fs: split rootargs into root and options
  2025-11-27 14:25         ` [PATCH v3 2/4] fs: split rootargs into root and options Fabian Pflug
@ 2025-11-28 10:01           ` Ahmad Fatoum
  0 siblings, 0 replies; 41+ messages in thread
From: Ahmad Fatoum @ 2025-11-28 10:01 UTC (permalink / raw)
  To: Fabian Pflug, barebox

Hi,

On 11/27/25 3:25 PM, Fabian Pflug wrote:
> The rootargs argument (root=/dev/etc rootwait) can be split into the
> root and options parts, which makes it easier to manipulate them both
> independently. This changes tries to be as backward compatible as
> possible and does not change the behaviour of the get functions, but
> introduces new ones to get both items seperatly.
> 
> Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

with below syntax error fixed. Pointed out some nitpicks while at it.

> ---
>  .../migration-guides/migration-master.rst     | 15 +++++
>  common/block.c                                | 44 ++++++++------
>  fs/9p/vfs_super.c                             |  6 +-
>  fs/fs.c                                       | 58 ++++++++++++++-----
>  fs/nfs.c                                      |  4 +-
>  fs/squashfs/squashfs.c                        | 13 +++--
>  fs/ubifs/ubifs.c                              | 12 ++--
>  include/block.h                               |  5 ++
>  include/bootargs.h                            |  2 +
>  include/fs.h                                  |  6 +-
>  10 files changed, 117 insertions(+), 48 deletions(-)
>  create mode 100644 Documentation/migration-guides/migration-master.rst
> 
> diff --git a/Documentation/migration-guides/migration-master.rst b/Documentation/migration-guides/migration-master.rst
> new file mode 100644
> index 0000000000..0d6cfcad57
> --- /dev/null
> +++ b/Documentation/migration-guides/migration-master.rst
> @@ -0,0 +1,15 @@
> +Filesystems
> +-----------
> +
> +{linux.bootargs} is replaced with "root={linux.bootargs.root} {linux.bootargs.rootopts}"
> +
> +The variable linux.bootargs has been replaced by the two variables
> +linux.bootargs.root and linux.bootargs.rootopts, splitting the previous bootargs
> +into three parts. A nonexistent fixed "root=", then the root filesystem and then
> +additional optional params for this particular filesystem.
> +
> +for example the previous
> +    linux.bootargs="root=/dev/nfs nfsroot=192.168.1.1:/rootfs"
> +becomes
> +    linux.bootargs.root="/dev/nfs"
> +    linux.bootargs.rootopts="nfsroot=192.168.1.1:/rootfs"

That will look odd rendered to HTML without extra ReST formatting.
For inline literal code (e.g., ``{linux.booargs}``) and for the code
blocks, use ::, e.g.:

for example the previous::

    linux.bootargs="root=/dev/nfs nfsroot=192.168.1.1:/rootfs"


> +char *cdev_get_linux_rootarg(const struct cdev *partcdev)
> +{
> +	int err;
> +	char* root = NULL;
> +	char* rootopts = NULL;

Asterisks next to identifier.

> +char *format_root_bootarg(const char *root_arg, char *root, char *rootopts) {

Newline before brace.

> -	str = dev_get_param(&fsdev->dev, "linux.bootargs");
> -	if (!str)
> -		return ERR_PTR(-ENOSYS);
> +	fsdev_get_linux_root_options(fsdev, &root, &rootopts);
>  
> -	return xstrdup(str);
> +	if (!root)
> +		return ERR_PTR(-EINVAL);

-ENOSYS would have been the better return type here, which is also what
we had before.

> -		str = cdev_get_linux_rootarg(fsdev->cdev);
> -		if (str)
> -			fsdev_set_linux_rootarg(fsdev, str);
> +		cdev_get_linux_root_and_opts(fsdev->cdev, &root, &rootopts);
> +		if (root) {
> +			fsdev_set_linux_root_options(fsdev, root, rootopts);
> +			free(root);
> +			if(rootopts)
> +				free(rootopts);

Coding style is spaces after if, but you can drop the check anyway, as
mentioned previously.

> +		}
>  	}

>  static int ubifs_probe(struct device *dev)
> diff --git a/include/block.h b/include/block.h
> index b277f590e4..ff18dcded0 100644
> --- a/include/block.h
> +++ b/include/block.h
> @@ -85,6 +85,7 @@ static inline int block_flush(struct block_device *blk)
>  #ifdef CONFIG_BLOCK
>  unsigned file_list_add_blockdevs(struct file_list *files);
>  char *cdev_get_linux_rootarg(const struct cdev *partcdev);
> +int cdev_get_linux_root_and_opts(const struct cdev *partcdev, char** root, char** rootopts);
>  #else
>  static inline unsigned file_list_add_blockdevs(struct file_list *files)
>  {
> @@ -94,6 +95,10 @@ static inline char *cdev_get_linux_rootarg(const struct cdev *partcdev)
>  {
>  	return NULL;
>  }
> +static inline void cdev_get_linux_root_and_opts(const struct cdev *partcdev, char** root, char** rootopts)
> +{
> +	return -ENOSYS;
> +}

Here's the actual issue: a void function can't return a value. Would
break in CI for platforms without CONFIG_BLOCK.

Cheers,
Ahmad

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |




^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 3/4] bootm: use new api to get kernel command line params
  2025-11-27 14:25         ` [PATCH v3 3/4] bootm: use new api to get kernel command line params Fabian Pflug
@ 2025-11-28 10:04           ` Ahmad Fatoum
  0 siblings, 0 replies; 41+ messages in thread
From: Ahmad Fatoum @ 2025-11-28 10:04 UTC (permalink / raw)
  To: Fabian Pflug, barebox

Hi,

On 11/27/25 3:25 PM, Fabian Pflug wrote:
> Getting root device adn root kernel options seperatily any combining
> them in this function instead of getting the full string from the helper
> functions. This is in preperation for replacing the root= string in the
> kernel commandline with something defined during runtime.

See typo fix suggestions on v1.

> 
> Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>

Looks good otherwise.

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

> ---
>  common/bootm.c | 28 ++++++++++++++++++----------
>  1 file changed, 18 insertions(+), 10 deletions(-)
> 
> diff --git a/common/bootm.c b/common/bootm.c
> index 17792b2a1d..8efe3426fe 100644
> --- a/common/bootm.c
> +++ b/common/bootm.c
> @@ -1,9 +1,11 @@
>  // SPDX-License-Identifier: GPL-2.0-or-later
>  
>  #include <common.h>
> +#include <bootargs.h>
>  #include <bootm.h>
>  #include <bootm-overrides.h>
>  #include <fs.h>
> +#include <fcntl.h>
>  #include <malloc.h>
>  #include <memory.h>
>  #include <block.h>
> @@ -841,33 +843,39 @@ int bootm_boot(struct bootm_data *bootm_data)
>  	}
>  
>  	if (bootm_data->appendroot) {
> -		char *rootarg;
> +		char *root = NULL;
> +		char *rootopts = NULL;
>  
>  		if (bootm_data->root_dev) {
>  			const char *root_dev_name = devpath_to_name(bootm_data->root_dev);
>  			struct cdev *root_cdev = cdev_open_by_name(root_dev_name, O_RDONLY);
>  
> -			rootarg = cdev_get_linux_rootarg(root_cdev);
> -			if (!rootarg) {
> -				rootarg = ERR_PTR(-EINVAL);
> +			ret = cdev_get_linux_root_and_opts(root_cdev, &root, &rootopts);
>  
> +			if (ret) {
>  				if (!root_cdev)
> -					pr_err("no cdev found for %s, cannot set root= option\n",
> -						root_dev_name);
> +					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);
> +					pr_err("%s doesn't have a PARTUUID, cannot set root= option\n", root_dev_name);
> +				else
> +					pr_err("could not determine root= from %s\n", root_dev_name);
>  			}
>  
>  			if (root_cdev)
>  				cdev_close(root_cdev);
>  		} else {
> -			rootarg = path_get_linux_rootarg(data->os_file);
> +			struct fs_device *fsdev = get_fsdevice_by_path(AT_FDCWD, data->os_file);
> +			if (fsdev)
> +				fsdev_get_linux_root_options(fsdev, &root, &rootopts);
> +			else
> +				pr_err("no fsdevice under path: %s\n", data->os_file);
>  		}
>  
> -		if (IS_ERR(rootarg)) {
> +		if (!root) {
>  			pr_err("Failed to append kernel cmdline parameter 'root='\n");
>  		} else {
> +			char *rootarg;
> +			rootarg = format_root_bootarg("root", root, rootopts);
>  			pr_info("Adding \"%s\" to Kernel commandline\n", rootarg);
>  			globalvar_add_simple("linux.bootargs.bootm.appendroot",
>  					     rootarg);

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |




^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v3 4/4] bootm: introduce bootm.root_arg variable
  2025-11-27 14:25         ` [PATCH v3 4/4] bootm: introduce bootm.root_arg variable Fabian Pflug
@ 2025-11-28 10:07           ` Ahmad Fatoum
  0 siblings, 0 replies; 41+ messages in thread
From: Ahmad Fatoum @ 2025-11-28 10:07 UTC (permalink / raw)
  To: Fabian Pflug, barebox

Hi,

On 11/27/25 3:25 PM, Fabian Pflug wrote:
> The bootm.root_arg variable will be responsible for the root= part of
> the kernel commandline if bootm.appendroot is set and a root device has
> been selected.
> root_arg allows to replace the root=/dev/... with verity=/dev/..., which
> is useful in a verified boot context, where you pass the root file
> system to the initramfs, but do not want the kernel to be able to parse
> and mount the rootfs. With renaming the root= to something different,
> you make sure, that the kernel does not mount the rootfs.
> 
> Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>

With rename (see below):

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

> ---
>  common/bootm.c  | 17 ++++++++++++-----
>  fs/fs.c         | 26 --------------------------
>  include/bootm.h |  1 +
>  include/fs.h    |  1 -
>  4 files changed, 13 insertions(+), 32 deletions(-)
> 
> diff --git a/common/bootm.c b/common/bootm.c
> index 8efe3426fe..c00be384d0 100644
> --- a/common/bootm.c
> +++ b/common/bootm.c
> @@ -70,6 +70,7 @@ void bootm_data_init_defaults(struct bootm_data *data)
>  		data->initrd_file = getenv_nonempty("global.bootm.initrd");
>  	}
>  	data->root_dev = getenv_nonempty("global.bootm.root_dev");
> +	data->root_arg = getenv_nonempty("global.bootm.root_arg");

I know root_arg was my suggestion IIRC, but thinking about it this
should rather be root_param as it's about what's before the =, not
what's after it.

>  				if (!root_cdev)
> -					pr_err("no cdev found for %s, cannot set root= option\n", root_dev_name);
> +					pr_err("no cdev found for %s, cannot set %s= option\n",
> +						root_dev_name, bootm_data->root_arg);

This was two lines before Patch 3/4, Patch 3/4 made it into one line,
now patch 4/4 makes it two lines again.

Cheers,
Ahmad

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |




^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v4 0/4] make the root= command line parameter variable
  2025-11-27 14:25       ` [PATCH v3 0/4] make the root= command line parameter variable Fabian Pflug
                           ` (3 preceding siblings ...)
  2025-11-27 14:25         ` [PATCH v3 4/4] bootm: introduce bootm.root_arg variable Fabian Pflug
@ 2025-11-28 14:58         ` Fabian Pflug
  2025-11-28 14:59           ` [PATCH v4 1/4] block.h: renamed get_rootargs to get_root Fabian Pflug
                             ` (4 more replies)
  4 siblings, 5 replies; 41+ messages in thread
From: Fabian Pflug @ 2025-11-28 14:58 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug

Changes in v4:
Added reviewd by for all patches
integrated review
moved removal of path_get_linux_rootarg from patch 4 to patch 3

Fabian Pflug (4):
  block.h: renamed get_rootargs to get_root
  fs: split rootargs into root and options
  bootm: use new api to get kernel command line params
  bootm: introduce bootm.root_arg variable

 .../migration-guides/migration-master.rst     | 18 ++++++
 common/block.c                                | 37 ++++++++---
 common/bootm.c                                | 37 +++++++----
 drivers/mci/mci-core.c                        |  4 +-
 fs/9p/vfs_super.c                             |  6 +-
 fs/fs.c                                       | 61 ++++++++++---------
 fs/nfs.c                                      |  4 +-
 fs/squashfs/squashfs.c                        | 13 ++--
 fs/ubifs/ubifs.c                              | 12 ++--
 include/block.h                               |  7 ++-
 include/bootargs.h                            |  2 +
 include/bootm.h                               |  1 +
 include/fs.h                                  |  7 ++-
 13 files changed, 138 insertions(+), 71 deletions(-)
 create mode 100644 Documentation/migration-guides/migration-master.rst

-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v4 1/4] block.h: renamed get_rootargs to get_root
  2025-11-28 14:58         ` [PATCH v4 0/4] make the root= command line parameter variable Fabian Pflug
@ 2025-11-28 14:59           ` Fabian Pflug
  2025-11-28 14:59           ` [PATCH 2/4] fs: split rootargs into root and options Fabian Pflug
                             ` (3 subsequent siblings)
  4 siblings, 0 replies; 41+ messages in thread
From: Fabian Pflug @ 2025-11-28 14:59 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug, Ahmad Fatoum

Don't return the full commandline-parameter, but instead just return the
root block/fs/etc. The functions downstream can add root= before.

This is the first commit in a series to make root= dynamic.

Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/block.c         | 10 ++++++++--
 drivers/mci/mci-core.c |  4 ++--
 include/block.h        |  2 +-
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/common/block.c b/common/block.c
index ca2ed37dbd..07c4d5d504 100644
--- a/common/block.c
+++ b/common/block.c
@@ -598,8 +598,14 @@ char *cdev_get_linux_rootarg(const struct cdev *partcdev)
 	if (!blk)
 		return NULL;
 
-	if (blk->ops->get_rootarg)
-		rootarg = blk->ops->get_rootarg(blk, partcdev);
+	if (blk->ops->get_root) {
+		char *root = NULL;
+		root = blk->ops->get_root(blk, partcdev);
+		if (root) {
+			rootarg = basprintf("root=%s", root);
+			free(root);
+		}
+	}
 	if (!rootarg && partcdev->partuuid[0] != 0)
 		rootarg = basprintf("root=PARTUUID=%s", partcdev->partuuid);
 
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 57825bc849..206147cb93 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -2691,7 +2691,7 @@ static char *mci_get_linux_mmcblkdev(struct block_device *blk,
 		 * skipping it.
 		 */
 		if (cdev_partname_equal(partcdev, cdev))
-			return basprintf("root=/dev/mmcblk%dp%d", id, partnum);
+			return basprintf("/dev/mmcblk%dp%d", id, partnum);
 		if (cdev->flags & DEVFS_PARTITION_FROM_TABLE)
 			partnum++;
 	}
@@ -2703,7 +2703,7 @@ static struct block_device_ops mci_ops = {
 	.read = mci_sd_read,
 	.write = IS_ENABLED(CONFIG_MCI_WRITE) ? mci_sd_write : NULL,
 	.erase = IS_ENABLED(CONFIG_MCI_ERASE) ? mci_sd_erase : NULL,
-	.get_rootarg = IS_ENABLED(CONFIG_MMCBLKDEV_ROOTARG) ?
+	.get_root = IS_ENABLED(CONFIG_MMCBLKDEV_ROOTARG) ?
 		mci_get_linux_mmcblkdev : NULL,
 };
 
diff --git a/include/block.h b/include/block.h
index fc7a0a32fb..b277f590e4 100644
--- a/include/block.h
+++ b/include/block.h
@@ -14,7 +14,7 @@ struct block_device_ops {
 	int (*write)(struct block_device *, const void *buf, sector_t block, blkcnt_t num_blocks);
 	int (*erase)(struct block_device *blk, sector_t block, blkcnt_t num_blocks);
 	int (*flush)(struct block_device *);
-	char *(*get_rootarg)(struct block_device *blk, const struct cdev *partcdev);
+	char *(*get_root)(struct block_device *blk, const struct cdev *partcdev);
 };
 
 struct chunk;
-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH 2/4] fs: split rootargs into root and options
  2025-11-28 14:58         ` [PATCH v4 0/4] make the root= command line parameter variable Fabian Pflug
  2025-11-28 14:59           ` [PATCH v4 1/4] block.h: renamed get_rootargs to get_root Fabian Pflug
@ 2025-11-28 14:59           ` Fabian Pflug
  2025-11-28 14:59           ` [PATCH v4 3/4] bootm: use new api to get kernel command line params Fabian Pflug
                             ` (2 subsequent siblings)
  4 siblings, 0 replies; 41+ messages in thread
From: Fabian Pflug @ 2025-11-28 14:59 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug, Ahmad Fatoum

The rootargs argument (root=/dev/etc rootwait) can be split into the
root and options parts, which makes it easier to manipulate them both
independently. This changes tries to be as backward compatible as
possible and does not change the behaviour of the get functions, but
introduces new ones to get both items seperatly.

Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
* Added space arount rst
* moved asterisk next to identifier
* added newline before brace
* made return-type -ENOSYS (not that it really matters, as the function
  will be deleted in the next commit)
* fixed return value for inline wihtout CONFIG_BLOCK

 .../migration-guides/migration-master.rst     | 18 ++++++
 common/block.c                                | 43 +++++++++-----
 fs/9p/vfs_super.c                             |  6 +-
 fs/fs.c                                       | 59 ++++++++++++++-----
 fs/nfs.c                                      |  4 +-
 fs/squashfs/squashfs.c                        | 13 ++--
 fs/ubifs/ubifs.c                              | 12 ++--
 include/block.h                               |  5 ++
 include/bootargs.h                            |  2 +
 include/fs.h                                  |  6 +-
 10 files changed, 120 insertions(+), 48 deletions(-)
 create mode 100644 Documentation/migration-guides/migration-master.rst

diff --git a/Documentation/migration-guides/migration-master.rst b/Documentation/migration-guides/migration-master.rst
new file mode 100644
index 0000000000..3b20dc1e4e
--- /dev/null
+++ b/Documentation/migration-guides/migration-master.rst
@@ -0,0 +1,18 @@
+Filesystems
+-----------
+
+``{linux.bootargs}`` is replaced with ``root={linux.bootargs.root} {linux.bootargs.rootopts}``
+
+The variable linux.bootargs has been replaced by the two variables
+linux.bootargs.root and linux.bootargs.rootopts, splitting the previous bootargs
+into three parts. A nonexistent fixed "root=", then the root filesystem and then
+additional optional params for this particular filesystem.
+
+for example the previous::
+
+    linux.bootargs="root=/dev/nfs nfsroot=192.168.1.1:/rootfs"
+
+becomes::
+
+    linux.bootargs.root="/dev/nfs"
+    linux.bootargs.rootopts="nfsroot=192.168.1.1:/rootfs"
diff --git a/common/block.c b/common/block.c
index 07c4d5d504..345adad722 100644
--- a/common/block.c
+++ b/common/block.c
@@ -584,34 +584,45 @@ const char *blk_type_str(enum blk_type type)
 	}
 }
 
-char *cdev_get_linux_rootarg(const struct cdev *partcdev)
+int cdev_get_linux_root_and_opts(const struct cdev *partcdev, char **root, char **rootopts)
 {
+
 	const struct cdev *cdevm;
 	struct block_device *blk;
-	char *rootarg = NULL;
+	char *root_local = NULL;
 
 	if (!partcdev)
-		return NULL;
+		return -EINVAL;
 
 	cdevm = partcdev->master ?: partcdev;
 	blk = cdev_get_block_device(cdevm);
 	if (!blk)
-		return NULL;
+		return -EINVAL;
 
-	if (blk->ops->get_root) {
-		char *root = NULL;
-		root = blk->ops->get_root(blk, partcdev);
-		if (root) {
-			rootarg = basprintf("root=%s", root);
-			free(root);
-		}
-	}
-	if (!rootarg && partcdev->partuuid[0] != 0)
-		rootarg = basprintf("root=PARTUUID=%s", partcdev->partuuid);
+	if (blk->ops->get_root)
+		root_local = blk->ops->get_root(blk, partcdev);
+	if (!root_local && partcdev->partuuid[0] != 0)
+		root_local = xasprintf("PARTUUID=%s", partcdev->partuuid);
+
+	if (!root_local)
+		return -ENODEV;
 
 	if (IS_ENABLED(CONFIG_ROOTWAIT_BOOTARG) && blk->rootwait)
-		rootarg = linux_bootargs_append_rootwait(rootarg);
+		*rootopts = xasprintf("rootwait=%d", linux_rootwait_secs);
 
-	return rootarg;
+	*root = root_local;
+	return 0;
 }
 
+char *cdev_get_linux_rootarg(const struct cdev *partcdev)
+{
+	int err;
+	char *root = NULL;
+	char *rootopts = NULL;
+
+	err = cdev_get_linux_root_and_opts(partcdev, &root, &rootopts);
+	if (err)
+		return NULL;
+
+	return format_root_bootarg("root", root, rootopts);
+}
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
index 6a451d9ef5..efc9a9193d 100644
--- a/fs/9p/vfs_super.c
+++ b/fs/9p/vfs_super.c
@@ -70,11 +70,11 @@ static void v9fs_set_rootarg(struct v9fs_session_info *v9ses,
 	trans = v9ses->clnt->trans_mod->name;
 	path = v9ses->aname;
 
-	str = basprintf("root=%s rootfstype=9p rootflags=trans=%s,msize=%d,"
+	str = basprintf("rootfstype=9p rootflags=trans=%s,msize=%d,"
 			"cache=loose,uname=%s,dfltuid=0,dfltgid=0,aname=%s",
-			tag, trans, v9ses->clnt->msize, tag, path);
+			trans, v9ses->clnt->msize, tag, path);
 
-	fsdev_set_linux_rootarg(fsdev, str);
+	fsdev_set_linux_root_options(fsdev, tag, str);
 
 	free(str);
 }
diff --git a/fs/fs.c b/fs/fs.c
index 528299e039..0f27879395 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -14,6 +14,7 @@
  *
  */
 
+#include <bootargs.h>
 #include <common.h>
 #include <command.h>
 #include <fs.h>
@@ -1226,12 +1227,34 @@ void mount_all(void)
 	}
 }
 
-void fsdev_set_linux_rootarg(struct fs_device *fsdev, const char *str)
+void fsdev_set_linux_root_options(struct fs_device *fsdev, const char *root, const char *rootopts)
 {
-	fsdev->linux_rootarg = xstrdup(str);
+	fsdev->linux_root = xstrdup(root);
+	fsdev->linux_rootopts = xstrdup(rootopts);
 
-	dev_add_param_fixed(&fsdev->dev, "linux.bootargs",
-			    "%s", fsdev->linux_rootarg);
+	dev_add_param_fixed(&fsdev->dev, "linux.bootargs.root",
+			    "%s", fsdev->linux_root);
+	dev_add_param_fixed(&fsdev->dev, "linux.bootargs.rootopts",
+			    "%s", fsdev->linux_rootopts);
+}
+
+void fsdev_get_linux_root_options(struct fs_device *fsdev, char **root, char **rootopts)
+{
+	if (fsdev) {
+		*root = dev_get_param(&fsdev->dev, "linux.bootargs.root");
+		*rootopts = dev_get_param(&fsdev->dev, "linux.bootargs.rootopts");
+	}
+}
+
+char *format_root_bootarg(const char *root_arg, char *root, char *rootopts) {
+	char *bootarg;
+	if (rootopts)
+		bootarg = xasprintf("%s=%s %s", root_arg, root, rootopts);
+	else
+		bootarg = xasprintf("%s=%s", root_arg, root);
+	free(root);
+	free(rootopts);
+	return bootarg;
 }
 
 /**
@@ -1245,17 +1268,19 @@ void fsdev_set_linux_rootarg(struct fs_device *fsdev, const char *str)
 char *path_get_linux_rootarg(const char *path)
 {
 	struct fs_device *fsdev;
-	const char *str;
+	char *root = NULL;
+	char *rootopts = NULL;
 
 	fsdev = get_fsdevice_by_path(AT_FDCWD, path);
 	if (!fsdev)
-		return ERR_PTR(-EINVAL);
-
-	str = dev_get_param(&fsdev->dev, "linux.bootargs");
-	if (!str)
 		return ERR_PTR(-ENOSYS);
 
-	return xstrdup(str);
+	fsdev_get_linux_root_options(fsdev, &root, &rootopts);
+
+	if (!root)
+		return ERR_PTR(-ENOSYS);
+
+	return format_root_bootarg("root", root, rootopts);
 }
 
 /**
@@ -3249,12 +3274,16 @@ int mount(const char *device, const char *fsname, const char *pathname,
 
 	fsdev->vfsmount.mnt_root = fsdev->sb.s_root;
 
-	if (!fsdev->linux_rootarg) {
-		char *str;
+	if (!fsdev->linux_root) {
+		char *root = NULL;
+		char *rootopts = NULL;
 
-		str = cdev_get_linux_rootarg(fsdev->cdev);
-		if (str)
-			fsdev_set_linux_rootarg(fsdev, str);
+		ret = cdev_get_linux_root_and_opts(fsdev->cdev, &root, &rootopts);
+		if (ret == 0) {
+			fsdev_set_linux_root_options(fsdev, root, rootopts);
+			free(root);
+			free(rootopts);
+		}
 	}
 
 	path_put(&path);
diff --git a/fs/nfs.c b/fs/nfs.c
index 5c2476cd88..0b40c56ff3 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -1558,7 +1558,7 @@ static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device *fsdev)
 	char *str, *tmp;
 	const char *bootargs;
 
-	str = basprintf("root=/dev/nfs nfsroot=%pI4:%s%s%s", &npriv->server, npriv->path,
+	str = basprintf("nfsroot=%pI4:%s%s%s", &npriv->server, npriv->path,
 			  rootnfsopts[0] ? "," : "", rootnfsopts);
 
 	/* forward specific mount options on demand */
@@ -1584,7 +1584,7 @@ static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device *fsdev)
 	if (IS_ENABLED(CONFIG_ROOTWAIT_BOOTARG))
 		str = linux_bootargs_append_rootwait(str);
 
-	fsdev_set_linux_rootarg(fsdev, str);
+	fsdev_set_linux_root_options(fsdev, "/dev/nfs", str);
 
 	free(str);
 }
diff --git a/fs/squashfs/squashfs.c b/fs/squashfs/squashfs.c
index e30372627a..365aa1f219 100644
--- a/fs/squashfs/squashfs.c
+++ b/fs/squashfs/squashfs.c
@@ -46,7 +46,8 @@ static void squashfs_set_rootarg(struct fs_device *fsdev)
 	struct ubi_volume_info vi = {};
 	struct ubi_device_info di = {};
 	struct mtd_info *mtd;
-	char *str;
+	char *root;
+	char *rootopts;
 
 	if (!IS_ENABLED(CONFIG_MTD_UBI))
 		return;
@@ -60,12 +61,14 @@ static void squashfs_set_rootarg(struct fs_device *fsdev)
 	ubi_get_device_info(vi.ubi_num, &di);
 	mtd = di.mtd;
 
-	str = basprintf("root=/dev/ubiblock%d_%d ubi.mtd=%s ubi.block=%d,%d rootfstype=squashfs",
-			vi.ubi_num, vi.vol_id, mtd->cdev.partname, vi.ubi_num, vi.vol_id);
+	root = basprintf("/dev/ubiblock%d_%d", vi.ubi_num, vi.vol_id);
+	rootopts = basprintf("ubi.mtd=%s ubi.block=%d,%d rootfstype=squashfs",
+			mtd->cdev.partname, vi.ubi_num, vi.vol_id);
 
-	fsdev_set_linux_rootarg(fsdev, str);
+	fsdev_set_linux_root_options(fsdev, root, rootopts);
 
-	free(str);
+	free(root);
+	free(rootopts);
 }
 
 static struct inode *squashfs_alloc_inode(struct super_block *sb)
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 37986acbb2..9cc35fa273 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -435,19 +435,21 @@ static void ubifs_set_rootarg(struct ubifs_priv *priv,
 	struct ubi_volume_info vi = {};
 	struct ubi_device_info di = {};
 	struct mtd_info *mtd;
-	char *str;
+	char *root;
+	char *rootopts;
 
 	ubi_get_volume_info(priv->ubi, &vi);
 	ubi_get_device_info(vi.ubi_num, &di);
 
 	mtd = di.mtd;
 
-	str = basprintf("root=ubi0:%s ubi.mtd=%s rootfstype=ubifs",
-			  vi.name, mtd->cdev.partname);
+	root = basprintf("ubi0:%s", vi.name);
+	rootopts = basprintf("ubi.mtd=%s rootfstype=ubifs", mtd->cdev.partname);
 
-	fsdev_set_linux_rootarg(fsdev, str);
+	fsdev_set_linux_root_options(fsdev, root, rootopts);
 
-	free(str);
+	free(root);
+	free(rootopts);
 }
 
 static int ubifs_probe(struct device *dev)
diff --git a/include/block.h b/include/block.h
index b277f590e4..cbab04095d 100644
--- a/include/block.h
+++ b/include/block.h
@@ -85,6 +85,7 @@ static inline int block_flush(struct block_device *blk)
 #ifdef CONFIG_BLOCK
 unsigned file_list_add_blockdevs(struct file_list *files);
 char *cdev_get_linux_rootarg(const struct cdev *partcdev);
+int cdev_get_linux_root_and_opts(const struct cdev *partcdev, char** root, char** rootopts);
 #else
 static inline unsigned file_list_add_blockdevs(struct file_list *files)
 {
@@ -94,6 +95,10 @@ static inline char *cdev_get_linux_rootarg(const struct cdev *partcdev)
 {
 	return NULL;
 }
+static inline int cdev_get_linux_root_and_opts(const struct cdev *partcdev, char** root, char** rootopts)
+{
+	return -ENOSYS;
+}
 #endif
 
 static inline bool cdev_is_block_device(const struct cdev *cdev)
diff --git a/include/bootargs.h b/include/bootargs.h
index 1cf88bd380..6cb61750d1 100644
--- a/include/bootargs.h
+++ b/include/bootargs.h
@@ -26,4 +26,6 @@ static inline char *linux_bootargs_append_rootwait(char *rootarg)
 }
 #endif
 
+char *format_root_bootarg(const char *root_arg, char *root, char *rootopts);
+
 #endif /* __BOOTARGS_H */
diff --git a/include/fs.h b/include/fs.h
index 98c482bbf2..c50437d609 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -90,7 +90,8 @@ struct fs_device {
 	char *path;
 	struct list_head list;
 	char *options;
-	char *linux_rootarg;
+	char *linux_root;
+	char *linux_rootopts;
 
 	struct super_block sb;
 
@@ -159,7 +160,8 @@ const char *cdev_mount_default(struct cdev *cdev, const char *fsoptions);
 const char *cdev_mount(struct cdev *cdev);
 void mount_all(void);
 
-void fsdev_set_linux_rootarg(struct fs_device *fsdev, const char *str);
+void fsdev_set_linux_root_options(struct fs_device *fsdev, const char *root, const char* rootopts);
+void fsdev_get_linux_root_options(struct fs_device *fsdev, char **root, char **rootopts);
 char *path_get_linux_rootarg(const char *path);
 
 static inline const char *devpath_to_name(const char *devpath)
-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v4 3/4] bootm: use new api to get kernel command line params
  2025-11-28 14:58         ` [PATCH v4 0/4] make the root= command line parameter variable Fabian Pflug
  2025-11-28 14:59           ` [PATCH v4 1/4] block.h: renamed get_rootargs to get_root Fabian Pflug
  2025-11-28 14:59           ` [PATCH 2/4] fs: split rootargs into root and options Fabian Pflug
@ 2025-11-28 14:59           ` Fabian Pflug
  2025-11-28 14:59           ` [PATCH v4 4/4] bootm: introduce bootm.root_arg variable Fabian Pflug
  2025-12-01  7:20           ` [PATCH v5 0/4] make the root= command line parameter variable Fabian Pflug
  4 siblings, 0 replies; 41+ messages in thread
From: Fabian Pflug @ 2025-11-28 14:59 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug, Ahmad Fatoum

Getting root device and root kernel options seperatly and combining
them in this function instead of getting the full string from the helper
functions. This is in preparation for replacing the root= string in the
kernel commandline with something defined during runtime.

Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
* fixed typo suggestions
* added removal of path_get_linux_rootarg
 common/bootm.c | 23 +++++++++++++++++------
 fs/fs.c        | 26 --------------------------
 include/fs.h   |  1 -
 3 files changed, 17 insertions(+), 33 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 17792b2a1d..adc76eba64 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -1,9 +1,11 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 
 #include <common.h>
+#include <bootargs.h>
 #include <bootm.h>
 #include <bootm-overrides.h>
 #include <fs.h>
+#include <fcntl.h>
 #include <malloc.h>
 #include <memory.h>
 #include <block.h>
@@ -841,33 +843,42 @@ int bootm_boot(struct bootm_data *bootm_data)
 	}
 
 	if (bootm_data->appendroot) {
-		char *rootarg;
+		char *root = NULL;
+		char *rootopts = NULL;
 
 		if (bootm_data->root_dev) {
 			const char *root_dev_name = devpath_to_name(bootm_data->root_dev);
 			struct cdev *root_cdev = cdev_open_by_name(root_dev_name, O_RDONLY);
 
-			rootarg = cdev_get_linux_rootarg(root_cdev);
-			if (!rootarg) {
-				rootarg = ERR_PTR(-EINVAL);
+			ret = cdev_get_linux_root_and_opts(root_cdev, &root, &rootopts);
 
+			if (ret) {
 				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
+					pr_err("could not determine root= from %s\n",
+						root_dev_name);
 			}
 
 			if (root_cdev)
 				cdev_close(root_cdev);
 		} else {
-			rootarg = path_get_linux_rootarg(data->os_file);
+			struct fs_device *fsdev = get_fsdevice_by_path(AT_FDCWD, data->os_file);
+			if (fsdev)
+				fsdev_get_linux_root_options(fsdev, &root, &rootopts);
+			else
+				pr_err("no fsdevice under path: %s\n", data->os_file);
 		}
 
-		if (IS_ERR(rootarg)) {
+		if (!root) {
 			pr_err("Failed to append kernel cmdline parameter 'root='\n");
 		} else {
+			char *rootarg;
+			rootarg = format_root_bootarg("root", root, rootopts);
 			pr_info("Adding \"%s\" to Kernel commandline\n", rootarg);
 			globalvar_add_simple("linux.bootargs.bootm.appendroot",
 					     rootarg);
diff --git a/fs/fs.c b/fs/fs.c
index 0f27879395..ae6a776b2b 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -1257,32 +1257,6 @@ char *format_root_bootarg(const char *root_arg, char *root, char *rootopts) {
 	return bootarg;
 }
 
-/**
- * path_get_linux_rootarg() - Given a path return a suitable root= option for
- *                            Linux
- * @path: The path
- *
- * Return: A string containing the root= option or an ERR_PTR. the returned
- *         string must be freed by the caller.
- */
-char *path_get_linux_rootarg(const char *path)
-{
-	struct fs_device *fsdev;
-	char *root = NULL;
-	char *rootopts = NULL;
-
-	fsdev = get_fsdevice_by_path(AT_FDCWD, path);
-	if (!fsdev)
-		return ERR_PTR(-ENOSYS);
-
-	fsdev_get_linux_root_options(fsdev, &root, &rootopts);
-
-	if (!root)
-		return ERR_PTR(-ENOSYS);
-
-	return format_root_bootarg("root", root, rootopts);
-}
-
 /**
  * __is_tftp_fs() - return true when path is mounted on TFTP
  * @path: The path
diff --git a/include/fs.h b/include/fs.h
index c50437d609..ddd93e93ec 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -162,7 +162,6 @@ void mount_all(void);
 
 void fsdev_set_linux_root_options(struct fs_device *fsdev, const char *root, const char* rootopts);
 void fsdev_get_linux_root_options(struct fs_device *fsdev, char **root, char **rootopts);
-char *path_get_linux_rootarg(const char *path);
 
 static inline const char *devpath_to_name(const char *devpath)
 {
-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v4 4/4] bootm: introduce bootm.root_arg variable
  2025-11-28 14:58         ` [PATCH v4 0/4] make the root= command line parameter variable Fabian Pflug
                             ` (2 preceding siblings ...)
  2025-11-28 14:59           ` [PATCH v4 3/4] bootm: use new api to get kernel command line params Fabian Pflug
@ 2025-11-28 14:59           ` Fabian Pflug
  2025-12-01  7:20           ` [PATCH v5 0/4] make the root= command line parameter variable Fabian Pflug
  4 siblings, 0 replies; 41+ messages in thread
From: Fabian Pflug @ 2025-11-28 14:59 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug, Ahmad Fatoum

The bootm.root_arg variable will be responsible for the root= part of
the kernel commandline if bootm.appendroot is set and a root device has
been selected.
root_arg allows to replace the root=/dev/... with verity=/dev/..., which
is useful in a verified boot context, where you pass the root file
system to the initramfs, but do not want the kernel to be able to parse
and mount the rootfs. With renaming the root= to something different,
you make sure, that the kernel does not mount the rootfs.

Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
* removed removal of path_get_linux_rootarg
* renamed root_arg to root_param
 common/bootm.c  | 20 ++++++++++++--------
 include/bootm.h |  1 +
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index adc76eba64..6a01aa3638 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -70,6 +70,7 @@ void bootm_data_init_defaults(struct bootm_data *data)
 		data->initrd_file = getenv_nonempty("global.bootm.initrd");
 	}
 	data->root_dev = getenv_nonempty("global.bootm.root_dev");
+	data->root_param = getenv_nonempty("global.bootm.root_param");
 	data->verify = bootm_get_verify_mode();
 	data->appendroot = bootm_appendroot;
 	data->provide_machine_id = bootm_provide_machine_id;
@@ -89,6 +90,7 @@ void bootm_data_restore_defaults(const struct bootm_data *data)
 		globalvar_set("bootm.initrd", data->initrd_file);
 	}
 	globalvar_set("bootm.root_dev", data->root_dev);
+	globalvar_set("bootm.root_param", data->root_param);
 	bootm_set_verify_mode(data->verify);
 	bootm_appendroot = data->appendroot;
 	bootm_provide_machine_id = data->provide_machine_id;
@@ -854,14 +856,14 @@ int bootm_boot(struct bootm_data *bootm_data)
 
 			if (ret) {
 				if (!root_cdev)
-					pr_err("no cdev found for %s, cannot set root= option\n",
-						root_dev_name);
+					pr_err("no cdev found for %s, cannot set %s= option\n",
+						root_dev_name, bootm_data->root_param);
 				else if (!root_cdev->partuuid[0])
-					pr_err("%s doesn't have a PARTUUID, cannot set root= option\n",
-						root_dev_name);
+					pr_err("%s doesn't have a PARTUUID, cannot set %s= option\n",
+						root_dev_name, bootm_data->root_param);
 				else
-					pr_err("could not determine root= from %s\n",
-						root_dev_name);
+					pr_err("could not determine %s= from %s\n",
+						bootm_data->root_param, root_dev_name);
 			}
 
 			if (root_cdev)
@@ -875,10 +877,10 @@ int bootm_boot(struct bootm_data *bootm_data)
 		}
 
 		if (!root) {
-			pr_err("Failed to append kernel cmdline parameter 'root='\n");
+			pr_err("Failed to append kernel cmdline parameter '%s='\n", bootm_data->root_param);
 		} else {
 			char *rootarg;
-			rootarg = format_root_bootarg("root", root, rootopts);
+			rootarg = format_root_bootarg(bootm_data->root_param, root, rootopts);
 			pr_info("Adding \"%s\" to Kernel commandline\n", rootarg);
 			globalvar_add_simple("linux.bootargs.bootm.appendroot",
 					     rootarg);
@@ -1121,6 +1123,7 @@ static int bootm_init(void)
 	globalvar_add_simple("bootm.image.loadaddr", NULL);
 	globalvar_add_simple("bootm.oftree", NULL);
 	globalvar_add_simple("bootm.root_dev", NULL);
+	globalvar_add_simple("bootm.root_param", "root");
 	globalvar_add_simple("bootm.tee", NULL);
 	globalvar_add_simple_bool("bootm.appendroot", &bootm_appendroot);
 	globalvar_add_simple_bool("bootm.earlycon", &bootm_earlycon);
@@ -1178,5 +1181,6 @@ BAREBOX_MAGICVAR(global.bootm.verbose, "bootm default verbosity level (0=quiet)"
 BAREBOX_MAGICVAR(global.bootm.earlycon, "Add earlycon option to Kernel for early log output");
 BAREBOX_MAGICVAR(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(global.bootm.root_dev, "bootm default root device (overrides default device in global.bootm.appendroot)");
+BAREBOX_MAGICVAR(global.bootm.root_param, "bootm default parameter name arg for the root partition (normally 'root' for root=/dev/...)");
 BAREBOX_MAGICVAR(global.bootm.provide_machine_id, "If true, append systemd.machine_id=$global.machine_id to Kernel command line");
 BAREBOX_MAGICVAR(global.bootm.provide_hostname, "If true, append systemd.hostname=$global.hostname to Kernel command line");
diff --git a/include/bootm.h b/include/bootm.h
index b35deb25bf..14b2465500 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -19,6 +19,7 @@ struct bootm_data {
 	const char *oftree_file;
 	const char *tee_file;
 	const char *root_dev;
+	const char *root_param;
 	int verbose;
 	enum bootm_verify verify;
 	bool force;
-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v5 0/4] make the root= command line parameter variable
  2025-11-28 14:58         ` [PATCH v4 0/4] make the root= command line parameter variable Fabian Pflug
                             ` (3 preceding siblings ...)
  2025-11-28 14:59           ` [PATCH v4 4/4] bootm: introduce bootm.root_arg variable Fabian Pflug
@ 2025-12-01  7:20           ` Fabian Pflug
  2025-12-01  7:20             ` [PATCH v5 1/4] block.h: renamed get_rootargs to get_root Fabian Pflug
                               ` (3 more replies)
  4 siblings, 4 replies; 41+ messages in thread
From: Fabian Pflug @ 2025-12-01  7:20 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug

Changes in v5:
Updated documentation for nfs
Added documentation about new bootm variable
Fixed commit message for last patch

Fabian Pflug (4):
  block.h: renamed get_rootargs to get_root
  fs: split rootargs into root and options
  bootm: use new api to get kernel command line params
  bootm: introduce bootm.root_param variable

 Documentation/filesystems/nfs.rst             | 10 +--
 .../migration-guides/migration-master.rst     | 18 ++++++
 Documentation/user/security.rst               | 16 +++++
 common/block.c                                | 37 ++++++++---
 common/bootm.c                                | 37 +++++++----
 drivers/mci/mci-core.c                        |  4 +-
 fs/9p/vfs_super.c                             |  6 +-
 fs/fs.c                                       | 61 ++++++++++---------
 fs/nfs.c                                      |  4 +-
 fs/squashfs/squashfs.c                        | 13 ++--
 fs/ubifs/ubifs.c                              | 12 ++--
 include/block.h                               |  7 ++-
 include/bootargs.h                            |  2 +
 include/bootm.h                               |  1 +
 include/fs.h                                  |  7 ++-
 15 files changed, 160 insertions(+), 75 deletions(-)
 create mode 100644 Documentation/migration-guides/migration-master.rst

-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v5 1/4] block.h: renamed get_rootargs to get_root
  2025-12-01  7:20           ` [PATCH v5 0/4] make the root= command line parameter variable Fabian Pflug
@ 2025-12-01  7:20             ` Fabian Pflug
  2025-12-01  7:20             ` [PATCH v5 2/4] fs: split rootargs into root and options Fabian Pflug
                               ` (2 subsequent siblings)
  3 siblings, 0 replies; 41+ messages in thread
From: Fabian Pflug @ 2025-12-01  7:20 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug, Ahmad Fatoum

Don't return the full commandline-parameter, but instead just return the
root block/fs/etc. The functions downstream can add root= before.

This is the first commit in a series to make root= dynamic.

Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/block.c         | 10 ++++++++--
 drivers/mci/mci-core.c |  4 ++--
 include/block.h        |  2 +-
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/common/block.c b/common/block.c
index ca2ed37dbd..07c4d5d504 100644
--- a/common/block.c
+++ b/common/block.c
@@ -598,8 +598,14 @@ char *cdev_get_linux_rootarg(const struct cdev *partcdev)
 	if (!blk)
 		return NULL;
 
-	if (blk->ops->get_rootarg)
-		rootarg = blk->ops->get_rootarg(blk, partcdev);
+	if (blk->ops->get_root) {
+		char *root = NULL;
+		root = blk->ops->get_root(blk, partcdev);
+		if (root) {
+			rootarg = basprintf("root=%s", root);
+			free(root);
+		}
+	}
 	if (!rootarg && partcdev->partuuid[0] != 0)
 		rootarg = basprintf("root=PARTUUID=%s", partcdev->partuuid);
 
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 57825bc849..206147cb93 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -2691,7 +2691,7 @@ static char *mci_get_linux_mmcblkdev(struct block_device *blk,
 		 * skipping it.
 		 */
 		if (cdev_partname_equal(partcdev, cdev))
-			return basprintf("root=/dev/mmcblk%dp%d", id, partnum);
+			return basprintf("/dev/mmcblk%dp%d", id, partnum);
 		if (cdev->flags & DEVFS_PARTITION_FROM_TABLE)
 			partnum++;
 	}
@@ -2703,7 +2703,7 @@ static struct block_device_ops mci_ops = {
 	.read = mci_sd_read,
 	.write = IS_ENABLED(CONFIG_MCI_WRITE) ? mci_sd_write : NULL,
 	.erase = IS_ENABLED(CONFIG_MCI_ERASE) ? mci_sd_erase : NULL,
-	.get_rootarg = IS_ENABLED(CONFIG_MMCBLKDEV_ROOTARG) ?
+	.get_root = IS_ENABLED(CONFIG_MMCBLKDEV_ROOTARG) ?
 		mci_get_linux_mmcblkdev : NULL,
 };
 
diff --git a/include/block.h b/include/block.h
index fc7a0a32fb..b277f590e4 100644
--- a/include/block.h
+++ b/include/block.h
@@ -14,7 +14,7 @@ struct block_device_ops {
 	int (*write)(struct block_device *, const void *buf, sector_t block, blkcnt_t num_blocks);
 	int (*erase)(struct block_device *blk, sector_t block, blkcnt_t num_blocks);
 	int (*flush)(struct block_device *);
-	char *(*get_rootarg)(struct block_device *blk, const struct cdev *partcdev);
+	char *(*get_root)(struct block_device *blk, const struct cdev *partcdev);
 };
 
 struct chunk;
-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v5 2/4] fs: split rootargs into root and options
  2025-12-01  7:20           ` [PATCH v5 0/4] make the root= command line parameter variable Fabian Pflug
  2025-12-01  7:20             ` [PATCH v5 1/4] block.h: renamed get_rootargs to get_root Fabian Pflug
@ 2025-12-01  7:20             ` Fabian Pflug
  2025-12-01  7:20             ` [PATCH v5 3/4] bootm: use new api to get kernel command line params Fabian Pflug
  2025-12-01  7:21             ` [PATCH v5 4/4] bootm: introduce bootm.root_param variable Fabian Pflug
  3 siblings, 0 replies; 41+ messages in thread
From: Fabian Pflug @ 2025-12-01  7:20 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug, Ahmad Fatoum

The rootargs argument (root=/dev/etc rootwait) can be split into the
root and options parts, which makes it easier to manipulate them both
independently. This changes tries to be as backward compatible as
possible and does not change the behaviour of the get functions, but
introduces new ones to get both items seperatly.

Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---

Updated documentation block for nfs to reflect current state.

 Documentation/filesystems/nfs.rst             | 10 ++--
 .../migration-guides/migration-master.rst     | 18 ++++++
 common/block.c                                | 43 +++++++++-----
 fs/9p/vfs_super.c                             |  6 +-
 fs/fs.c                                       | 59 ++++++++++++++-----
 fs/nfs.c                                      |  4 +-
 fs/squashfs/squashfs.c                        | 13 ++--
 fs/ubifs/ubifs.c                              | 12 ++--
 include/block.h                               |  5 ++
 include/bootargs.h                            |  2 +
 include/fs.h                                  |  6 +-
 11 files changed, 126 insertions(+), 52 deletions(-)
 create mode 100644 Documentation/migration-guides/migration-master.rst

diff --git a/Documentation/filesystems/nfs.rst b/Documentation/filesystems/nfs.rst
index 3e40ae9767..73614c8a83 100644
--- a/Documentation/filesystems/nfs.rst
+++ b/Documentation/filesystems/nfs.rst
@@ -13,9 +13,10 @@ Example:
 
    barebox:/ mount -t nfs 192.168.23.4:/home/user/nfsroot /mnt/nfs
 
-The barebox NFS driver adds a ``linux.bootargs`` device parameter to the NFS device.
-This parameter holds a Linux kernel commandline snippet containing a suitable root=
-option for booting from exactly that NFS share.
+The barebox NFS driver adds two ``linux.bootargs`` device parameters to the NFS
+device. These parameters will be combined into a Linux kernel commandline
+snippet containing a suitable root= option for booting from exactly that NFS
+share.
 
 Example:
 
@@ -23,7 +24,8 @@ Example:
 
   barebox:/ devinfo nfs0
   ...
-  linux.bootargs: root=/dev/nfs nfsroot=192.168.23.4:/home/sha/nfsroot/generic-v7,v3,tcp
+  linux.bootargs.root: /dev/nfs
+  linux.bootargs.rootopts: nfsroot=192.168.23.4:/home/sha/nfsroot/generic-v7,v3,tcp
 
 The options default to ``v3,tcp`` but can be adjusted before mounting the NFS share with
 the ``global.linux.rootnfsopts`` variable
diff --git a/Documentation/migration-guides/migration-master.rst b/Documentation/migration-guides/migration-master.rst
new file mode 100644
index 0000000000..3b20dc1e4e
--- /dev/null
+++ b/Documentation/migration-guides/migration-master.rst
@@ -0,0 +1,18 @@
+Filesystems
+-----------
+
+``{linux.bootargs}`` is replaced with ``root={linux.bootargs.root} {linux.bootargs.rootopts}``
+
+The variable linux.bootargs has been replaced by the two variables
+linux.bootargs.root and linux.bootargs.rootopts, splitting the previous bootargs
+into three parts. A nonexistent fixed "root=", then the root filesystem and then
+additional optional params for this particular filesystem.
+
+for example the previous::
+
+    linux.bootargs="root=/dev/nfs nfsroot=192.168.1.1:/rootfs"
+
+becomes::
+
+    linux.bootargs.root="/dev/nfs"
+    linux.bootargs.rootopts="nfsroot=192.168.1.1:/rootfs"
diff --git a/common/block.c b/common/block.c
index 07c4d5d504..345adad722 100644
--- a/common/block.c
+++ b/common/block.c
@@ -584,34 +584,45 @@ const char *blk_type_str(enum blk_type type)
 	}
 }
 
-char *cdev_get_linux_rootarg(const struct cdev *partcdev)
+int cdev_get_linux_root_and_opts(const struct cdev *partcdev, char **root, char **rootopts)
 {
+
 	const struct cdev *cdevm;
 	struct block_device *blk;
-	char *rootarg = NULL;
+	char *root_local = NULL;
 
 	if (!partcdev)
-		return NULL;
+		return -EINVAL;
 
 	cdevm = partcdev->master ?: partcdev;
 	blk = cdev_get_block_device(cdevm);
 	if (!blk)
-		return NULL;
+		return -EINVAL;
 
-	if (blk->ops->get_root) {
-		char *root = NULL;
-		root = blk->ops->get_root(blk, partcdev);
-		if (root) {
-			rootarg = basprintf("root=%s", root);
-			free(root);
-		}
-	}
-	if (!rootarg && partcdev->partuuid[0] != 0)
-		rootarg = basprintf("root=PARTUUID=%s", partcdev->partuuid);
+	if (blk->ops->get_root)
+		root_local = blk->ops->get_root(blk, partcdev);
+	if (!root_local && partcdev->partuuid[0] != 0)
+		root_local = xasprintf("PARTUUID=%s", partcdev->partuuid);
+
+	if (!root_local)
+		return -ENODEV;
 
 	if (IS_ENABLED(CONFIG_ROOTWAIT_BOOTARG) && blk->rootwait)
-		rootarg = linux_bootargs_append_rootwait(rootarg);
+		*rootopts = xasprintf("rootwait=%d", linux_rootwait_secs);
 
-	return rootarg;
+	*root = root_local;
+	return 0;
 }
 
+char *cdev_get_linux_rootarg(const struct cdev *partcdev)
+{
+	int err;
+	char *root = NULL;
+	char *rootopts = NULL;
+
+	err = cdev_get_linux_root_and_opts(partcdev, &root, &rootopts);
+	if (err)
+		return NULL;
+
+	return format_root_bootarg("root", root, rootopts);
+}
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
index 6a451d9ef5..efc9a9193d 100644
--- a/fs/9p/vfs_super.c
+++ b/fs/9p/vfs_super.c
@@ -70,11 +70,11 @@ static void v9fs_set_rootarg(struct v9fs_session_info *v9ses,
 	trans = v9ses->clnt->trans_mod->name;
 	path = v9ses->aname;
 
-	str = basprintf("root=%s rootfstype=9p rootflags=trans=%s,msize=%d,"
+	str = basprintf("rootfstype=9p rootflags=trans=%s,msize=%d,"
 			"cache=loose,uname=%s,dfltuid=0,dfltgid=0,aname=%s",
-			tag, trans, v9ses->clnt->msize, tag, path);
+			trans, v9ses->clnt->msize, tag, path);
 
-	fsdev_set_linux_rootarg(fsdev, str);
+	fsdev_set_linux_root_options(fsdev, tag, str);
 
 	free(str);
 }
diff --git a/fs/fs.c b/fs/fs.c
index 528299e039..0f27879395 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -14,6 +14,7 @@
  *
  */
 
+#include <bootargs.h>
 #include <common.h>
 #include <command.h>
 #include <fs.h>
@@ -1226,12 +1227,34 @@ void mount_all(void)
 	}
 }
 
-void fsdev_set_linux_rootarg(struct fs_device *fsdev, const char *str)
+void fsdev_set_linux_root_options(struct fs_device *fsdev, const char *root, const char *rootopts)
 {
-	fsdev->linux_rootarg = xstrdup(str);
+	fsdev->linux_root = xstrdup(root);
+	fsdev->linux_rootopts = xstrdup(rootopts);
 
-	dev_add_param_fixed(&fsdev->dev, "linux.bootargs",
-			    "%s", fsdev->linux_rootarg);
+	dev_add_param_fixed(&fsdev->dev, "linux.bootargs.root",
+			    "%s", fsdev->linux_root);
+	dev_add_param_fixed(&fsdev->dev, "linux.bootargs.rootopts",
+			    "%s", fsdev->linux_rootopts);
+}
+
+void fsdev_get_linux_root_options(struct fs_device *fsdev, char **root, char **rootopts)
+{
+	if (fsdev) {
+		*root = dev_get_param(&fsdev->dev, "linux.bootargs.root");
+		*rootopts = dev_get_param(&fsdev->dev, "linux.bootargs.rootopts");
+	}
+}
+
+char *format_root_bootarg(const char *root_arg, char *root, char *rootopts) {
+	char *bootarg;
+	if (rootopts)
+		bootarg = xasprintf("%s=%s %s", root_arg, root, rootopts);
+	else
+		bootarg = xasprintf("%s=%s", root_arg, root);
+	free(root);
+	free(rootopts);
+	return bootarg;
 }
 
 /**
@@ -1245,17 +1268,19 @@ void fsdev_set_linux_rootarg(struct fs_device *fsdev, const char *str)
 char *path_get_linux_rootarg(const char *path)
 {
 	struct fs_device *fsdev;
-	const char *str;
+	char *root = NULL;
+	char *rootopts = NULL;
 
 	fsdev = get_fsdevice_by_path(AT_FDCWD, path);
 	if (!fsdev)
-		return ERR_PTR(-EINVAL);
-
-	str = dev_get_param(&fsdev->dev, "linux.bootargs");
-	if (!str)
 		return ERR_PTR(-ENOSYS);
 
-	return xstrdup(str);
+	fsdev_get_linux_root_options(fsdev, &root, &rootopts);
+
+	if (!root)
+		return ERR_PTR(-ENOSYS);
+
+	return format_root_bootarg("root", root, rootopts);
 }
 
 /**
@@ -3249,12 +3274,16 @@ int mount(const char *device, const char *fsname, const char *pathname,
 
 	fsdev->vfsmount.mnt_root = fsdev->sb.s_root;
 
-	if (!fsdev->linux_rootarg) {
-		char *str;
+	if (!fsdev->linux_root) {
+		char *root = NULL;
+		char *rootopts = NULL;
 
-		str = cdev_get_linux_rootarg(fsdev->cdev);
-		if (str)
-			fsdev_set_linux_rootarg(fsdev, str);
+		ret = cdev_get_linux_root_and_opts(fsdev->cdev, &root, &rootopts);
+		if (ret == 0) {
+			fsdev_set_linux_root_options(fsdev, root, rootopts);
+			free(root);
+			free(rootopts);
+		}
 	}
 
 	path_put(&path);
diff --git a/fs/nfs.c b/fs/nfs.c
index 5c2476cd88..0b40c56ff3 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -1558,7 +1558,7 @@ static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device *fsdev)
 	char *str, *tmp;
 	const char *bootargs;
 
-	str = basprintf("root=/dev/nfs nfsroot=%pI4:%s%s%s", &npriv->server, npriv->path,
+	str = basprintf("nfsroot=%pI4:%s%s%s", &npriv->server, npriv->path,
 			  rootnfsopts[0] ? "," : "", rootnfsopts);
 
 	/* forward specific mount options on demand */
@@ -1584,7 +1584,7 @@ static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device *fsdev)
 	if (IS_ENABLED(CONFIG_ROOTWAIT_BOOTARG))
 		str = linux_bootargs_append_rootwait(str);
 
-	fsdev_set_linux_rootarg(fsdev, str);
+	fsdev_set_linux_root_options(fsdev, "/dev/nfs", str);
 
 	free(str);
 }
diff --git a/fs/squashfs/squashfs.c b/fs/squashfs/squashfs.c
index e30372627a..365aa1f219 100644
--- a/fs/squashfs/squashfs.c
+++ b/fs/squashfs/squashfs.c
@@ -46,7 +46,8 @@ static void squashfs_set_rootarg(struct fs_device *fsdev)
 	struct ubi_volume_info vi = {};
 	struct ubi_device_info di = {};
 	struct mtd_info *mtd;
-	char *str;
+	char *root;
+	char *rootopts;
 
 	if (!IS_ENABLED(CONFIG_MTD_UBI))
 		return;
@@ -60,12 +61,14 @@ static void squashfs_set_rootarg(struct fs_device *fsdev)
 	ubi_get_device_info(vi.ubi_num, &di);
 	mtd = di.mtd;
 
-	str = basprintf("root=/dev/ubiblock%d_%d ubi.mtd=%s ubi.block=%d,%d rootfstype=squashfs",
-			vi.ubi_num, vi.vol_id, mtd->cdev.partname, vi.ubi_num, vi.vol_id);
+	root = basprintf("/dev/ubiblock%d_%d", vi.ubi_num, vi.vol_id);
+	rootopts = basprintf("ubi.mtd=%s ubi.block=%d,%d rootfstype=squashfs",
+			mtd->cdev.partname, vi.ubi_num, vi.vol_id);
 
-	fsdev_set_linux_rootarg(fsdev, str);
+	fsdev_set_linux_root_options(fsdev, root, rootopts);
 
-	free(str);
+	free(root);
+	free(rootopts);
 }
 
 static struct inode *squashfs_alloc_inode(struct super_block *sb)
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 37986acbb2..9cc35fa273 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -435,19 +435,21 @@ static void ubifs_set_rootarg(struct ubifs_priv *priv,
 	struct ubi_volume_info vi = {};
 	struct ubi_device_info di = {};
 	struct mtd_info *mtd;
-	char *str;
+	char *root;
+	char *rootopts;
 
 	ubi_get_volume_info(priv->ubi, &vi);
 	ubi_get_device_info(vi.ubi_num, &di);
 
 	mtd = di.mtd;
 
-	str = basprintf("root=ubi0:%s ubi.mtd=%s rootfstype=ubifs",
-			  vi.name, mtd->cdev.partname);
+	root = basprintf("ubi0:%s", vi.name);
+	rootopts = basprintf("ubi.mtd=%s rootfstype=ubifs", mtd->cdev.partname);
 
-	fsdev_set_linux_rootarg(fsdev, str);
+	fsdev_set_linux_root_options(fsdev, root, rootopts);
 
-	free(str);
+	free(root);
+	free(rootopts);
 }
 
 static int ubifs_probe(struct device *dev)
diff --git a/include/block.h b/include/block.h
index b277f590e4..cbab04095d 100644
--- a/include/block.h
+++ b/include/block.h
@@ -85,6 +85,7 @@ static inline int block_flush(struct block_device *blk)
 #ifdef CONFIG_BLOCK
 unsigned file_list_add_blockdevs(struct file_list *files);
 char *cdev_get_linux_rootarg(const struct cdev *partcdev);
+int cdev_get_linux_root_and_opts(const struct cdev *partcdev, char** root, char** rootopts);
 #else
 static inline unsigned file_list_add_blockdevs(struct file_list *files)
 {
@@ -94,6 +95,10 @@ static inline char *cdev_get_linux_rootarg(const struct cdev *partcdev)
 {
 	return NULL;
 }
+static inline int cdev_get_linux_root_and_opts(const struct cdev *partcdev, char** root, char** rootopts)
+{
+	return -ENOSYS;
+}
 #endif
 
 static inline bool cdev_is_block_device(const struct cdev *cdev)
diff --git a/include/bootargs.h b/include/bootargs.h
index 1cf88bd380..6cb61750d1 100644
--- a/include/bootargs.h
+++ b/include/bootargs.h
@@ -26,4 +26,6 @@ static inline char *linux_bootargs_append_rootwait(char *rootarg)
 }
 #endif
 
+char *format_root_bootarg(const char *root_arg, char *root, char *rootopts);
+
 #endif /* __BOOTARGS_H */
diff --git a/include/fs.h b/include/fs.h
index 98c482bbf2..c50437d609 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -90,7 +90,8 @@ struct fs_device {
 	char *path;
 	struct list_head list;
 	char *options;
-	char *linux_rootarg;
+	char *linux_root;
+	char *linux_rootopts;
 
 	struct super_block sb;
 
@@ -159,7 +160,8 @@ const char *cdev_mount_default(struct cdev *cdev, const char *fsoptions);
 const char *cdev_mount(struct cdev *cdev);
 void mount_all(void);
 
-void fsdev_set_linux_rootarg(struct fs_device *fsdev, const char *str);
+void fsdev_set_linux_root_options(struct fs_device *fsdev, const char *root, const char* rootopts);
+void fsdev_get_linux_root_options(struct fs_device *fsdev, char **root, char **rootopts);
 char *path_get_linux_rootarg(const char *path);
 
 static inline const char *devpath_to_name(const char *devpath)
-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v5 3/4] bootm: use new api to get kernel command line params
  2025-12-01  7:20           ` [PATCH v5 0/4] make the root= command line parameter variable Fabian Pflug
  2025-12-01  7:20             ` [PATCH v5 1/4] block.h: renamed get_rootargs to get_root Fabian Pflug
  2025-12-01  7:20             ` [PATCH v5 2/4] fs: split rootargs into root and options Fabian Pflug
@ 2025-12-01  7:20             ` Fabian Pflug
  2025-12-01  7:21             ` [PATCH v5 4/4] bootm: introduce bootm.root_param variable Fabian Pflug
  3 siblings, 0 replies; 41+ messages in thread
From: Fabian Pflug @ 2025-12-01  7:20 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug, Ahmad Fatoum

Getting root device and root kernel options seperatly and combining
them in this function instead of getting the full string from the helper
functions. This is in preparation for replacing the root= string in the
kernel commandline with something defined during runtime.

Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/bootm.c | 23 +++++++++++++++++------
 fs/fs.c        | 26 --------------------------
 include/fs.h   |  1 -
 3 files changed, 17 insertions(+), 33 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 17792b2a1d..adc76eba64 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -1,9 +1,11 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 
 #include <common.h>
+#include <bootargs.h>
 #include <bootm.h>
 #include <bootm-overrides.h>
 #include <fs.h>
+#include <fcntl.h>
 #include <malloc.h>
 #include <memory.h>
 #include <block.h>
@@ -841,33 +843,42 @@ int bootm_boot(struct bootm_data *bootm_data)
 	}
 
 	if (bootm_data->appendroot) {
-		char *rootarg;
+		char *root = NULL;
+		char *rootopts = NULL;
 
 		if (bootm_data->root_dev) {
 			const char *root_dev_name = devpath_to_name(bootm_data->root_dev);
 			struct cdev *root_cdev = cdev_open_by_name(root_dev_name, O_RDONLY);
 
-			rootarg = cdev_get_linux_rootarg(root_cdev);
-			if (!rootarg) {
-				rootarg = ERR_PTR(-EINVAL);
+			ret = cdev_get_linux_root_and_opts(root_cdev, &root, &rootopts);
 
+			if (ret) {
 				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
+					pr_err("could not determine root= from %s\n",
+						root_dev_name);
 			}
 
 			if (root_cdev)
 				cdev_close(root_cdev);
 		} else {
-			rootarg = path_get_linux_rootarg(data->os_file);
+			struct fs_device *fsdev = get_fsdevice_by_path(AT_FDCWD, data->os_file);
+			if (fsdev)
+				fsdev_get_linux_root_options(fsdev, &root, &rootopts);
+			else
+				pr_err("no fsdevice under path: %s\n", data->os_file);
 		}
 
-		if (IS_ERR(rootarg)) {
+		if (!root) {
 			pr_err("Failed to append kernel cmdline parameter 'root='\n");
 		} else {
+			char *rootarg;
+			rootarg = format_root_bootarg("root", root, rootopts);
 			pr_info("Adding \"%s\" to Kernel commandline\n", rootarg);
 			globalvar_add_simple("linux.bootargs.bootm.appendroot",
 					     rootarg);
diff --git a/fs/fs.c b/fs/fs.c
index 0f27879395..ae6a776b2b 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -1257,32 +1257,6 @@ char *format_root_bootarg(const char *root_arg, char *root, char *rootopts) {
 	return bootarg;
 }
 
-/**
- * path_get_linux_rootarg() - Given a path return a suitable root= option for
- *                            Linux
- * @path: The path
- *
- * Return: A string containing the root= option or an ERR_PTR. the returned
- *         string must be freed by the caller.
- */
-char *path_get_linux_rootarg(const char *path)
-{
-	struct fs_device *fsdev;
-	char *root = NULL;
-	char *rootopts = NULL;
-
-	fsdev = get_fsdevice_by_path(AT_FDCWD, path);
-	if (!fsdev)
-		return ERR_PTR(-ENOSYS);
-
-	fsdev_get_linux_root_options(fsdev, &root, &rootopts);
-
-	if (!root)
-		return ERR_PTR(-ENOSYS);
-
-	return format_root_bootarg("root", root, rootopts);
-}
-
 /**
  * __is_tftp_fs() - return true when path is mounted on TFTP
  * @path: The path
diff --git a/include/fs.h b/include/fs.h
index c50437d609..ddd93e93ec 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -162,7 +162,6 @@ void mount_all(void);
 
 void fsdev_set_linux_root_options(struct fs_device *fsdev, const char *root, const char* rootopts);
 void fsdev_get_linux_root_options(struct fs_device *fsdev, char **root, char **rootopts);
-char *path_get_linux_rootarg(const char *path);
 
 static inline const char *devpath_to_name(const char *devpath)
 {
-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v5 4/4] bootm: introduce bootm.root_param variable
  2025-12-01  7:20           ` [PATCH v5 0/4] make the root= command line parameter variable Fabian Pflug
                               ` (2 preceding siblings ...)
  2025-12-01  7:20             ` [PATCH v5 3/4] bootm: use new api to get kernel command line params Fabian Pflug
@ 2025-12-01  7:21             ` Fabian Pflug
  3 siblings, 0 replies; 41+ messages in thread
From: Fabian Pflug @ 2025-12-01  7:21 UTC (permalink / raw)
  To: barebox; +Cc: Fabian Pflug, Ahmad Fatoum

The bootm.root_param variable will be responsible for the root= part of
the kernel commandline if bootm.appendroot is set and a root device has
been selected.
root_param allows to replace the root=/dev/... with verity=/dev/..., which
is useful in a verified boot context, where you pass the root file
system to the initramfs, but do not want the kernel to be able to parse
and mount the rootfs. With renaming the root= to something different,
you make sure, that the kernel does not mount the rootfs.

Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---

Add section in security about how to use the new function to prevent
linux from mounting the rootfs and motivation behind it.

 Documentation/user/security.rst | 16 ++++++++++++++++
 common/bootm.c                  | 20 ++++++++++++--------
 include/bootm.h                 |  1 +
 3 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/Documentation/user/security.rst b/Documentation/user/security.rst
index 357ea86a1d..5a23bd83ba 100644
--- a/Documentation/user/security.rst
+++ b/Documentation/user/security.rst
@@ -86,6 +86,22 @@ can be used to compile in well known development keys into the barebox binary.
 The private keys for these keys can be found
 `[here] <https://git.pengutronix.de/cgit/ptx-code-signing-dev>`__
 
+Prevent the kernel from booting the rootfs in verity boots
+----------------------------------------------------------
+
+In systems, where barebox loads an initramfs that setups a dm-verity rootfs and
+passes the location of the root file system on the kernel command-line, make
+sure not to use ``root=``!
+``root=`` is also interpreted by the kernel and can lead to the kernel mounting
+the rootfs without dm-verity, if the initramfs failed to load, e.g. due to
+different compression algorithm.
+
+The fail-safe alternative is to use a parameter name understood only by the
+initramfs (e.g. ``verity_root=``) in all bootloader scripts. If the
+``root=$dev`` is fixed up by barebox dynamically, the
+``$global.bootm.root_param`` variable can be used to customize the name of the
+parameter passed to Linux.
+
 Disabling the shell
 ^^^^^^^^^^^^^^^^^^^
 
diff --git a/common/bootm.c b/common/bootm.c
index adc76eba64..8f52071ef2 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -70,6 +70,7 @@ void bootm_data_init_defaults(struct bootm_data *data)
 		data->initrd_file = getenv_nonempty("global.bootm.initrd");
 	}
 	data->root_dev = getenv_nonempty("global.bootm.root_dev");
+	data->root_param = getenv_nonempty("global.bootm.root_param");
 	data->verify = bootm_get_verify_mode();
 	data->appendroot = bootm_appendroot;
 	data->provide_machine_id = bootm_provide_machine_id;
@@ -89,6 +90,7 @@ void bootm_data_restore_defaults(const struct bootm_data *data)
 		globalvar_set("bootm.initrd", data->initrd_file);
 	}
 	globalvar_set("bootm.root_dev", data->root_dev);
+	globalvar_set("bootm.root_param", data->root_param);
 	bootm_set_verify_mode(data->verify);
 	bootm_appendroot = data->appendroot;
 	bootm_provide_machine_id = data->provide_machine_id;
@@ -854,14 +856,14 @@ int bootm_boot(struct bootm_data *bootm_data)
 
 			if (ret) {
 				if (!root_cdev)
-					pr_err("no cdev found for %s, cannot set root= option\n",
-						root_dev_name);
+					pr_err("no cdev found for %s, cannot set %s= option\n",
+						root_dev_name, bootm_data->root_param);
 				else if (!root_cdev->partuuid[0])
-					pr_err("%s doesn't have a PARTUUID, cannot set root= option\n",
-						root_dev_name);
+					pr_err("%s doesn't have a PARTUUID, cannot set %s= option\n",
+						root_dev_name, bootm_data->root_param);
 				else
-					pr_err("could not determine root= from %s\n",
-						root_dev_name);
+					pr_err("could not determine %s= from %s\n",
+						bootm_data->root_param, root_dev_name);
 			}
 
 			if (root_cdev)
@@ -875,10 +877,10 @@ int bootm_boot(struct bootm_data *bootm_data)
 		}
 
 		if (!root) {
-			pr_err("Failed to append kernel cmdline parameter 'root='\n");
+			pr_err("Failed to append kernel cmdline parameter '%s='\n", bootm_data->root_param);
 		} else {
 			char *rootarg;
-			rootarg = format_root_bootarg("root", root, rootopts);
+			rootarg = format_root_bootarg(bootm_data->root_param, root, rootopts);
 			pr_info("Adding \"%s\" to Kernel commandline\n", rootarg);
 			globalvar_add_simple("linux.bootargs.bootm.appendroot",
 					     rootarg);
@@ -1121,6 +1123,7 @@ static int bootm_init(void)
 	globalvar_add_simple("bootm.image.loadaddr", NULL);
 	globalvar_add_simple("bootm.oftree", NULL);
 	globalvar_add_simple("bootm.root_dev", NULL);
+	globalvar_add_simple("bootm.root_param", "root");
 	globalvar_add_simple("bootm.tee", NULL);
 	globalvar_add_simple_bool("bootm.appendroot", &bootm_appendroot);
 	globalvar_add_simple_bool("bootm.earlycon", &bootm_earlycon);
@@ -1178,5 +1181,6 @@ BAREBOX_MAGICVAR(global.bootm.verbose, "bootm default verbosity level (0=quiet)"
 BAREBOX_MAGICVAR(global.bootm.earlycon, "Add earlycon option to Kernel for early log output");
 BAREBOX_MAGICVAR(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(global.bootm.root_dev, "bootm default root device (overrides default device in global.bootm.appendroot)");
+BAREBOX_MAGICVAR(global.bootm.root_param, "bootm root parameter name (normally 'root' for root=/dev/...)");
 BAREBOX_MAGICVAR(global.bootm.provide_machine_id, "If true, append systemd.machine_id=$global.machine_id to Kernel command line");
 BAREBOX_MAGICVAR(global.bootm.provide_hostname, "If true, append systemd.hostname=$global.hostname to Kernel command line");
diff --git a/include/bootm.h b/include/bootm.h
index b35deb25bf..14b2465500 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -19,6 +19,7 @@ struct bootm_data {
 	const char *oftree_file;
 	const char *tee_file;
 	const char *root_dev;
+	const char *root_param;
 	int verbose;
 	enum bootm_verify verify;
 	bool force;
-- 
2.47.3




^ permalink raw reply	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2025-12-01  7:25 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-24 10:16 [PATCH] common: setting the root= command line parameter Fabian Pflug
2025-11-24 12:00 ` Ahmad Fatoum
2025-11-25 10:22   ` Fabian Pflug
2025-11-25 19:13     ` Ahmad Fatoum
2025-11-26  6:42   ` [PATCH 0/4] make the root= command line parameter variable Fabian Pflug
2025-11-26  6:42     ` [PATCH 1/4] block.h: renamed get_rootargs to get_root Fabian Pflug
2025-11-26  9:50       ` Ahmad Fatoum
2025-11-26  6:42     ` [PATCH 2/4] fs: split rootargs into root and options Fabian Pflug
2025-11-26 10:13       ` Ahmad Fatoum
2025-11-26 10:31       ` Ahmad Fatoum
2025-11-26  6:42     ` [PATCH 3/4] bootm: use new api to get kernel command line params Fabian Pflug
2025-11-26 10:25       ` Ahmad Fatoum
2025-11-26 11:29         ` Fabian Pflug
2025-11-26 11:33           ` Ahmad Fatoum
2025-11-26  6:42     ` [PATCH 4/4] bootm: introduce bootm.root_arg variable Fabian Pflug
2025-11-26 10:28       ` Ahmad Fatoum
2025-11-27 10:57     ` [PATCH v2 0/4] make the root= command line parameter variable Fabian Pflug
2025-11-27 10:57       ` [PATCH v2 1/4] block.h: renamed get_rootargs to get_root Fabian Pflug
2025-11-27 11:08         ` Ahmad Fatoum
2025-11-27 10:57       ` [PATCH v2 2/4] fs: split rootargs into root and options Fabian Pflug
2025-11-27 10:57       ` [PATCH v2 3/4] bootm: use new api to get kernel command line params Fabian Pflug
2025-11-27 10:57       ` [PATCH v2 4/4] bootm: introduce bootm.root_arg variable Fabian Pflug
2025-11-27 14:25       ` [PATCH v3 0/4] make the root= command line parameter variable Fabian Pflug
2025-11-27 14:25         ` [PATCH v3 1/4] block.h: renamed get_rootargs to get_root Fabian Pflug
2025-11-28  9:45           ` Ahmad Fatoum
2025-11-27 14:25         ` [PATCH v3 2/4] fs: split rootargs into root and options Fabian Pflug
2025-11-28 10:01           ` Ahmad Fatoum
2025-11-27 14:25         ` [PATCH v3 3/4] bootm: use new api to get kernel command line params Fabian Pflug
2025-11-28 10:04           ` Ahmad Fatoum
2025-11-27 14:25         ` [PATCH v3 4/4] bootm: introduce bootm.root_arg variable Fabian Pflug
2025-11-28 10:07           ` Ahmad Fatoum
2025-11-28 14:58         ` [PATCH v4 0/4] make the root= command line parameter variable Fabian Pflug
2025-11-28 14:59           ` [PATCH v4 1/4] block.h: renamed get_rootargs to get_root Fabian Pflug
2025-11-28 14:59           ` [PATCH 2/4] fs: split rootargs into root and options Fabian Pflug
2025-11-28 14:59           ` [PATCH v4 3/4] bootm: use new api to get kernel command line params Fabian Pflug
2025-11-28 14:59           ` [PATCH v4 4/4] bootm: introduce bootm.root_arg variable Fabian Pflug
2025-12-01  7:20           ` [PATCH v5 0/4] make the root= command line parameter variable Fabian Pflug
2025-12-01  7:20             ` [PATCH v5 1/4] block.h: renamed get_rootargs to get_root Fabian Pflug
2025-12-01  7:20             ` [PATCH v5 2/4] fs: split rootargs into root and options Fabian Pflug
2025-12-01  7:20             ` [PATCH v5 3/4] bootm: use new api to get kernel command line params Fabian Pflug
2025-12-01  7:21             ` [PATCH v5 4/4] bootm: introduce bootm.root_param variable Fabian Pflug

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox