From: Marco Felsch <m.felsch@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH 3/7] partition: allow to reparse a partition table
Date: Thu, 15 Feb 2024 12:07:52 +0100 [thread overview]
Message-ID: <20240215110752.qjhfdytbb3hap5qk@pengutronix.de> (raw)
In-Reply-To: <20240215074757.960200-4-s.hauer@pengutronix.de>
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@pengutronix.de>
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))
> + pr_warn("%s is busy, will continue to use old partition table\n", c->name);
> + return -EBUSY;
> + }
> + }
> +
> + list_for_each_entry_safe(c, tmp, &cdev->partitions, partition_entry) {
> + if (c->flags & DEVFS_PARTITION_FROM_TABLE)
if (cdev_flag_set(c, DEVFS_PARTITION_FROM_TABLE))
> + cdevfs_del_partition(c);
> + }
> +
> + return parse_partition_table(blk);
> +}
> +
> int partition_parser_register(struct partition_parser *p)
> {
> list_add_tail(&p->list, &partition_parser_list);
> diff --git a/include/disks.h b/include/disks.h
> index 1ca7063c54..ccb50d3ce9 100644
> --- a/include/disks.h
> +++ b/include/disks.h
> @@ -24,5 +24,6 @@ struct partition_entry {
> } __attribute__ ((packed));
>
> extern int parse_partition_table(struct block_device*);
> +int reparse_partition_table(struct block_device *blk);
>
> #endif /* DISKS_H */
> --
> 2.39.2
>
>
>
next prev parent reply other threads:[~2024-02-15 11:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-15 7:47 [PATCH 0/7] Detect partition changes at runtime Sascha Hauer
2024-02-15 7:47 ` [PATCH 1/7] fs: move cdev open count to cdev_open()/cdev_close() Sascha Hauer
2024-02-15 7:47 ` [PATCH 2/7] common: partitions: efi: fix memory leak Sascha Hauer
2024-02-15 7:47 ` [PATCH 3/7] partition: allow to reparse a partition table Sascha Hauer
2024-02-15 11:07 ` Marco Felsch [this message]
2024-02-16 11:14 ` Sascha Hauer
2024-02-15 7:47 ` [PATCH 4/7] block: reparse partition table when necessary Sascha Hauer
2024-02-15 12:52 ` Marco Felsch
2024-02-16 11:16 ` Sascha Hauer
2024-02-15 7:47 ` [PATCH 5/7] fastboot: pass list to fb_addvar() Sascha Hauer
2024-02-15 7:47 ` [PATCH 6/7] fastboot: add function to free a list of fastboot variables Sascha Hauer
2024-02-15 7:47 ` [PATCH 7/7] fastboot: evaluate fastboot partitions when used Sascha Hauer
2024-02-15 12:51 ` Marco Felsch
2024-02-16 11:15 ` Sascha Hauer
2024-02-15 8:31 ` [PATCH 0/7] Detect partition changes at runtime Ahmad Fatoum
2024-02-15 12:54 ` Marco Felsch
2024-02-16 11:13 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240215110752.qjhfdytbb3hap5qk@pengutronix.de \
--to=m.felsch@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox