From patchwork Wed May 31 12:55:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 1788325 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=o9AaYQSj; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QWTmm6MVFz20Q4 for ; Wed, 31 May 2023 22:56:56 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Y15SPNCyjwcb0wFpA7Qu98jZ4Qwllqyi6hi4F7w1Ip4=; b=o9AaYQSjrcuprF tRCGx9kvCAA7houZQBIm9l8aYSmIpXlCs4RxsGiHEqQbW7/ME5H8314gYmxxKWB6I4XN+YSrRNTiB 8CCVPzsC6fp+30lH2GcqioaPVFdpZK8B0qihEGgVZn9bRmXIk86j4uMJKWxeQmGd12MCA5Djapo8N 8MDqNo+nGXKHS3sbXg8sxE/Lo72INpLqw+BIE0TPBk8Sr9fyusbDZLO3g55pza+kV0BKbh7yZIpUk cDZO5loDxReqmR034y7p4lPKT1yXm+CneIiIFLupZ5RlSfPqALq6TxpE0RWTqrJRi/wahvDS8d2/i TwJ8KpTHB3sNG63Rd/ng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q4LNI-00HRHT-2U; Wed, 31 May 2023 12:56:24 +0000 Received: from [2001:4bb8:182:6d06:2e49:a56:513a:92ee] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1q4LNG-00HRDS-1i; Wed, 31 May 2023 12:56:23 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Mike Snitzer , Joern Engel , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Pavel Machek , Loic Poulain , dm-devel@redhat.com, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-mtd@lists.infradead.org, linux-pm@vger.kernel.org Subject: [PATCH 08/24] init: pass root_device_name explicitly Date: Wed, 31 May 2023 14:55:19 +0200 Message-Id: <20230531125535.676098-9-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230531125535.676098-1-hch@lst.de> References: <20230531125535.676098-1-hch@lst.de> MIME-Version: 1.0 X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Instead of declaring root_device_name as a global variable pass it as an argument to the functions using it. Signed-off-by: Christoph Hellwig --- init/do_mounts.c | 29 ++++++++++++++++------------- init/do_mounts.h | 14 +++++++------- init/do_mounts_initrd.c | 11 ++++++----- 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/init/do_mounts.c b/init/do_mounts.c index e708b02d9d6566..1405ee7218bf00 100644 --- a/init/do_mounts.c +++ b/init/do_mounts.c @@ -28,7 +28,6 @@ #include "do_mounts.h" int root_mountflags = MS_RDONLY | MS_SILENT; -static char * __initdata root_device_name; static char __initdata saved_root_name[64]; static int root_wait; @@ -391,7 +390,7 @@ static int __init do_mount_root(const char *name, const char *fs, return ret; } -void __init mount_root_generic(char *name, int flags) +void __init mount_root_generic(char *name, char *pretty_name, int flags) { struct page *page = alloc_page(GFP_KERNEL); char *fs_names = page_address(page); @@ -425,7 +424,7 @@ void __init mount_root_generic(char *name, int flags) * and give them a list of the available devices */ printk("VFS: Cannot open root device \"%s\" or %s: error %d\n", - root_device_name, b, err); + pretty_name, b, err); printk("Please append a correct \"root=\" boot option; here are the available partitions:\n"); printk_all_partitions(); @@ -541,7 +540,7 @@ static bool __init fs_is_nodev(char *fstype) return ret; } -static int __init mount_nodev_root(void) +static int __init mount_nodev_root(char *root_device_name) { char *fs_names, *fstype; int err = -EINVAL; @@ -569,21 +568,21 @@ static int __init mount_nodev_root(void) } #ifdef CONFIG_BLOCK -static void __init mount_block_root(void) +static void __init mount_block_root(char *root_device_name) { int err = create_dev("/dev/root", ROOT_DEV); if (err < 0) pr_emerg("Failed to create /dev/root: %d\n", err); - mount_root_generic("/dev/root", root_mountflags); + mount_root_generic("/dev/root", root_device_name, root_mountflags); } #else -static inline void mount_block_root(void) +static inline void mount_block_root(char *root_device_name) { } #endif /* CONFIG_BLOCK */ -void __init mount_root(void) +void __init mount_root(char *root_device_name) { switch (ROOT_DEV) { case Root_NFS: @@ -593,11 +592,12 @@ void __init mount_root(void) mount_cifs_root(); break; case 0: - if (root_device_name && root_fs_names && mount_nodev_root() == 0) + if (root_device_name && root_fs_names && + mount_nodev_root(root_device_name) == 0) break; fallthrough; default: - mount_block_root(); + mount_block_root(root_device_name); break; } } @@ -607,6 +607,8 @@ void __init mount_root(void) */ void __init prepare_namespace(void) { + char *root_device_name; + if (root_delay) { printk(KERN_INFO "Waiting %d sec before mounting root device...\n", root_delay); @@ -628,7 +630,8 @@ void __init prepare_namespace(void) root_device_name = saved_root_name; if (!strncmp(root_device_name, "mtd", 3) || !strncmp(root_device_name, "ubi", 3)) { - mount_root_generic(root_device_name, root_mountflags); + mount_root_generic(root_device_name, root_device_name, + root_mountflags); goto out; } ROOT_DEV = name_to_dev_t(root_device_name); @@ -636,7 +639,7 @@ void __init prepare_namespace(void) root_device_name += 5; } - if (initrd_load()) + if (initrd_load(root_device_name)) goto out; /* wait for any asynchronous scanning to complete */ @@ -649,7 +652,7 @@ void __init prepare_namespace(void) async_synchronize_full(); } - mount_root(); + mount_root(root_device_name); out: devtmpfs_mount(); init_mount(".", "/", NULL, MS_MOVE, NULL); diff --git a/init/do_mounts.h b/init/do_mounts.h index 33623025f6951a..15e372b00ce704 100644 --- a/init/do_mounts.h +++ b/init/do_mounts.h @@ -10,8 +10,8 @@ #include #include -void mount_root_generic(char *name, int flags); -void mount_root(void); +void mount_root_generic(char *name, char *pretty_name, int flags); +void mount_root(char *root_device_name); extern int root_mountflags; static inline __init int create_dev(char *name, dev_t dev) @@ -33,11 +33,11 @@ static inline int rd_load_image(char *from) { return 0; } #endif #ifdef CONFIG_BLK_DEV_INITRD - -bool __init initrd_load(void); - +bool __init initrd_load(char *root_device_name); #else - -static inline bool initrd_load(void) { return false; } +static inline bool initrd_load(char *root_device_name) +{ + return false; + } #endif diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c index 686d1ff3af4bb1..425f4bcf4b77e0 100644 --- a/init/do_mounts_initrd.c +++ b/init/do_mounts_initrd.c @@ -83,7 +83,7 @@ static int __init init_linuxrc(struct subprocess_info *info, struct cred *new) return 0; } -static void __init handle_initrd(void) +static void __init handle_initrd(char *root_device_name) { struct subprocess_info *info; static char *argv[] = { "linuxrc", NULL, }; @@ -95,7 +95,8 @@ static void __init handle_initrd(void) real_root_dev = new_encode_dev(ROOT_DEV); create_dev("/dev/root.old", Root_RAM0); /* mount initrd on rootfs' /root */ - mount_root_generic("/dev/root.old", root_mountflags & ~MS_RDONLY); + mount_root_generic("/dev/root.old", root_device_name, + root_mountflags & ~MS_RDONLY); init_mkdir("/old", 0700); init_chdir("/old"); @@ -117,7 +118,7 @@ static void __init handle_initrd(void) init_chdir("/"); ROOT_DEV = new_decode_dev(real_root_dev); - mount_root(); + mount_root(root_device_name); printk(KERN_NOTICE "Trying to move old root to /initrd ... "); error = init_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL); @@ -133,7 +134,7 @@ static void __init handle_initrd(void) } } -bool __init initrd_load(void) +bool __init initrd_load(char *root_device_name) { if (mount_initrd) { create_dev("/dev/ram", Root_RAM0); @@ -145,7 +146,7 @@ bool __init initrd_load(void) */ if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) { init_unlink("/initrd.image"); - handle_initrd(); + handle_initrd(root_device_name); return true; } }