[git commit] run-init: if doing dry run, do not require pid==1

Denys Vlasenko vda.linux at googlemail.com
Tue Aug 22 09:40:27 UTC 2017


commit: https://git.busybox.net/busybox/commit/?id=7d834c9bb436edd594ebacc48d2b9ea7d3364dbd
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 util-linux/switch_root.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/util-linux/switch_root.c b/util-linux/switch_root.c
index 16abcb6..080b05e 100644
--- a/util-linux/switch_root.c
+++ b/util-linux/switch_root.c
@@ -227,9 +227,12 @@ int switch_root_main(int argc UNUSED_PARAM, char **argv)
 	xstat("/", &st);
 	rootdev = st.st_dev;
 	xstat(".", &st);
-	if (st.st_dev == rootdev || getpid() != 1) {
+	if (st.st_dev == rootdev) {
 		// Show usage, it says new root must be a mountpoint
-		// and we must be PID 1
+		bb_show_usage();
+	}
+	if (!dry_run && getpid() != 1) {
+		// Show usage, it says we must be PID 1
 		bb_show_usage();
 	}
 


More information about the busybox-cvs mailing list