summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2013-01-10 14:25:37 -0500
committerColin Walters <walters@verbum.org>2013-01-10 14:25:37 -0500
commit61eea63b4042d1c6fba12d79215f5b9247d3b5c5 (patch)
treeed1647d74eedf3ceb98c83eb04f9b607874e3cfb
parent21a2e2b39af9f681d7ebeac72a6fcf0487a2b359 (diff)
downloadlinux-user-chroot-61eea63b4042d1c6fba12d79215f5b9247d3b5c5.tar.gz
Only MS_MOVE the root to / if the root isn't already /
Otherwise the MS_MOVE call aborts.
-rw-r--r--src/linux-user-chroot.c12
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");