nixos-riscv/busybox-debug.patch
Rodrigo Arias Mallo 93e83f52e8 Add busybox patch to see debug lines: initrd sh ok
The switch_root command seems to hang in the execv() syscall.
2024-07-03 13:43:41 +02:00

69 lines
2.3 KiB
Diff

Only in busybox-1.36.1-mod: tags
diff -up -r busybox-1.36.1/util-linux/switch_root.c busybox-1.36.1-mod/util-linux/switch_root.c
--- busybox-1.36.1/util-linux/switch_root.c 2021-09-30 00:04:47.000000000 +0200
+++ busybox-1.36.1-mod/util-linux/switch_root.c 2024-07-01 16:08:28.336541504 +0200
@@ -181,6 +181,8 @@ int switch_root_main(int argc UNUSED_PAR
unsigned dry_run = 0;
dev_t rootdev;
+ printf("HELLO THIS IS SWITCH ROOT STARTING\n");
+
// Parse args. '+': stop at first non-option
if (ENABLE_SWITCH_ROOT && (!ENABLE_RUN_INIT || applet_name[0] == 's')) {
//usage:#define switch_root_trivial_usage
@@ -241,12 +243,15 @@ int switch_root_main(int argc UNUSED_PAR
if (stat("/init", &st) != 0 || !S_ISREG(st.st_mode)) {
bb_error_msg_and_die("'%s' is not a regular file", "/init");
}
+ printf("SWITCH ROOT LINE %d OK\n", __LINE__);
statfs("/", &stfs); // this never fails
+ printf("SWITCH ROOT LINE %d OK\n", __LINE__);
if ((unsigned)stfs.f_type != RAMFS_MAGIC
&& (unsigned)stfs.f_type != TMPFS_MAGIC
) {
bb_simple_error_msg_and_die("root filesystem is not ramfs/tmpfs");
}
+ printf("SWITCH ROOT LINE %d OK\n", __LINE__);
if (!dry_run) {
// Zap everything out of rootdev
@@ -258,19 +263,26 @@ int switch_root_main(int argc UNUSED_PAR
bb_simple_perror_msg_and_die("error moving root");
}
}
+ printf("SWITCH ROOT LINE %d OK\n", __LINE__);
+ printf("XCHROOT\n");
xchroot(".");
+ printf("SWITCH ROOT LINE %d OK\n", __LINE__);
// The chdir is needed to recalculate "." and ".." links
/*xchdir("/"); - done in xchroot */
// If a new console specified, redirect stdin/stdout/stderr to it
if (console) {
+ printf("REDIRECTING CONSOLE\n");
+ printf("SWITCH ROOT LINE %d OK\n", __LINE__);
int fd = open_or_warn(console, O_RDWR);
if (fd >= 0) {
xmove_fd(fd, 0);
xdup2(0, 1);
xdup2(0, 2);
}
+ printf("SWITCH ROOT LINE %d OK\n", __LINE__);
}
+ printf("SWITCH ROOT LINE %d OK\n", __LINE__);
if (dry_run) {
// Does NEW_INIT look like it can be executed?
@@ -280,8 +292,11 @@ int switch_root_main(int argc UNUSED_PAR
if (access(argv[0], X_OK) == 0)
return 0;
} else {
+ printf("SWITCH ROOT LINE %d OK\n", __LINE__);
+ printf("LAUNCHING EXECV\n");
// Exec NEW_INIT
execv(argv[0], argv);
+ printf("RETURNED FROM EXECV???\n");
}
bb_perror_msg_and_die("can't execute '%s'", argv[0]);
}