98a6f1fc02
When booting with 'console=<empty>' in the kernel command line (as e.g. U-Boot does with silent flags in effect), opening /dev/console fails. As per POSIX [0], when iany redirection fails, the shell running exec shal exit in error. So, when 'console=<empty>' is specified. /dev/console can't be opened, and the redirection fails, and /init is killed. That behaviour was fixed on the kernel side with commit 2bd3a997befc2 (Open /dev/console from rootfs), present since 2.6.34, released in May 2010, so any [dr]ecent kernel will have that fix. Furthermore, busybox will fix things up anyway (in bb_sanitize_stdio()), falling back to opening /dev/null if no console is availble. systemd does a similar thing (in make_console_stdio()), and sysvinit again has a similar approach (in console_init()). The archealogy search turned up those relevant commits: 2011-08-0410a130f91e
initramfs/init: make sure that 0, 1, 2 fds are available introduces the three exec redirections in initramfs 2011-09-063fac21ef8d
cpio: fix boot with dynamic /dev introduces the three exec redirections in cpio 2011-09-0613a3afc536
fs/initramfs: refactor with fs/cpio dropped the initramfs tweaks to reuse the cpio ones 2012-11-04e1ebae700a
fs/common: Create initial console device introduces the /dev/console char,5,1 pseudo device creation in cpio 2018-03-31dec061adce
fs/cpio: don't extend packages' permissions table switched from the permission-table to a manual mknod to create /dev/console The redirections were added before we could guarantee there was a /dev/console in the rootfs. We're now guaranteed to have /dev/console in an initramfs, and any recent kernel will automatically open /dev/console before spawning /init. The three redirections are useless now, and cause harm under certain conditions. Drop them. [0] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_20_01 Signed-off-by: Timo Ketola <timo.ketola@exertus.fi> Cc: Peter Korsgaard <peter@korsgaard.com> [yann.morin.1998@free.fr: - extend commit log with the analysis done with Peter ] Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
5 lines
118 B
Bash
Executable File
5 lines
118 B
Bash
Executable File
#!/bin/sh
|
|
# devtmpfs does not get automounted for initramfs
|
|
/bin/mount -t devtmpfs devtmpfs /dev
|
|
exec /sbin/init "$@"
|