public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
* [PATCH] initramfs-framework: remove hard dependency with busybox
       [not found] <20250328180456.90413-1-gavrosc.ref@yahoo.com>
@ 2025-03-28 18:04 ` Christos Gavros
  2025-03-29 13:45   ` [OE-core] " Adrian Freihofer
  0 siblings, 1 reply; 6+ messages in thread
From: Christos Gavros @ 2025-03-28 18:04 UTC (permalink / raw)
  To: openembedded-core
  Cc: Christos Gavros, Yoann Congal, Randy MacLeod, Ross Burton, jbk

In 'finish'script the Switch_root command with option -c is busybox specific.
When package-core-base-utils is selected the boot is breaking.
Remove -c option to make it compatible with both providers
Fixes [YOCTO #15716]

CC: Yoann Congal <yoann.congal@smile.fr>
CC: Randy MacLeod <randy.macleod@windriver.com>
CC: Ross Burton <ross.burton@arm.com>
CC: jbk <jbk@mm-software.com>
Signed-off-by: Christos Gavros <gavrosc@yahoo.com>
---
 meta/recipes-core/initrdscripts/initramfs-framework/finish | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/finish b/meta/recipes-core/initrdscripts/initramfs-framework/finish
index ac0de9f996..716c2f44af 100755
--- a/meta/recipes-core/initrdscripts/initramfs-framework/finish
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/finish
@@ -41,7 +41,7 @@ finish_run() {
 		mount --move /sys $ROOTFS_DIR/sys
 
 		cd $ROOTFS_DIR
-		exec switch_root -c /dev/console $ROOTFS_DIR ${bootparam_init:-/sbin/init}
+		exec switch_root $ROOTFS_DIR ${bootparam_init:-/sbin/init}
 	else
 		debug "No rootfs has been set"
 	fi
-- 
2.34.1



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

* Re: [OE-core] [PATCH] initramfs-framework: remove hard dependency with busybox
  2025-03-28 18:04 ` [PATCH] initramfs-framework: remove hard dependency with busybox Christos Gavros
@ 2025-03-29 13:45   ` Adrian Freihofer
  2025-03-29 16:01     ` Christos Gavros
  0 siblings, 1 reply; 6+ messages in thread
From: Adrian Freihofer @ 2025-03-29 13:45 UTC (permalink / raw)
  To: gavrosc, openembedded-core; +Cc: Yoann Congal, Randy MacLeod, Ross Burton, jbk

Hi Christos

Since the -c has been around for a very long time, I assume that there
are many users who use it with busybox. Using it with core-utils will
probably remain the special use case.
The proposed fix raises the question of why the -c was introduced at
some point. If your fix also works for busybox, was the -c always
redundant? Or has something changed in the meantime?

Please also address the busybox users' point of view in the commit
message and summarize how this was tested with busybox in particular.

Thank you.
Adrian


On Fri, 2025-03-28 at 19:04 +0100, Christos Gavros via
lists.openembedded.org wrote:
> In 'finish'script the Switch_root command with option -c is busybox
> specific.
> When package-core-base-utils is selected the boot is breaking.
> Remove -c option to make it compatible with both providers
> Fixes [YOCTO #15716]
> 
> CC: Yoann Congal <yoann.congal@smile.fr>
> CC: Randy MacLeod <randy.macleod@windriver.com>
> CC: Ross Burton <ross.burton@arm.com>
> CC: jbk <jbk@mm-software.com>
> Signed-off-by: Christos Gavros <gavrosc@yahoo.com>
> ---
>  meta/recipes-core/initrdscripts/initramfs-framework/finish | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/meta/recipes-core/initrdscripts/initramfs-
> framework/finish b/meta/recipes-core/initrdscripts/initramfs-
> framework/finish
> index ac0de9f996..716c2f44af 100755
> --- a/meta/recipes-core/initrdscripts/initramfs-framework/finish
> +++ b/meta/recipes-core/initrdscripts/initramfs-framework/finish
> @@ -41,7 +41,7 @@ finish_run() {
>  		mount --move /sys $ROOTFS_DIR/sys
>  
>  		cd $ROOTFS_DIR
> -		exec switch_root -c /dev/console $ROOTFS_DIR
> ${bootparam_init:-/sbin/init}
> +		exec switch_root $ROOTFS_DIR ${bootparam_init:-
> /sbin/init}
>  	else
>  		debug "No rootfs has been set"
>  	fi
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#213861):
> https://lists.openembedded.org/g/openembedded-core/message/213861
> Mute This Topic: https://lists.openembedded.org/mt/111959232/4454582
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe:
> https://lists.openembedded.org/g/openembedded-core/unsub [
> adrian.freihofer@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
> 



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

* Re: [PATCH] initramfs-framework: remove hard dependency with busybox
  2025-03-29 13:45   ` [OE-core] " Adrian Freihofer
@ 2025-03-29 16:01     ` Christos Gavros
  2025-03-29 16:29       ` [OE-core] " Khem Raj
  0 siblings, 1 reply; 6+ messages in thread
From: Christos Gavros @ 2025-03-29 16:01 UTC (permalink / raw)
  To: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 611 bytes --]

hi Adrian

thank you for the comment. I had a look in commits log and it looks that '-c' was there since the beginning in 2008/09/10 in script 'init-live.sh' and then moved in 'finish.sh' in 2011/12/08.
I reproduced the issue by using qemu and I described how I did it in detail in bug # 15716.
After I applied the change I tested both busybox and packagegroup-core-base-utils. The boot was successful in both cases.
Also '-c' is an option in busybox: https://www.busybox.net/downloads/BusyBox.html

I will wait for more comments and then I will extend the commit message and send a v2.

Br
Christos

[-- Attachment #2: Type: text/html, Size: 7528 bytes --]

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

* Re: [OE-core] [PATCH] initramfs-framework: remove hard dependency with busybox
  2025-03-29 16:01     ` Christos Gavros
@ 2025-03-29 16:29       ` Khem Raj
  2025-04-10 21:27         ` Adrian Freihofer
  0 siblings, 1 reply; 6+ messages in thread
From: Khem Raj @ 2025-03-29 16:29 UTC (permalink / raw)
  To: gavrosc; +Cc: openembedded-core

On Sat, Mar 29, 2025 at 9:01 AM Christos Gavros via
lists.openembedded.org <gavrosc=yahoo.com@lists.openembedded.org>
wrote:
>
> hi Adrian
>
> thank you for the comment. I had a look in commits log and it looks that '-c' was there since the beginning in 2008/09/10 in script 'init-live.sh' and then moved in 'finish.sh' in 2011/12/08.
> I reproduced the issue by using qemu and I described how I did it in detail in bug #15716.
> After I applied the change I tested both busybox and packagegroup-core-base-utils. The boot was successful in both cases.
> Also '-c' is an option in busybox: https://www.busybox.net/downloads/BusyBox.html
>

-c option is to redirect the console after switching root. Some
devices it did not work properly because util-linux version moved the
pseudo filesystems like /dev automatically
but busybox version did not, maybe things have changed but I would
suggest that this operation is now happening with both switch_root
versions with you script manually doing so.

> I will wait for more comments and then I will extend the commit message and send a v2.
>
> Br
> Christos
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#213885): https://lists.openembedded.org/g/openembedded-core/message/213885
> Mute This Topic: https://lists.openembedded.org/mt/111959232/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>


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

* Re: [OE-core] [PATCH] initramfs-framework: remove hard dependency with busybox
  2025-03-29 16:29       ` [OE-core] " Khem Raj
@ 2025-04-10 21:27         ` Adrian Freihofer
  2025-04-11  9:40           ` Richard Purdie
  0 siblings, 1 reply; 6+ messages in thread
From: Adrian Freihofer @ 2025-04-10 21:27 UTC (permalink / raw)
  To: gavrosc, richard.purdie; +Cc: openembedded-core

On Sat, 2025-03-29 at 09:29 -0700, Khem Raj via lists.openembedded.org
wrote:
> On Sat, Mar 29, 2025 at 9:01 AM Christos Gavros via
> lists.openembedded.org <gavrosc=yahoo.com@lists.openembedded.org>
> wrote:
> > 
> > hi Adrian
> > 
> > thank you for the comment. I had a look in commits log and it looks
> > that '-c' was there since the beginning in 2008/09/10 in script
> > 'init-live.sh' and then moved in 'finish.sh' in 2011/12/08.
> > I reproduced the issue by using qemu and I described how I did it
> > in detail in bug #15716.
> > After I applied the change I tested both busybox and packagegroup-
> > core-base-utils. The boot was successful in both cases.
> > Also '-c' is an option in busybox:
> > https://www.busybox.net/downloads/BusyBox.html
> > 
> 
> -c option is to redirect the console after switching root. Some
> devices it did not work properly because util-linux version moved the
> pseudo filesystems like /dev automatically
> but busybox version did not, maybe things have changed but I would
> suggest that this operation is now happening with both switch_root
> versions with you script manually doing so.

I tested this on a device with kernel 6.1+. It seams to work as
expected also with a busybox based initramfs. Maybe you are right and
this is more like a legacy thing which can (or even should?) be
removed.

Additionally I looked into the code from busybox. The related lines
are:

	if (console) {
		close(0);
		xopen(console, O_RDWR);
		xdup2(0, 1);
		xdup2(0, 2);
	}
https://github.com/brgl/busybox/blob/master/util-linux/switch_root.c#L143

At least on my device this would just close /dev/console and open it
again. Not really useful.

I think the patch is beneficial for probably all kind of systems.
Adrian


> 
> > I will wait for more comments and then I will extend the commit
> > message and send a v2.
> > 
> > Br
> > Christos
> > 
> > 
> > 
> > 
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#213886):
> https://lists.openembedded.org/g/openembedded-core/message/213886
> Mute This Topic: https://lists.openembedded.org/mt/111959232/4454582
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe:
> https://lists.openembedded.org/g/openembedded-core/unsub [
> adrian.freihofer@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
> 



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

* Re: [OE-core] [PATCH] initramfs-framework: remove hard dependency with busybox
  2025-04-10 21:27         ` Adrian Freihofer
@ 2025-04-11  9:40           ` Richard Purdie
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Purdie @ 2025-04-11  9:40 UTC (permalink / raw)
  To: Adrian Freihofer, gavrosc; +Cc: openembedded-core

On Thu, 2025-04-10 at 23:27 +0200, Adrian Freihofer wrote:
> On Sat, 2025-03-29 at 09:29 -0700, Khem Raj via lists.openembedded.org
> wrote:
> > On Sat, Mar 29, 2025 at 9:01 AM Christos Gavros via
> > lists.openembedded.org <gavrosc=yahoo.com@lists.openembedded.org>
> > wrote:
> > > 
> > > hi Adrian
> > > 
> > > thank you for the comment. I had a look in commits log and it looks
> > > that '-c' was there since the beginning in 2008/09/10 in script
> > > 'init-live.sh' and then moved in 'finish.sh' in 2011/12/08.
> > > I reproduced the issue by using qemu and I described how I did it
> > > in detail in bug #15716.
> > > After I applied the change I tested both busybox and packagegroup-
> > > core-base-utils. The boot was successful in both cases.
> > > Also '-c' is an option in busybox:
> > > https://www.busybox.net/downloads/BusyBox.html
> > > 
> > 
> > -c option is to redirect the console after switching root. Some
> > devices it did not work properly because util-linux version moved the
> > pseudo filesystems like /dev automatically
> > but busybox version did not, maybe things have changed but I would
> > suggest that this operation is now happening with both switch_root
> > versions with you script manually doing so.
> 
> I tested this on a device with kernel 6.1+. It seams to work as
> expected also with a busybox based initramfs. Maybe you are right and
> this is more like a legacy thing which can (or even should?) be
> removed.
> 
> Additionally I looked into the code from busybox. The related lines
> are:
> 
> 	if (console) {
> 		close(0);
> 		xopen(console, O_RDWR);
> 		xdup2(0, 1);
> 		xdup2(0, 2);
> 	}
> https://github.com/brgl/busybox/blob/master/util-linux/switch_root.c#L143
> 
> At least on my device this would just close /dev/console and open it
> again. Not really useful.
> 
> I think the patch is beneficial for probably all kind of systems.

Thanks, this analysis really helps.

I agree that this does appear to make sense. I guess it is in case the
initramfs and the main system have different /dev/console entries but
that is probably/hopefully very rare. It would only be the init process
affected.

Cheers,

Richard


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

end of thread, other threads:[~2025-04-11  9:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20250328180456.90413-1-gavrosc.ref@yahoo.com>
2025-03-28 18:04 ` [PATCH] initramfs-framework: remove hard dependency with busybox Christos Gavros
2025-03-29 13:45   ` [OE-core] " Adrian Freihofer
2025-03-29 16:01     ` Christos Gavros
2025-03-29 16:29       ` [OE-core] " Khem Raj
2025-04-10 21:27         ` Adrian Freihofer
2025-04-11  9:40           ` Richard Purdie

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