Fix switch_root implementation.
authorAlistair Strachan <alistair.strachan@imgtec.com>
Wed, 6 May 2015 22:20:19 +0000 (15:20 -0700)
committerRob Landley <rob@landley.net>
Sat, 8 Aug 2015 21:57:30 +0000 (16:57 -0500)
commit430bf378418e655b06d518a7cd62ae680301af80
treead5a0364976f57f7210d59f73f0f5b8eb9084b25
parent5fb2766a9b51ee326a14ec9909066b20a2bfa9ac
Fix switch_root implementation.

Add the MS_MOVE of cwd to / and chroot into it. chdir is also
called to ensure cwd does not point outside the chroot.

The switch_root toy was also blocking any case where NEW_ROOT/init
did not exist, even though NEW_INIT was a required parameter and
did not have to be '/init'. Change it to handle any NEW_INIT
passed as either a relative or absolute path.

With this change, the switch_root toy actually works from initramfs.
toys/other/switch_root.c