libbb: make xchroot do a chdir("/") after chroot

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
diff --git a/coreutils/chroot.c b/coreutils/chroot.c
index ab8beb0..633e66b 100644
--- a/coreutils/chroot.c
+++ b/coreutils/chroot.c
@@ -31,7 +31,6 @@
 	if (!*argv)
 		bb_show_usage();
 	xchroot(*argv);
-	xchdir("/");
 
 	++argv;
 	if (!*argv) { /* no 2nd param (PROG), use shell */
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c
index 56ee459..d8a42ba 100644
--- a/libbb/xfuncs_printf.c
+++ b/libbb/xfuncs_printf.c
@@ -362,6 +362,7 @@
 {
 	if (chroot(path))
 		bb_perror_msg_and_die("can't change root directory to %s", path);
+	xchdir("/");
 }
 
 // Print a warning message if opendir() fails, but don't die.
diff --git a/networking/ftpd.c b/networking/ftpd.c
index e38138c..1c97df5 100644
--- a/networking/ftpd.c
+++ b/networking/ftpd.c
@@ -1179,8 +1179,7 @@
 #endif
 
 	if (argv[optind]) {
-		xchdir(argv[optind]);
-		chroot(".");
+		xchroot(argv[optind]);
 	}
 
 	//umask(077); - admin can set umask before starting us
diff --git a/procps/sysctl.c b/procps/sysctl.c
index cb3b6a2..5296d0f 100644
--- a/procps/sysctl.c
+++ b/procps/sysctl.c
@@ -224,7 +224,7 @@
 	parser = config_open(filename);
 	/* Must do it _after_ config_open(): */
 	xchdir("/proc/sys");
-	/* xchroot(".") - if you are paranoid */
+	/* xchroot("/proc/sys") - if you are paranoid */
 
 //TODO: ';' is comment char too
 //TODO: comment may be only at line start. "var=1 #abc" - "1 #abc" is the value
@@ -260,7 +260,7 @@
 		return sysctl_handle_preload_file(*argv ? *argv : "/etc/sysctl.conf");
 	}
 	xchdir("/proc/sys");
-	/* xchroot(".") - if you are paranoid */
+	/* xchroot("/proc/sys") - if you are paranoid */
 	if (opt & (FLAG_TABLE_FORMAT | FLAG_SHOW_ALL)) {
 		return sysctl_act_recursive(".");
 	}
diff --git a/runit/chpst.c b/runit/chpst.c
index 9b8c99b..ac296ba 100644
--- a/runit/chpst.c
+++ b/runit/chpst.c
@@ -417,8 +417,7 @@
 	}
 
 	if (opt & OPT_root) {
-		xchdir(root);
-		xchroot(".");
+		xchroot(root);
 	}
 
 	if (opt & OPT_u) {
diff --git a/util-linux/switch_root.c b/util-linux/switch_root.c
index db6ae35..a301b36 100644
--- a/util-linux/switch_root.c
+++ b/util-linux/switch_root.c
@@ -114,7 +114,7 @@
 	}
 	xchroot(".");
 	// The chdir is needed to recalculate "." and ".." links
-	xchdir("/");
+	/*xchdir("/"); - done in xchroot */
 
 	// If a new console specified, redirect stdin/stdout/stderr to it
 	if (console) {