mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Marco Felsch <m.felsch@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2 2/4] parted: add support for gpt-location
Date: Thu, 24 Apr 2025 22:34:29 +0200	[thread overview]
Message-ID: <20250424203429.yfdk36fphj4j5ffq@pengutronix.de> (raw)
In-Reply-To: <aAon8N28ujN0YTaL@pengutronix.de>

On 25-04-24, Sascha Hauer wrote:
> On Wed, Apr 23, 2025 at 04:09:11PM +0200, Marco Felsch wrote:
> > Add support to place the GPT partition entries to random places instead
> > of LBA2.
> > 
> > Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> > ---
> > v2:
> > - new
> > 
> >  commands/parted.c | 29 +++++++++++++++++++++++++++--
> >  1 file changed, 27 insertions(+), 2 deletions(-)
> > 
> > diff --git a/commands/parted.c b/commands/parted.c
> > index 90cee1ede10e..895c06524d4c 100644
> > --- a/commands/parted.c
> > +++ b/commands/parted.c
> > @@ -224,6 +224,30 @@ static int do_mklabel(struct block_device *blk, int argc, char *argv[])
> >  		return -EINVAL;
> >  	}
> >  
> > +	if (argc == 3) {
> > +		uint64_t mult;
> > +		int ret;
> > +
> > +		if (!strcmp(argv[1], "msdos")) {
> > +			printf("gpt-location not supported for msdos partitions\n");
> > +			return -EINVAL;
> > +		}
> > +
> > +		ret = parted_strtoull(argv[2], &gpt_location, &mult);
> > +		if (ret)
> > +			return ret;
> > +
> > +		if (!mult)
> > +			mult = gunit;
> > +
> > +		gpt_location *= mult;
> > +
> > +		/* Ensure alignment */
> > +		gpt_location = ALIGN(gpt_location, SECTOR_SIZE);
> > +		/* convert to LBA */
> > +		gpt_location >>= SECTOR_SHIFT;
> > +	}
> > +
> >  	pdesc = partition_table_new(blk, argv[1], gpt_location);
> >  	if (IS_ERR(pdesc)) {
> >  		printf("Error: Cannot create partition table: %pe\n", pdesc);
> > @@ -236,7 +260,7 @@ static int do_mklabel(struct block_device *blk, int argc, char *argv[])
> >  		partition_table_free(gpdesc);
> >  	gpdesc = pdesc;
> >  
> > -	return 2;
> > +	return argc > 2 ? 3 : 2;
> 
> Optional arguments are not supported by parted. You can pass multiple
> commands to parted, e.g.
> 
> parted /dev/mmc0 mklabel gpt mkpart foo ext4 4MiB 1024MiB
> 
> argc will contain the remaining arguments, when another command follows
> it won't be exactly three and you can't tell if the argument belongs to
> this command or is the start of the next one.

Argh.. damn, I wasn't aware of such use-cases. Thanks for the hint :)

> You could implement it as an option.

Sure.

Regards,
  Marco



  reply	other threads:[~2025-04-24 20:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-23 14:09 [PATCH v2 1/4] partitions: efi: add support to specify gpt-location Marco Felsch
2025-04-23 14:09 ` [PATCH v2 2/4] parted: add support for gpt-location Marco Felsch
2025-04-24 12:00   ` Sascha Hauer
2025-04-24 20:34     ` Marco Felsch [this message]
2025-04-23 14:09 ` [PATCH v2 3/4] defaultenv-2: add support to automatically create an initial GPT table Marco Felsch
2025-04-24 11:51   ` Sascha Hauer
2025-04-23 14:09 ` [PATCH v2 4/4] ARM: riotboard: drop static barebox-environment handling Marco Felsch
2025-04-24  8:02   ` Ahmad Fatoum
2025-04-24  8:45     ` Marco Felsch
2025-04-24 17:49     ` Alexander Shiyan
2025-04-24 12:08 ` [PATCH v2 1/4] partitions: efi: add support to specify gpt-location 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=20250424203429.yfdk36fphj4j5ffq@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