From patchwork Tue May 23 07:45:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 685257 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 223A8C7EE2D for ; Tue, 23 May 2023 07:46:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235301AbjEWHqr (ORCPT ); Tue, 23 May 2023 03:46:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235604AbjEWHqS (ORCPT ); Tue, 23 May 2023 03:46:18 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 215D8119; Tue, 23 May 2023 00:46:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=6jd70DMemk8ZckghMl9CiFecycutXCrZ5EOvBFmSYmY=; b=SlbXJ9ZjegvwC5j/ePHUyQlPMO 10fGoUAfAUa2294Yk8GJ/5hXIc8QkHAr8iH0CH9IfsltCmCAkRDyo0tkeYvtcN+sFFebcilXnZ04i D8MSXRiSHOtUrnsk15xhBXZkUlim/0Dy2qHZ5lquLt+0gu2J93iXsnFMIveQ5eLIaREfT3xMalFtK cpaDkDjm+tqNDuy2Zoj1oZg4zuMH0I39KBfwyIp4mMVLoS/MhnvBzVzkVFrzBTIhExJTAVRYNWFOG eFOtxHK3Bw5bmENBrXUgt9Ds+KADqvDpzOxaPDU4J9T3ivnwTQagSZsAzzJtSs0mDB6NPPNdcsUwj 9vusgheQ==; Received: from [2001:4bb8:188:23b2:6ade:85c9:530f:6eb0] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1q1Mig-009Gou-1r; Tue, 23 May 2023 07:46:11 +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 , 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 12/24] init: move the nfs/cifs/ram special cases out of name_to_dev_t Date: Tue, 23 May 2023 09:45:23 +0200 Message-Id: <20230523074535.249802-13-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230523074535.249802-1-hch@lst.de> References: <20230523074535.249802-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The nfs/cifs/ram special cass only need to be parsed once, and only in the boot code. Move them out of name_to_dev_t and into prepare_namespace. Signed-off-by: Christoph Hellwig --- init/do_mounts.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/init/do_mounts.c b/init/do_mounts.c index d5c06c1546e82c..86599faf2bf8a1 100644 --- a/init/do_mounts.c +++ b/init/do_mounts.c @@ -248,7 +248,6 @@ static dev_t devt_from_devnum(const char *name) * * 1) device number in hexadecimal represents itself * no leading 0x, for example b302. - * 2) /dev/nfs represents Root_NFS (0xff) * 3) /dev/ represents the device number of disk * 4) /dev/ represents the device number * of partition - device number of disk plus the partition number @@ -266,7 +265,6 @@ static dev_t devt_from_devnum(const char *name) * a colon. * 9) PARTLABEL= with name being the GPT partition label. * MSDOS partitions do not support labels! - * 10) /dev/cifs represents Root_CIFS (0xfe) * * If name doesn't have fall into the categories above, we return (0,0). * block_class is used to check if something is a disk name. If the disk @@ -275,12 +273,6 @@ static dev_t devt_from_devnum(const char *name) */ dev_t name_to_dev_t(const char *name) { - if (strcmp(name, "/dev/nfs") == 0) - return Root_NFS; - if (strcmp(name, "/dev/cifs") == 0) - return Root_CIFS; - if (strcmp(name, "/dev/ram") == 0) - return Root_RAM0; #ifdef CONFIG_BLOCK if (strncmp(name, "PARTUUID=", 9) == 0) return devt_from_partuuid(name + 9); @@ -631,6 +623,12 @@ static dev_t __init parse_root_device(char *root_device_name) if (!strncmp(root_device_name, "mtd", 3) || !strncmp(root_device_name, "ubi", 3)) return Root_Generic; + if (strcmp(root_device_name, "/dev/nfs") == 0) + return Root_NFS; + if (strcmp(root_device_name, "/dev/cifs") == 0) + return Root_CIFS; + if (strcmp(root_device_name, "/dev/ram") == 0) + return Root_RAM0; return name_to_dev_t(root_device_name); }