]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/shared/switch-root.c
shared: rework switch_root() code
authorLennart Poettering <lennart@poettering.net>
Mon, 12 Dec 2016 20:03:34 +0000 (21:03 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 21 Dec 2016 18:09:29 +0000 (19:09 +0100)
commite5b422034160937712fe7a546f175b883e39e763
tree0b46eb9d8d8cdf0b51c74d698498b20d3153341d
parentf78273c8dacf678cc8fd7387f678e6344a99405c
shared: rework switch_root() code

Let's follow symlinks before invoking mount() on arbitrary paths, so that we
won't get confused if directories are prepared with absolute symlinks.

Use FOREACH_STRING() instead of NULSTR_FOREACH() as it is more readable.

Don't use snprintf() for concatenating strings, let chase_symlinks() to that.

Replace homegrown mount check with path_is_mount_point(). Also, change the
behaviour when we encounter this: instead of unmounting the old mount point,
simply leave it around and don't replace it, so that initrds can mount stuff
there with different settings than we would apply. This is in-line with how we
handle automatic mounts in nspawn for example.

Use umount_recursive() instead of a simple umount2() for unmounting the old
root, so that we actually cover really all mounts, not just the top-level one.
src/shared/switch-root.c