mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 21:21:41 +00:00
block: add support for defining read-only partitions
Add support for defining read-only partitions and complete support for it in the cmdline partition parser as the additional "ro" after a partition is scanned but never actually applied. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20241002221306.4403-2-ansuelsmth@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
e3569ecae4
commit
ba40f4c590
@ -547,6 +547,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);
|
||||
|
@ -237,6 +237,9 @@ static int add_part(int slot, struct cmdline_subpart *subpart,
|
||||
put_partition(state, slot, subpart->from >> 9,
|
||||
subpart->size >> 9);
|
||||
|
||||
if (subpart->flags & PF_RDONLY)
|
||||
state->parts[slot].flags |= ADDPART_FLAG_READONLY;
|
||||
|
||||
info = &state->parts[slot].info;
|
||||
|
||||
strscpy(info->volname, subpart->name, sizeof(info->volname));
|
||||
|
@ -373,6 +373,9 @@ static struct block_device *add_partition(struct gendisk *disk, int partno,
|
||||
goto out_del;
|
||||
}
|
||||
|
||||
if (flags & ADDPART_FLAG_READONLY)
|
||||
bdev_set_flag(bdev, BD_READ_ONLY);
|
||||
|
||||
/* everything is up and running, commence */
|
||||
err = xa_insert(&disk->part_tbl, partno, bdev, GFP_KERNEL);
|
||||
if (err)
|
||||
|
Loading…
Reference in New Issue
Block a user