]> rtime.felk.cvut.cz Git - coffee/buildroot.git/commitdiff
initramfs/init: make sure that 0, 1, 2 fds are available
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Thu, 4 Aug 2011 19:38:59 +0000 (21:38 +0200)
committerPeter Korsgaard <jacmet@sunsite.dk>
Thu, 4 Aug 2011 19:52:21 +0000 (21:52 +0200)
As the kernel doesn't automatically mount devtmpfs when an initramfs
is used, commit 424888e47431db738f5f9b3c6392435bfce7a842 has
introduced a small wrapper script that mounts devtmpfs before starting
the real init.

Unfortunately, the problem is that in this case, the init process runs
without any 0, 1 and 2 file descriptors, so none of the
messages/errors printed by the various initialization scripts can be
seen. This is due to the fact the init process relies on 0, 1 and 2
being opened by the kernel before init is started. However, as
/dev/console isn't present on the filesystem at the time the kernel
tries to open the console to create the 0, 1 and 2 file descriptors,
the kernel fails on this and prints the famous "Warning: unable to
open an initial console".

The proposed workaround is to actually open 0, 1 and 2 to /dev/console
in the wrapper script, right after mounting the devtmpfs filesystem,
and before starting the real init. The "Warning" from the kernel is
still shown, but at least the messages from the init scripts are
visible.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
fs/initramfs/init

index 751cb270f1bc39c1619eab115815b1a73d45e6a1..a2754821776997c5f8eb9873eb2ede68c091327e 100755 (executable)
@@ -1,4 +1,7 @@
 #!/bin/sh
 # devtmpfs does not get automounted for initramfs
 /bin/mount -t devtmpfs devtmpfs /dev
+exec 0</dev/console
+exec 1>/dev/console
+exec 2>/dev/console
 exec /sbin/init $*