summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarald Hoyer <harald@redhat.com>2012-05-16 14:22:43 +0200
committerLennart Poettering <lennart@poettering.net>2012-05-21 18:50:29 +0200
commite148ac5a6cccd1c9c23bf7b3085b50fdb1cd1cf9 (patch)
tree2b3985948e026230b6a9d2a853b88fb393067e69
parentd03bc1b814b853497120c35a9a8d6a66925963ff (diff)
core/main.c: do_switch_root(): do not remove the old root if not in initrd
Only recursively remove the old root, if we have been in an initrd/initramfs.
-rw-r--r--src/core/main.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/core/main.c b/src/core/main.c
index 747121461d..d7143edae2 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1180,6 +1180,7 @@ static int do_switch_root(const char *switch_root) {
int i;
int cfd = -1;
struct stat switch_root_stat, sb;
+ bool remove_old_root;
if (path_equal(switch_root, "/"))
return 0;
@@ -1190,6 +1191,8 @@ static int do_switch_root(const char *switch_root) {
goto fail;
}
+ remove_old_root = in_initrd();
+
for (i = 0; umounts[i] != NULL; i++) {
char newmount[PATH_MAX];
@@ -1215,7 +1218,8 @@ static int do_switch_root(const char *switch_root) {
goto fail;
}
- cfd = open("/", O_RDONLY);
+ if (remove_old_root)
+ cfd = open("/", O_RDONLY);
if (mount(switch_root, "/", NULL, MS_MOVE, NULL) < 0) {
r = -errno;