From patchwork Thu Oct 21 22:51:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 12576745 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D48C4C433EF for ; Thu, 21 Oct 2021 22:51:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B22EA61359 for ; Thu, 21 Oct 2021 22:51:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231515AbhJUWxm (ORCPT ); Thu, 21 Oct 2021 18:53:42 -0400 Received: from rere.qmqm.pl ([91.227.64.183]:57374 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229567AbhJUWxl (ORCPT ); Thu, 21 Oct 2021 18:53:41 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4Hb2lb3tbrz5Y; Fri, 22 Oct 2021 00:51:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1634856684; bh=lHHnRAA8YLV9uPJ7CrD5WKHXnh3ph4RCyZ2dlYvGX+0=; h=Date:From:Subject:To:Cc:From; b=m7le8OCLrkH6rybhlZq/HqAvBjFNaosEB2GQ6A4ljIgcX2emA0CUoBa+cIPaz/rMf AhPUyHbxvPW1bZUGg4UK3JjtRZtcc0iwanowHISBp9kFUHk5cjPqGdRldzc+JAIeqM Uqm91y41Xj6nu0kehiHKz09q26LWCYrVvIO2/lWZrDWIR84DX4J5yk968HrZI6Eka5 3grcJEib0cbEi7Tcccfs0shUFktMCT5B2Q+RKrtoLt0PqaGEpJ2ePdaNffq0Z9AuIH lLR5Bs25g7JhFs4kEEaS/jg4838r47CnFRoggiIJopvR2DBOf5pVVgRKryqq5YkDUG X9aplhRG3AjFQ== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.3 at mail Date: Fri, 22 Oct 2021 00:51:23 +0200 Message-Id: <8a6b11c6ada5d55bdb2b1f8319e47bbf5192654b.1634856658.git.mirq-linux@rere.qmqm.pl> From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH 1/2] block: parse cmdline partitions first MIME-Version: 1.0 To: Jens Axboe , Jonathan Corbet Cc: linux-block@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Make sure cmdline-provided partitions can override anything that's on a storage device. Signed-off-by: Michał Mirosław --- block/partitions/core.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/block/partitions/core.c b/block/partitions/core.c index 66ef9bc6d6a1..b4dac3077dce 100644 --- a/block/partitions/core.c +++ b/block/partitions/core.c @@ -15,6 +15,13 @@ #include "check.h" static int (*check_part[])(struct parsed_partitions *) = { + /* + * Let cmdline override whatever there is on disk. + */ +#ifdef CONFIG_CMDLINE_PARTITION + cmdline_partition, +#endif + /* * Probe partition formats with tables at disk address 0 * that also have an ADFS boot block at 0xdc0. @@ -42,9 +49,6 @@ static int (*check_part[])(struct parsed_partitions *) = { adfspart_check_ADFS, #endif -#ifdef CONFIG_CMDLINE_PARTITION - cmdline_partition, -#endif #ifdef CONFIG_EFI_PARTITION efi_partition, /* this must come before msdos */ #endif From patchwork Thu Oct 21 22:51:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 12576747 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1FCEC433FE for ; Thu, 21 Oct 2021 22:51:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 786DE61354 for ; Thu, 21 Oct 2021 22:51:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231755AbhJUWxm (ORCPT ); Thu, 21 Oct 2021 18:53:42 -0400 Received: from rere.qmqm.pl ([91.227.64.183]:56520 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229935AbhJUWxm (ORCPT ); Thu, 21 Oct 2021 18:53:42 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4Hb2lc2JCTz6R; Fri, 22 Oct 2021 00:51:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1634856684; bh=ZwoePfzEfsoQ8Zx+vw7u0tVHnJGAJrlBMlcivXSgOgA=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=ayTpHcro7nKHbKWJIgWmfnXcSv3s0VwFAF5kxAaIK6X2ZsDRkHMDQNM1G89k74UDn hU9QvKZrKV+F1hfoeYFbXyVGGbfWzIQ925Q+6D9dSj4sqjrkRVqA12SnGiiMUM/6B2 ayvj4eHkN3njrYneicJUXRiKsOjE+swpDNBJ3x4uzZ2ENk2Prk6wLuAnUEee1sBEaE bsp4v8nQrbXXynshNwXaLIKzxpXm9pr6yOry3nvZa/NwrlexTTLBGqIl+jheqqiOBU ZhLcTg6D2wJxLK0Y7J6lANZEyvsI41x7nHVnusJGYabTsVwF5qe+s+Zp3ytcqRT8fP HLM6yp6xZKiVQ== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.3 at mail Date: Fri, 22 Oct 2021 00:51:24 +0200 Message-Id: In-Reply-To: <8a6b11c6ada5d55bdb2b1f8319e47bbf5192654b.1634856658.git.mirq-linux@rere.qmqm.pl> References: <8a6b11c6ada5d55bdb2b1f8319e47bbf5192654b.1634856658.git.mirq-linux@rere.qmqm.pl> From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH 2/2] block: allow empty cmdline partition set MIME-Version: 1.0 To: Jonathan Corbet , Jens Axboe Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Make no-partitions setting valid. This makes it possible to prevent kernel from trying to read a partition table from a device. Signed-off-by: Michał Mirosław --- Documentation/block/cmdline-partition.rst | 2 +- block/partitions/cmdline.c | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Documentation/block/cmdline-partition.rst b/Documentation/block/cmdline-partition.rst index 530bedff548a..a5ccacee982f 100644 --- a/Documentation/block/cmdline-partition.rst +++ b/Documentation/block/cmdline-partition.rst @@ -13,7 +13,7 @@ Users can easily change the partition. The format for the command line is just like mtdparts: blkdevparts=[;] - := :[,] + := :[[,]] := [@](part-name) diff --git a/block/partitions/cmdline.c b/block/partitions/cmdline.c index 1af610f0ba8c..3655e8c8e949 100644 --- a/block/partitions/cmdline.c +++ b/block/partitions/cmdline.c @@ -164,11 +164,9 @@ static int parse_parts(struct cmdline_parts **parts, const char *bdevdef) next_subpart = &(*next_subpart)->next_subpart; } - if (!newparts->subpart) { - pr_warn("cmdline partition has no valid partition."); - ret = -EINVAL; - goto fail; - } + if (!newparts->subpart) + pr_warn("%s: cmdline partition has no valid partitions.", + newparts->name); *parts = newparts;