From 6458ec20b574edf7170fda61c51ccd3c6e73937f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 19 May 2015 20:32:44 +0200 Subject: core,nspawn: unify code that moves the root dir --- src/nspawn/nspawn.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'src/nspawn/nspawn.c') 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); } -- cgit v1.2.3-54-g00ecf