diff options
-rw-r--r-- | src/linux-user-chroot.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/linux-user-chroot.c b/src/linux-user-chroot.c index 82070b2..fa8a2be 100644 --- a/src/linux-user-chroot.c +++ b/src/linux-user-chroot.c @@ -351,11 +351,15 @@ main (int argc, if (mount (chroot_dir, chroot_dir, NULL, MS_BIND | MS_PRIVATE, NULL) < 0) fatal_errno ("mount (MS_BIND)"); - if (mount (chroot_dir, "/", NULL, MS_MOVE, NULL) < 0) - fatal_errno ("mount (MS_MOVE)"); + /* Only move if we're not actually just using / */ + if (strcmp (chroot_dir, "/") != 0) + { + if (mount (chroot_dir, "/", NULL, MS_MOVE, NULL) < 0) + fatal_errno ("mount (MS_MOVE)"); - if (chroot (".") < 0) - fatal_errno ("chroot"); + if (chroot (".") < 0) + fatal_errno ("chroot"); + } if (chdir (chdir_target) < 0) fatal_errno ("chdir"); |