Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1382468rwb; Wed, 16 Nov 2022 17:01:24 -0800 (PST) X-Google-Smtp-Source: AA0mqf6S3hLgYfzAGd0jZ11Qs7pO0shhvMWciJpw945tygW4GX2t7XiRzL/p2K4TmEckffhuG4lz X-Received: by 2002:a17:903:2407:b0:17f:3da:f19d with SMTP id e7-20020a170903240700b0017f03daf19dmr304165plo.147.1668646883844; Wed, 16 Nov 2022 17:01:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668646883; cv=none; d=google.com; s=arc-20160816; b=P5OZGPgnRIT30+MDv0MTj74XzrDGkT/nHTB3CHz9bq33ulqQGjq4FKQFBGPxyoEyBF uwwlHwiP/Bm3JKJQs6mRQ1S+B2sgoBhemKcpzbjlrQ6kmtoO1A89s3q94agtJyTsbRam yOpi+urmy2yyDJffZLHVfeESRNMyNYHq9P6y9cOQ0VtevX5ZOBePGV1serLr6zlq13TW q7/M3H7YedQIGyHzpA2bfjTX1AnHFd1P13Zr8l0zgCmfD0Ad6qbzMwyy54BBgAKr06h0 kbec5BYETVcqgaVQNK5+dHs9G6UpJSQCFQru9H5il4z5otTL1g22wMF72PQJlKIQ2qVm AxLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date; bh=QL8a0deLAuhj1IQrO+ZAK2NOnJRVmLLYuYU2Bz1xQ2g=; b=ofeduLXY7ZBSZLkNJg1AYf5GeDaqEx79QdAyg1wfaAvtDwz5bz2Eh4dX+AS7E7rSA7 vwlRZlLC+fOPJ6HmwLLk954SVKqz2QTIM7S73r8SpdQ//M+aEfMD05DL6HhCQbdHctUH lf7JYJUmU19czdAaVlK2Y8r7Zn0OKOS5Y6RZxVkZFZJD9wShIJqaD4riA8Pyl3VdUMze CgGMHvZ+CQ2fxqsTqEm0IMJ9OhSUCXODf18fHKr1v1n4DyFqqCemzGwu3MUEqXZj1fYi dRcyP1D4PsOQIf6mD4bxrLdVix4LSBoXBPzOZalwIQ0/UJ2iklTx65bHDjV8RXhGCGMk BeCw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v29-20020aa799dd000000b005251a2f06bbsi15221896pfi.59.2022.11.16.17.01.11; Wed, 16 Nov 2022 17:01:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233716AbiKQAng (ORCPT + 90 others); Wed, 16 Nov 2022 19:43:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234042AbiKQAnT (ORCPT ); Wed, 16 Nov 2022 19:43:19 -0500 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27EC964A1B; Wed, 16 Nov 2022 16:43:16 -0800 (PST) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.94.2) (envelope-from ) id 1ovSzk-0002VB-PV; Thu, 17 Nov 2022 01:43:08 +0100 Date: Thu, 17 Nov 2022 00:43:03 +0000 From: Daniel Golle To: Christoph Hellwig , Jens Axboe , "Martin K. Petersen" , Chaitanya Kulkarni , Wolfram Sang , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 2/4] block: add new flag to add partitions read-only Message-ID: <31b78b87ece4e095aa082d09ca3d4058a2484f3c.1668644705.git.daniel@makrotopia.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_00,PDS_OTHER_BAD_TLD, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add flag ADDPART_FLAG_READONLY to allow partition parsers marking a partition to be set read-only. This is needed for the uImage.FIT partition parser added by a follow-up commit: we need to be sure the contents of uImage.FIT sub-images remain unaltered they are validated using a hash within the uImage.FIT structure which also serves as partition table. Signed-off-by: Daniel Golle --- block/blk.h | 1 + block/partitions/core.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/block/blk.h b/block/blk.h index e85703ae81dd..05ac426350b2 100644 --- a/block/blk.h +++ b/block/blk.h @@ -414,6 +414,7 @@ void blk_free_ext_minor(unsigned int minor); #define ADDPART_FLAG_NONE 0 #define ADDPART_FLAG_RAID 1 #define ADDPART_FLAG_WHOLEDISK 2 +#define ADDPART_FLAG_READONLY 4 int bdev_add_partition(struct gendisk *disk, int partno, sector_t start, sector_t length); int bdev_del_partition(struct gendisk *disk, int partno); diff --git a/block/partitions/core.c b/block/partitions/core.c index b8112f52d388..355646b0707d 100644 --- a/block/partitions/core.c +++ b/block/partitions/core.c @@ -398,6 +398,9 @@ static struct block_device *add_partition(struct gendisk *disk, int partno, goto out_del; } + if (flags & ADDPART_FLAG_READONLY) + bdev->bd_read_only = true; + /* everything is up and running, commence */ err = xa_insert(&disk->part_tbl, partno, bdev, GFP_KERNEL); if (err) -- 2.38.1