[PATCH 4/5] disk: introduce partition name
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Sat Feb 16 06:29:16 EST 2013
On 18:43 Fri 15 Feb , Sascha Hauer wrote:
> On Fri, Feb 15, 2013 at 02:35:16PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > so we can register partion with name as present in EFI GPT
> >
> > Cc: Rob Herring <rob.herring at calxeda.com>
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> > ---
> > common/partitions.c | 54 ++++++++++++++++++++++++++++++++++----------
> > common/partitions/parser.h | 2 ++
> > 2 files changed, 44 insertions(+), 12 deletions(-)
> >
> > diff --git a/common/partitions.c b/common/partitions.c
> > index c1578c9..b0f48be 100644
> > --- a/common/partitions.c
> > +++ b/common/partitions.c
> > @@ -44,15 +44,43 @@ LIST_HEAD(partition_parser_list);
> > static int register_one_partition(struct block_device *blk,
> > struct partition *part, int no)
> > {
> > - char partition_name[19];
> > + char *partition_name;
> > + int ret;
> > + uint64_t start = part->first_sec * SECTOR_SIZE;
> > + uint64_t size = part->size * SECTOR_SIZE;
> > +
> > + partition_name = asprintf("%s.%d", blk->cdev.name, no);
> > + if (!partition_name)
> > + return -ENOMEM;
> > + dev_dbg(blk->dev, "Registering partition %s on drive %s\n",
> > + partition_name, blk->cdev.name);
> > + ret = devfs_add_partition(blk->cdev.name,
> > + start, size, 0, partition_name);
> > + if (ret)
> > + goto out;
> > +
> > + free(partition_name);
> > +
> > + if (!part->name[0])
> > + return 0;
>
> So when a name is not given then you also don't register the partition
> with a number?
we register with number first and only register with name if present
Best Regards,
J.
>
> > +
> > + partition_name = asprintf("%s.%s", blk->cdev.name, part->name);
> > + if (!partition_name)
> > + return -ENOMEM;
> >
> > - sprintf(partition_name, "%s.%d", blk->cdev.name, no);
> > dev_dbg(blk->dev, "Registering partition %s on drive %s\n",
> > partition_name, blk->cdev.name);
> > - return devfs_add_partition(blk->cdev.name,
> > - part->first_sec * SECTOR_SIZE,
> > - part->size * SECTOR_SIZE,
> > - 0, partition_name);
> > + ret = devfs_add_partition(blk->cdev.name,
> > + start, size, 0, partition_name);
> > +
> > + if (ret)
> > + dev_warn(blk->dev, "Registering partition %s on drive %s failled\n",
> > + partition_name, blk->cdev.name);
>
> s/failled/failed/
>
> Sascha
>
> --
> Pengutronix e.K. | |
> Industrial Linux Solutions | http://www.pengutronix.de/ |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list