From: Askar Safin <safinaskar@gmail.com>
To: linux-fsdevel@vger.kernel.org,
Christian Brauner <brauner@kernel.org>,
Alexander Viro <viro@zeniv.linux.org.uk>, Jan Kara <jack@suse.cz>
Cc: Randy Dunlap <rdunlap@infradead.org>,
linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org,
initramfs@vger.kernel.org, Rob Landley <rob@landley.net>,
David Disseldorp <ddiss@suse.de>,
Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nsc@kernel.org>,
patches@lists.linux.dev
Subject: [PATCH 2/2] init: ensure that /dev/null is (nearly) always available in initramfs
Date: Thu, 19 Feb 2026 21:03:12 +0000 [thread overview]
Message-ID: <20260219210312.3468980-3-safinaskar@gmail.com> (raw)
In-Reply-To: <20260219210312.3468980-1-safinaskar@gmail.com>
Binaries linked with bionic libc require /dev/null to be present,
otherwise they will crash before entering "main", as explained
in https://landley.net/toybox/faq.html#cross3 .
So we should put /dev/null to initramfs, but this is impossible
if we create initramfs using "cpio" and we are running as normal
user.
This problem can be solved by using gen_init_cpio.
But let's make sure instead that /dev/null is always available as
a quality-of-implementation feature. This will reduce number
of failure modes and will make it easier for developers to
get early boot right. (Early boot issues are very hard to debug.)
Signed-off-by: Askar Safin <safinaskar@gmail.com>
---
init/do_mounts.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/init/do_mounts.c b/init/do_mounts.c
index f911280a348e..3e71049b3dcf 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -525,5 +525,8 @@ void __init create_basic_rootfs(void)
WARN_ON_ONCE(init_mkdir("/dev", 0755) != 0);
WARN_ON_ONCE(init_mknod("/dev/console", S_IFCHR | 0600,
new_encode_dev(MKDEV(5, 1))) != 0);
+ WARN_ON_ONCE(init_mknod("/dev/null", S_IFCHR,
+ new_encode_dev(MKDEV(1, 3))) != 0);
+ WARN_ON_ONCE(init_chmod("/dev/null", 0666) != 0);
WARN_ON_ONCE(init_mkdir("/root", 0700) != 0);
}
--
2.47.3
next prev parent reply other threads:[~2026-02-19 21:04 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-19 21:03 [PATCH 0/2] init: ensure that /dev/console and /dev/null are (nearly) always available in initramfs Askar Safin
2026-02-19 21:03 ` [PATCH 1/2] init: ensure that /dev/console is " Askar Safin
2026-02-19 23:59 ` David Disseldorp
2026-02-20 19:11 ` Askar Safin
2026-02-23 1:19 ` David Disseldorp
2026-02-23 21:41 ` Askar Safin
2026-02-23 1:27 ` Rob Landley
2026-02-23 2:33 ` David Disseldorp
2026-02-23 16:11 ` Rob Landley
2026-02-23 17:34 ` Askar Safin
2026-02-23 19:45 ` Rob Landley
2026-02-23 23:04 ` Askar Safin
2026-02-19 21:03 ` Askar Safin [this message]
2026-02-20 0:26 ` [PATCH 2/2] init: ensure that /dev/null " David Disseldorp
2026-02-21 0:16 ` Askar Safin
2026-02-23 1:15 ` Rob Landley
2026-02-23 21:18 ` Askar Safin
2026-02-23 0:17 ` [PATCH 0/2] init: ensure that /dev/console and /dev/null are " Rob Landley
2026-02-23 20:58 ` Askar Safin
2026-02-24 19:02 ` Rob Landley
2026-03-07 3:22 ` Askar Safin
2026-03-10 12:51 ` Rob Landley
2026-03-23 3:47 ` Askar Safin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260219210312.3468980-3-safinaskar@gmail.com \
--to=safinaskar@gmail.com \
--cc=brauner@kernel.org \
--cc=ddiss@suse.de \
--cc=initramfs@vger.kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nathan@kernel.org \
--cc=nsc@kernel.org \
--cc=patches@lists.linux.dev \
--cc=rdunlap@infradead.org \
--cc=rob@landley.net \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox