From patchwork Wed Jun 22 19:06:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Landley X-Patchwork-Id: 9193529 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EA2126075F for ; Wed, 22 Jun 2016 19:06:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6B722840F for ; Wed, 22 Jun 2016 19:06:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9AB428415; Wed, 22 Jun 2016 19:06:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD07B2840F for ; Wed, 22 Jun 2016 19:06:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751498AbcFVTGu (ORCPT ); Wed, 22 Jun 2016 15:06:50 -0400 Received: from mail-yw0-f195.google.com ([209.85.161.195]:34161 "EHLO mail-yw0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751307AbcFVTGs (ORCPT ); Wed, 22 Jun 2016 15:06:48 -0400 Received: by mail-yw0-f195.google.com with SMTP id l125so7509279ywb.1 for ; Wed, 22 Jun 2016 12:06:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=landley-net.20150623.gappssmtp.com; s=20150623; h=to:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=X4Ojrl8hMAi8WdgI5MJ+wIsDYd8/aUys+llA0Ru4QBY=; b=L4lExzzMRqOD33grCklxgiNaRLvo4l/Ow5kIHE4A676D825UyXAHjBjv003PVVGYFw DTHu3swEEVQJsCkWHKRUh+6RUql7efJr0RlSLrlJUaDNgFBRMN7O2lcEiLHRPMhZGbkt UE9uf5ZLp13KYA3U/Asq2ou60lQnUb/5Xbnd/En3/45p5yAoRfF51d0A3drBITjfKU+I obRfYX7tkjnEtcdI489dTNA3rsggWl4Nfj+kERst/HDXHB08Q2wyKZU/6AjPdtDOA1Ca b3tVMYawUttxkfrkWFeOVo+aNFepBz6vAgFjbob+i7jU/KBUmh5wgO6AH+PJn1xbTGgx en8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=X4Ojrl8hMAi8WdgI5MJ+wIsDYd8/aUys+llA0Ru4QBY=; b=d25XAFG6kEcxD5FPxCaIOmy6ITlAwbpOCEw2dwpkCJ57mNlg2Mq03fbUnWsW31+v5q j+FQ+MRfe3qYb1Z5Efik+M+KseftNZw16ATN46nKc9VyaQfwPbsOGkvYDgzJZqnBcoj7 9F5Umlc6+7fJFB+1FrW2mBF1WIv1l3aumP04LEnFU6ETfVZZhmx5gBxAsl03dQr2IL+N EipGjNIbbDkYIygD9lRUe6xU34LskpY3Jw6KipynaTm0v1r8s3P6P2xBMeMfCUe29V9w EWn9MjcgBYYSn0rVy2j1Wlo+Ba3kPQslBVSUFR6u+m561l+aI9ACbloRcJYI52Ky4XOK IyQw== X-Gm-Message-State: ALyK8tKV8j3Du0udUhxJa8xcurOJPco6UUvrp5ZAOvZboi4oi208Hm2hXo0umrfU6AN/QQ== X-Received: by 10.37.64.195 with SMTP id n186mr16927372yba.166.1466622407961; Wed, 22 Jun 2016 12:06:47 -0700 (PDT) Received: from [192.168.1.9] (cpe-72-182-52-210.austin.res.rr.com. [72.182.52.210]) by smtp.googlemail.com with ESMTPSA id k142sm316744ywe.32.2016.06.22.12.06.46 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 22 Jun 2016 12:06:47 -0700 (PDT) To: linux-kernel@vger.kernel.org, linux-sh@vger.kernel.org, gregkh@linuxfoundation.org, pavel@ucw.cz, akpm@linux-foundation.org, tglx@linutronix.de, mgorman@suse.de, mingo@kernel.org, keescook@chromium.org, paulmck@linux.vnet.ibm.com From: Rob Landley Subject: [PATCH] Make CONFIG_DEVTMPFS_MOUNT apply to initramfs/initmpfs. Message-ID: <576AE1C5.5090909@landley.net> Date: Wed, 22 Jun 2016 14:06:45 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Rob Landley Make CONFIG_DEVTMPFS_MOUNT apply to initramfs/initmpfs. Update help text, slightly improve error reporting, move /dev/console open down after devtmpfs mount, don't check IS_ENABLED(CONFIG_TMPFS) before mounting devtmpfs (it's always there, even if just a ramfs alias), and report whether we think we're using tmpfs or ramfs for rootfs. Signed-off-by: Rob Landley --- drivers/base/Kconfig | 10 ++++++---- drivers/base/devtmpfs.c | 3 ++- init/do_mounts.c | 7 +++---- init/main.c | 17 ++++++++++------- 4 files changed, 21 insertions(+), 16 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig index 98504ec..3fb07c1 100644 --- a/drivers/base/Kconfig +++ b/drivers/base/Kconfig @@ -45,16 +45,18 @@ config DEVTMPFS file system will be used instead. config DEVTMPFS_MOUNT - bool "Automount devtmpfs at /dev, after the kernel mounted the rootfs" + bool "Automount devtmpfs at /dev" depends on DEVTMPFS help This will instruct the kernel to automatically mount the devtmpfs filesystem at /dev, directly after the kernel has mounted the root filesystem. The behavior can be overridden with the commandline parameter: devtmpfs.mount=0|1. - This option does not affect initramfs based booting, here - the devtmpfs filesystem always needs to be mounted manually - after the rootfs is mounted. + + In an initramfs based system, this can create the /dev directory + as well. Other root filesystems require a /dev directory to exist + to act as a mount point. + With this option enabled, it allows to bring up a system in rescue mode with init=/bin/sh, even when the /dev directory on the rootfs is completely empty. diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c index 44a74cf..eaf8532 100644 --- a/drivers/base/devtmpfs.c +++ b/drivers/base/devtmpfs.c @@ -356,7 +356,8 @@ int devtmpfs_mount(const char *mntdir) err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL); if (err) - printk(KERN_INFO "devtmpfs: error mounting %i\n", err); + printk(KERN_ERR "devtmpfs: error %i mounting on %s\n", + err, mntdir); else printk(KERN_INFO "devtmpfs: mounted\n"); return err; diff --git a/init/do_mounts.c b/init/do_mounts.c index dea5de9..6daf63e 100644 --- a/init/do_mounts.c +++ b/init/do_mounts.c @@ -599,7 +599,6 @@ void __init prepare_namespace(void) mount_root(); out: - devtmpfs_mount("dev"); sys_mount(".", "/", NULL, MS_MOVE, NULL); sys_chroot("."); } @@ -614,8 +613,9 @@ static struct dentry *rootfs_mount(struct file_system_type *fs_type, if (test_and_set_bit(0, &once)) return ERR_PTR(-ENODEV); - if (IS_ENABLED(CONFIG_TMPFS) && is_tmpfs) + if (is_tmpfs) fill = shmem_fill_super; + printk(KERN_INFO "rootfs is %s\n", is_tmpfs ? "tmpfs" : "ramfs"); return mount_nodev(fs_type, flags, data, fill); } @@ -637,9 +637,8 @@ int __init init_rootfs(void) (!root_fs_names || strstr(root_fs_names, "tmpfs"))) { err = shmem_init(); is_tmpfs = true; - } else { + } else err = init_ramfs_fs(); - } if (err) unregister_filesystem(&rootfs_fs_type); diff --git a/init/main.c b/init/main.c index b3c6e36..e6bf551 100644 --- a/init/main.c +++ b/init/main.c @@ -1007,12 +1007,6 @@ static noinline void __init kernel_init_freeable(void) do_basic_setup(); - /* Open the /dev/console on the rootfs, this should never fail */ - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0) - pr_err("Warning: unable to open an initial console.\n"); - - (void) sys_dup(0); - (void) sys_dup(0); /* * check if there is an early userspace init. If yes, let it do all * the work @@ -1024,7 +1018,16 @@ static noinline void __init kernel_init_freeable(void) if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) { ramdisk_execute_command = NULL; prepare_namespace(); - } + } else if (config_enabled(CONFIG_DEVTMPFS_MOUNT)) + sys_mkdir("/dev", 0755); + devtmpfs_mount("dev"); + + /* Open the /dev/console on the rootfs, this should never fail */ + if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0) + pr_err("Warning: unable to open an initial console.\n"); + + (void) sys_dup(0); + (void) sys_dup(0); /* * Ok, we have completed the initial bootup, and