Why '-c DEV' option for switch_root?

ChenQi Qi.Chen at windriver.com
Fri Dec 6 02:25:26 UTC 2013


On 12/05/2013 06:10 PM, Harald Becker wrote:
> Hi !
>
> On 05-12-2013 14:59 ChenQi <Qi.Chen at windriver.com> wrote:
>> I noticed that switch_root in our busybox supports an extra
>> option '-c DEV' which is not supported by the same command from
>> util-linux. According to the source file, it's used to 'reopen
>> stdio to DEV after switch'.
>>
>> Does anyone know why we need this option? Is there any use case
>> where this option is useful or maybe necessary?
> You probably need to reopen stdio after switching your root. As
> long as you keep devices open, there are open file descriptors in
> the kernel and the device i-nodes on the old file system can't
> be deleted. Some programs do there own handling of devices and
> reopen stdio in the new root, other may miss this reopen step
> and you have to care of it for your own. In this case the -c
> option simplify the switch usage, as it bundles the reopen in
> same step as switching the root file system.
>
> --
> Harald
>
>

Hi Harald,

Thanks for your explanation.

I don't know if I understand it right.
Does it mean that as long as we don't do some strange redirections of 
standard IO in our initramfs, we don't need to add this option when 
switching root? So in most cases we don't need to reopen the stdio, right?

Best Regards,
Chen Qi



More information about the busybox mailing list