summaryrefslogtreecommitdiff
path: root/src/nspawn/nspawn.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-05-19 20:32:44 +0200
committerLennart Poettering <lennart@poettering.net>2015-05-20 14:38:12 +0200
commit6458ec20b574edf7170fda61c51ccd3c6e73937f (patch)
tree0baed30f599b2e01b9e929ad483a23572c2e7187 /src/nspawn/nspawn.c
parenteba6fd30f2a27f51fa328484cb241807c6934ce1 (diff)
core,nspawn: unify code that moves the root dir
Diffstat (limited to 'src/nspawn/nspawn.c')
-rw-r--r--src/nspawn/nspawn.c20
1 files changed, 3 insertions, 17 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index a38f47dd0a..1f919c082b 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -4391,23 +4391,9 @@ int main(int argc, char *argv[]) {
if (mount_cgroup(arg_directory) < 0)
_exit(EXIT_FAILURE);
- if (chdir(arg_directory) < 0) {
- log_error_errno(errno, "chdir(%s) failed: %m", arg_directory);
- _exit(EXIT_FAILURE);
- }
-
- if (mount(arg_directory, "/", NULL, MS_MOVE, NULL) < 0) {
- log_error_errno(errno, "mount(MS_MOVE) failed: %m");
- _exit(EXIT_FAILURE);
- }
-
- if (chroot(".") < 0) {
- log_error_errno(errno, "chroot() failed: %m");
- _exit(EXIT_FAILURE);
- }
-
- if (chdir("/") < 0) {
- log_error_errno(errno, "chdir() failed: %m");
+ r = mount_move_root(arg_directory);
+ if (r < 0) {
+ log_error_errno(r, "Failed to move root directory: %m");
_exit(EXIT_FAILURE);
}