mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] bootchooser: Change name of kernel parameter
@ 2020-01-27  7:46 Christian Eggers
  2020-01-27  8:31 ` Ahmad Fatoum
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Eggers @ 2020-01-27  7:46 UTC (permalink / raw)
  To: barebox; +Cc: Christian Eggers, ceggers

When passing the target name as "bootchooser.active", Linux will not
pass the parameter as environment variable to the init process. The only
way to get the bootchooser result (e.g. in an initramfs), is to parse it
out of /proc/cmdline (requires mounting of /proc, sed, ...).

After renaming, the bootchooser result will be passed as environment
variable which can easily accessed from /init (e.g. for selecting the
associated root fs).

Signed-off-by: Christian Eggers <ceggers@arri.de>
---
 common/bootchooser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/bootchooser.c b/common/bootchooser.c
index c08db03eb..f0e3294dc 100644
--- a/common/bootchooser.c
+++ b/common/bootchooser.c
@@ -817,7 +817,7 @@ static int bootchooser_boot_one(struct bootchooser *bc, int *tryagain)
 		goto out;
 	}
 
-	system = basprintf("bootchooser.active=%s", target->name);
+	system = basprintf("bootchooser_active=%s", target->name);
 	globalvar_add_simple("linux.bootargs.bootchooser", system);
 	free(system);
 
-- 
Christian Eggers
Embedded software developer

Arnold & Richter Cine Technik GmbH & Co. Betriebs KG
Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: HRA 57918
Persoenlich haftender Gesellschafter: Arnold & Richter Cine Technik GmbH
Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: HRB 54477
Geschaeftsfuehrer: Dr. Michael Neuhaeuser; Stephan Schenk; Walter Trauninger; Markus Zeiler


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] bootchooser: Change name of kernel parameter
  2020-01-27  7:46 [PATCH] bootchooser: Change name of kernel parameter Christian Eggers
@ 2020-01-27  8:31 ` Ahmad Fatoum
  2020-01-27  9:37   ` Christian Eggers
  0 siblings, 1 reply; 3+ messages in thread
From: Ahmad Fatoum @ 2020-01-27  8:31 UTC (permalink / raw)
  To: Christian Eggers, barebox; +Cc: ceggers

Hello Christian,

On 1/27/20 8:46 AM, Christian Eggers wrote:
> When passing the target name as "bootchooser.active", Linux will not
> pass the parameter as environment variable to the init process. The only
> way to get the bootchooser result (e.g. in an initramfs), is to parse it
> out of /proc/cmdline (requires mounting of /proc, sed, ...).
> 
> After renaming, the bootchooser result will be passed as environment
> variable which can easily accessed from /init (e.g. for selecting the
> associated root fs).

Existing userspace like RAUC[1] rely on this naming, so the default may
not be changed.

[1]: https://github.com/rauc/rauc/blob/f52978d9736f18794f7e277ca440e2e4e78c9703/src/context.c#L47

Cheers
Ahmad

> 
> Signed-off-by: Christian Eggers <ceggers@arri.de>
> ---
>  common/bootchooser.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/common/bootchooser.c b/common/bootchooser.c
> index c08db03eb..f0e3294dc 100644
> --- a/common/bootchooser.c
> +++ b/common/bootchooser.c
> @@ -817,7 +817,7 @@ static int bootchooser_boot_one(struct bootchooser *bc, int *tryagain)
>  		goto out;
>  	}
>  
> -	system = basprintf("bootchooser.active=%s", target->name);
> +	system = basprintf("bootchooser_active=%s", target->name);
>  	globalvar_add_simple("linux.bootargs.bootchooser", system);
>  	free(system);
>  
> 

-- 
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 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] bootchooser: Change name of kernel parameter
  2020-01-27  8:31 ` Ahmad Fatoum
@ 2020-01-27  9:37   ` Christian Eggers
  0 siblings, 0 replies; 3+ messages in thread
From: Christian Eggers @ 2020-01-27  9:37 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox, ceggers

Hello Ahmad,

> Existing userspace like RAUC[1] rely on this naming, so the default may
> not be changed.
> 
> [1]: https://github.com/rauc/rauc/blob/f52978d9736f18794f7e277ca440e2e4e78c9703/src/context.c#L47
that is what I already suspected...

For my initramfs (klibc based), I need a very cheap solution for mounting the "right" root fs. Currently
I work only with standard utilities (sh, mount, cat, ...) and I avoid creating a own program for this.
I had just success with the following expression

read CMDLINE < /proc/cmdline
if [ "${CMDLINE#bootchooser.active=system1}" != "${CMDLINE}" ]; then
	root=ubi0:rootfs1
else
	root=ubi0:rootfs0
fi
mount -t ubifs $root /root

If the string "bootchooser.active=system1" appears on the command line, the expression will match.
This way I can distinguish between "system1" and "system0".

As the result, my previous patch should be dropped.

regards
Christian





_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2020-01-27  9:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-27  7:46 [PATCH] bootchooser: Change name of kernel parameter Christian Eggers
2020-01-27  8:31 ` Ahmad Fatoum
2020-01-27  9:37   ` Christian Eggers

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