Only recursively remove the old root, if we have been in an
initrd/initramfs.
int i;
int cfd = -1;
struct stat switch_root_stat, sb;
int i;
int cfd = -1;
struct stat switch_root_stat, sb;
if (path_equal(switch_root, "/"))
return 0;
if (path_equal(switch_root, "/"))
return 0;
+ remove_old_root = in_initrd();
+
for (i = 0; umounts[i] != NULL; i++) {
char newmount[PATH_MAX];
for (i = 0; umounts[i] != NULL; i++) {
char newmount[PATH_MAX];
- cfd = open("/", O_RDONLY);
+ if (remove_old_root)
+ cfd = open("/", O_RDONLY);
if (mount(switch_root, "/", NULL, MS_MOVE, NULL) < 0) {
r = -errno;
if (mount(switch_root, "/", NULL, MS_MOVE, NULL) < 0) {
r = -errno;