block: add new flag to add partitions read-only
Subsystems (3)
RFC PATCH 1/5 block: add new flag to add partitions read-only
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 <[email protected]>
--- block/blk.h | 1 + block/partitions/core.c | 3 +++ 2 files changed, 4 insertions(+)
block/blk.h +1 -0
@@ -404,6 +404,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 4int bdev_add_partition (struct gendisk *disk,int partno,sector_t start,sector_t length);int bdev_del_partition (struct gendisk *disk,int partno);
block/partitions/core.c +3 -0
@@ -399,6 +399,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)
Signature · 1 line
2.36.0