[PATCH 4/7] block: reparse partition table when necessary
Sascha Hauer
s.hauer at pengutronix.de
Fri Feb 16 03:16:15 PST 2024
On Thu, Feb 15, 2024 at 01:52:28PM +0100, Marco Felsch wrote:
> On 24-02-15, Sascha Hauer wrote:
> > Call reparse_partition_table() when the partition table may have
> > changed. We detect this by recording if the block device has been
> > written to in the area where the partition table is.
> >
> > Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> > ---
> > common/block.c | 30 ++++++++++++++++++++++++++++--
> > include/block.h | 2 ++
> > 2 files changed, 30 insertions(+), 2 deletions(-)
> >
> > diff --git a/common/block.c b/common/block.c
> > index 3a4a9fb731..007c8bed12 100644
> > --- a/common/block.c
> > +++ b/common/block.c
> > @@ -284,6 +284,17 @@ static ssize_t block_op_write(struct cdev *cdev, const void *buf, size_t count,
> > blkcnt_t blocks;
> > int ret;
> >
> > + /*
> > + * When the offset that is written to is within the first two
> > + * LBAs then the partition table has changed, reparse the partition
> > + * table at close time in this case. A GPT covers more space than
> > + * only the first two LBAs, but a CRC of the remaining pieces is
> > + * written to LBA1, so LBA1 must change as well when the partioning
> > + * is changed.
> > + */
> > + if (offset < 2 * SECTOR_SIZE)
> > + blk->need_reparse = true;
> > +
> > if (offset & mask) {
> > size_t now = BLOCKSIZE(blk) - (offset & mask);
> > void *iobuf = block_get(blk, block);
> > @@ -335,13 +346,28 @@ static ssize_t block_op_write(struct cdev *cdev, const void *buf, size_t count,
> > static int block_op_flush(struct cdev *cdev)
> > {
> > struct block_device *blk = cdev->priv;
> > + int ret;
> >
> > blk->discard_start = blk->discard_size = 0;
> >
> > - return writebuffer_flush(blk);
> > + ret = writebuffer_flush(blk);
> > +
> > + return ret;
>
> This change is not required or do I miss something?
Fixed, thanks
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 |
More information about the barebox
mailing list