diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-05-19 20:32:44 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-05-20 14:38:12 +0200 |
commit | 6458ec20b574edf7170fda61c51ccd3c6e73937f (patch) | |
tree | 0baed30f599b2e01b9e929ad483a23572c2e7187 /src/nspawn/nspawn.c | |
parent | eba6fd30f2a27f51fa328484cb241807c6934ce1 (diff) |
core,nspawn: unify code that moves the root dir
Diffstat (limited to 'src/nspawn/nspawn.c')
-rw-r--r-- | src/nspawn/nspawn.c | 20 |
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); } |