Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2594839pxb; Mon, 17 Jan 2022 01:41:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJy5UiPiqbK5NoStpOrUgcFdARTvXedX5EDh2bYiOaoF0YlOIUL+P4OgGLxD95TYbdC/46r9 X-Received: by 2002:a05:6a00:1c76:b0:4bb:ffdc:6434 with SMTP id s54-20020a056a001c7600b004bbffdc6434mr20338396pfw.70.1642412478842; Mon, 17 Jan 2022 01:41:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642412478; cv=none; d=google.com; s=arc-20160816; b=M1uYfvvFqrNKCadNq+igtwTc22nM4D2LIhlcrre29jqjb0f94iN3E1ux/jvq17+pqk mDNETx9Uj6zPAGyXl1Hhyx5A5Dr7XWtBqgCQjR+qvQi75CvyH+YGj+L0xzW9tPDubPnk sQpdlySS2dkI/on1uXabq2q5gX+JATbuDrzDju2fYBowfSw5lMzniDpezTOElXAo1gmC BgmXGWtXgMxUwjqvqQwfJzZxA2SelJPaHGPrIsK+6frJXC9GXQVSGp5OKc0oFgk/qK5l sK1+8l6YYpVie9QUg4pFUzknorZphPmlzE8wwb8UsUM5XvPXBEUPAyy9Svh6DhL/ABrv 7H1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:user-agent:date:message-id:subject:from:to :dkim-signature; bh=8tWFetS/0R91mAOw4wQiTZSwlHSR50XGbCjUlKQuD+A=; b=B9X2jBGnFtHNnjA5tVnkJFdYHua59UXIhyhKCVxb2VyiUjq+2eOw6hAFmR8RcqbziC B0ZyEfL5DGzvqCDliFiudqiq92N1zqWrsJG8w7+PUO5n8S9djRHfGw7NnD/d6xsJDOka SzhlhWIj9JbmscBqHRF2suHw9BT+bQ16vw1ddd8ZK95rgXBQ9jje8h4ekg60g9Cy2ayX kSO9xLLVn0TE7yh1lTZizz7Hb7ShXHRiMzBWbUmFg4YYIgbeAsnPQmZc2pkyimNUzAA4 y08XQ+KxRkuLPbicDWCGZS6CjaRUo2QlPKehFQuVR7Kn9Ugm+idryMKf3C/QwpQLk8Ew yACg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@landley-net.20210112.gappssmtp.com header.s=20210112 header.b=u8KBF5jO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i18si7960809pgn.106.2022.01.17.01.41.06; Mon, 17 Jan 2022 01:41:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@landley-net.20210112.gappssmtp.com header.s=20210112 header.b=u8KBF5jO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232456AbiAPSey (ORCPT + 99 others); Sun, 16 Jan 2022 13:34:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235906AbiAPSex (ORCPT ); Sun, 16 Jan 2022 13:34:53 -0500 Received: from mail-ot1-x32d.google.com (mail-ot1-x32d.google.com [IPv6:2607:f8b0:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DFA1C06161C for ; Sun, 16 Jan 2022 10:34:53 -0800 (PST) Received: by mail-ot1-x32d.google.com with SMTP id z25-20020a0568301db900b005946f536d85so8110467oti.9 for ; Sun, 16 Jan 2022 10:34:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=landley-net.20210112.gappssmtp.com; s=20210112; h=to:from:subject:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=8tWFetS/0R91mAOw4wQiTZSwlHSR50XGbCjUlKQuD+A=; b=u8KBF5jOEy3icvGHKQWWiLkKz/Omz5FsxL3Tj2/2r/KZawCZE7/h1xBEvdLLeaLD33 Ou3IYHX5Qs1oX+UPaTT8NQS1IHKhGNG76vMYsFyprbEHyEI9f+NM7EjbISDYGiwCi3jU Bcolm/cBefYRlXyvHzoBml89qqkAs7K0jQQclrYwh0VTiZYbJrbAckn4UcgI8GVQKSMG cOV+174xzmM8qwARphD7bcdJrGYPFh/O/lCkHlEZ+vdWsyTmqaC5+k5CBHH7YsTjo3/X 4hwNpWXIgzy/E8wmglzZXJDMmNmMtr4vG7XGt3++tf/nprdV2Ro/loDBXH1sUxOvONUF 3tdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=8tWFetS/0R91mAOw4wQiTZSwlHSR50XGbCjUlKQuD+A=; b=mw6Hkh0AHk4OmxbaOSiBkMWubR2C6kduw/oBN+96++EyZGjqEHZq0bVFiaAkzWgS9F NiPAs2zHbNGCdEkNdgFeCge2YAVmNWvSGhkugQ5tKs1LzFZFgkVqFXRcFvHGHYWemDCI zBFFExnouZkDBASxa53fn/kVpb7aTIuKub2OC14z/qH0lZfJa5idgUs/E6Y88PzKVZdC K8gPXfNdV83YUHqwdAlDG9JQugfEt1RV3UVnr3XN1jaFZ8mQ6IZlp/uuRXDxIfM7Y139 8hDG3KxTIqlyaP5UpV+crd6cynJCcMscWWATD9JYEeMpzLnQLqD8k78Sjns2kCPDIeWq EibQ== X-Gm-Message-State: AOAM533nsvD0mhQDWwT41AGIW9EJVttEfDNCVVD/jETyFMY2ldc/hQNx 0vohzZ+a8XTQ79gq6aXjL9UOM2RFdTLNCQ== X-Received: by 2002:a9d:294a:: with SMTP id d68mr13692860otb.301.1642358092223; Sun, 16 Jan 2022 10:34:52 -0800 (PST) Received: from [192.168.86.178] ([136.62.4.88]) by smtp.gmail.com with ESMTPSA id 184sm5399896oih.58.2022.01.16.10.34.51 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 16 Jan 2022 10:34:51 -0800 (PST) To: "linux-kernel@vger.kernel.org" From: Rob Landley Subject: [PATCH] Wire up CONFIG_DEVTMPFS_MOUNT to initramfs. Message-ID: Date: Sun, 16 Jan 2022 12:36:49 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rob Landley The kernel has had CONFIG_DEVTMPFS_MOUNT for years, but it only applied to fallback ROOT= not initramfs/initmpfs. As long as the config option exists, it might as well work. I use this for board bringup: populating a chdir and calling cpio as a normal user often leaves /dev empty (because mknod requires root access), meaning no /dev/console for init/main.c to open, meaning init runs without stdin/stdout/stderr and has to mount devtmpfs and redirect the filehandles blind with no error output if something goes wrong. Signed-off-by: Rob Landley --- Previously: https://lkml.org/lkml/2017/9/13/651 init/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/init/main.c b/init/main.c index bb984ed79de0..288c73db57f4 100644 --- a/init/main.c +++ b/init/main.c @@ -1612,7 +1612,6 @@ static noinline void __init kernel_init_freeable(void) kunit_run_all_tests(); wait_for_initramfs(); - console_on_rootfs(); /* * check if there is an early userspace init. If yes, let it do all @@ -1621,7 +1620,11 @@ static noinline void __init kernel_init_freeable(void) if (init_eaccess(ramdisk_execute_command) != 0) { ramdisk_execute_command = NULL; prepare_namespace(); + } else if (IS_ENABLED(CONFIG_DEVTMPFS_MOUNT)) { + sys_mkdir("/dev", 0755); + devtmpfs_mount(); } + console_on_rootfs(); /* * Ok, we have completed the initial bootup, and