switch-root: when pivot_root() fails, but old root shall be mounted, do so
authorLennart Poettering <lennart@poettering.net>
Fri, 11 Aug 2023 10:10:18 +0000 (12:10 +0200)
committerMike Yuan <me@yhndnzj.com>
Sat, 2 Sep 2023 11:47:58 +0000 (19:47 +0800)
commit95648f9ed0d972c3ad86205a462bb5805498ee58
tree7766477b2c96af6dc28a74cc9ddab0b9f513bf6b
parentc2d62118f76a0454b4fb19c5432bd3d4fe4524b5
switch-root: when pivot_root() fails, but old root shall be mounted, do so

If pivot_root() fails, we'll fall back to switching root via MS_MOVE.
Unlike pivot_root() that won't place the old root fs anyway, but just
hide it. That's problematic during shutdown for example, since after all
we might still want to access it from the exitrd, to disassemble it
properly.

Hence let's make things somewhat systematic: regardless if pivot_root()
or MS_MOVE is used, always make the old root fs show up in the selected
new dir.
src/shared/switch-root.c