On Thu, Feb 15, 2024 at 12:07:52PM +0100, Marco Felsch wrote: > On 24-02-15, Sascha Hauer wrote: > > The partition table of a block device may change when it is written to. > > Allow to reparse the partition table when this happens. > > This is easy when none of the partitions is opened, in that case just > > remove the old partitions and call parse_partition_table() again. > > When a partition is opened (including mounted) we can't remove it. In > > that case continue with the old partition table and print a warning. > > > > Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> > > Just two nits, to make cdev access more opaque. > > > --- > > common/partitions.c | 20 ++++++++++++++++++++ > > include/disks.h | 1 + > > 2 files changed, 21 insertions(+) > > > > diff --git a/common/partitions.c b/common/partitions.c > > index 78b68276c3..cfcd0e080b 100644 > > --- a/common/partitions.c > > +++ b/common/partitions.c > > @@ -154,6 +154,26 @@ int parse_partition_table(struct block_device *blk) > > return rc; > > } > > > > +int reparse_partition_table(struct block_device *blk) > > +{ > > + struct cdev *cdev = &blk->cdev; > > + struct cdev *c, *tmp; > > + > > + list_for_each_entry(c, &cdev->partitions, partition_entry) { > > + if (c->open) { > > if (cdev_is_open(c)) I was assuming this function already exists, but it doesn't. I'll leave that for a later exercise. Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |