diff mbox

[U-Boot,V2,4/4] cmd_part: add partition-related command

Message ID 1346882624-12783-4-git-send-email-swarren@wwwdotorg.org
State Changes Requested
Headers show

Commit Message

Stephen Warren Sept. 5, 2012, 10:03 p.m. UTC
From: Stephen Warren <swarren@nvidia.com>

This implements the following:

part uuid mmc 0:1
  -> print partition UUID
part uuid mmc 0:1 uuid
  -> set environment variable to partition UUID

This can be useful when writing a bootcmd which searches all known
devices for something bootable, and then wants the kernel to use the
same partition as the root device, e.g.:

part uuid ${devtype} ${devnum}:${rootpart} uuid
setenv bootargs root=PARTUUID=${uuid} ...

It is expected that further part sub-commands will be added later, e.g.
to find which partition on a disk is marked bootable, to write new
partition tables to disk, etc.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
v2: validate that CONFIG_PARTITION_UUID is defined when CONFIG_CMD_PART is

Note: If Rob Herring's proposed patch "disk/part: introduce
get_device_and_partition" is applied, the body of do_partuuid() should
be reworked to use Rob's new function get_device_and_partition().
---
 common/Makefile   |    1 +
 common/cmd_part.c |  104 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 105 insertions(+), 0 deletions(-)
 create mode 100644 common/cmd_part.c

Comments

Rob Herring Sept. 5, 2012, 11:51 p.m. UTC | #1
On 09/05/2012 05:03 PM, Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
> 
> This implements the following:
> 
> part uuid mmc 0:1
>   -> print partition UUID
> part uuid mmc 0:1 uuid
>   -> set environment variable to partition UUID

What's the reason to not always both print out and set the uuid env var?

Perhaps the env name should be partuuid or part_uuid as you could have
uuid's for other purposes?

> 
> This can be useful when writing a bootcmd which searches all known
> devices for something bootable, and then wants the kernel to use the
> same partition as the root device, e.g.:
> 
> part uuid ${devtype} ${devnum}:${rootpart} uuid
> setenv bootargs root=PARTUUID=${uuid} ...
> 
> It is expected that further part sub-commands will be added later, e.g.
> to find which partition on a disk is marked bootable, to write new
> partition tables to disk, etc.

A list command would be useful and would be better located here than
under scsi or other interface commands. Perhaps instead of printing a
single part uuid, you should make a list command that prints all
partitions and their UUIDs. That would address my first question.

Rob

> 
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---
> v2: validate that CONFIG_PARTITION_UUID is defined when CONFIG_CMD_PART is
> 
> Note: If Rob Herring's proposed patch "disk/part: introduce
> get_device_and_partition" is applied, the body of do_partuuid() should
> be reworked to use Rob's new function get_device_and_partition().
> ---
>  common/Makefile   |    1 +
>  common/cmd_part.c |  104 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 105 insertions(+), 0 deletions(-)
>  create mode 100644 common/cmd_part.c
> 
> diff --git a/common/Makefile b/common/Makefile
> index 3d62775..449b390 100644
> --- a/common/Makefile
> +++ b/common/Makefile
> @@ -129,6 +129,7 @@ COBJS-$(CONFIG_CMD_NAND) += cmd_nand.o
>  COBJS-$(CONFIG_CMD_NET) += cmd_net.o
>  COBJS-$(CONFIG_CMD_ONENAND) += cmd_onenand.o
>  COBJS-$(CONFIG_CMD_OTP) += cmd_otp.o
> +COBJS-$(CONFIG_CMD_PART) += cmd_part.o
>  ifdef CONFIG_PCI
>  COBJS-$(CONFIG_CMD_PCI) += cmd_pci.o
>  endif
> diff --git a/common/cmd_part.c b/common/cmd_part.c
> new file mode 100644
> index 0000000..1b15ae9
> --- /dev/null
> +++ b/common/cmd_part.c
> @@ -0,0 +1,104 @@
> +/*
> + * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
> + *
> + * made from cmd_ext2, which was:
> + *
> + * (C) Copyright 2004
> + * esd gmbh <www.esd-electronics.com>
> + * Reinhard Arlt <reinhard.arlt@esd-electronics.com>
> + *
> + * made from cmd_reiserfs by
> + *
> + * (C) Copyright 2003 - 2004
> + * Sysgo Real-Time Solutions, AG <www.elinos.com>
> + * Pavel Bartusek <pba@sysgo.com>
> + *
> + * See file CREDITS for list of people who contributed to this
> + * project.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include <common.h>
> +#include <config.h>
> +#include <command.h>
> +#include <part.h>
> +#include <vsprintf.h>
> +
> +#ifndef CONFIG_PARTITION_UUIDS
> +#error CONFIG_PARTITION_UUIDS must be enabled for CONFIG_CMD_PART to be enabled
> +#endif
> +
> +int do_partuuid(int argc, char * const argv[])
> +{
> +	int dev;
> +	int part;
> +	char *ep;
> +	block_dev_desc_t *dev_desc;
> +	disk_partition_t info;
> +
> +	if (argc < 2)
> +		return CMD_RET_USAGE;
> +	if (argc > 3)
> +		return CMD_RET_USAGE;
> +
> +	dev = (int)simple_strtoul(argv[1], &ep, 16);
> +	dev_desc = get_dev(argv[0], dev);
> +	if (dev_desc == NULL) {
> +		printf("Block device %s %d not supported\n", argv[0], dev);
> +		return 1;
> +	}
> +
> +	if (*ep) {
> +		if (*ep != ':') {
> +			puts("Invalid device; use dev[:part]\n");
> +			return 1;
> +		}
> +		part = (int)simple_strtoul(++ep, NULL, 16);
> +	} else {
> +		part = 1;
> +	}
> +
> +	if (get_partition_info(dev_desc, part, &info)) {
> +		printf("Bad partition %d\n", part);
> +		return 1;
> +	}
> +
> +	if (argc > 2)
> +		setenv(argv[2], info.uuid);
> +	else
> +		printf("%s\n", info.uuid);
> +
> +	return 0;
> +}
> +
> +int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> +{
> +	if (argc < 2)
> +		return CMD_RET_USAGE;
> +
> +	if (!strcmp(argv[1], "uuid"))
> +		return do_partuuid(argc - 2, argv + 2);
> +
> +	return CMD_RET_USAGE;
> +}
> +
> +U_BOOT_CMD(
> +	part,	5,	1,	do_part,
> +	"disk partition related commands",
> +	"part uuid <interface> <dev[:part]>\n"
> +	"    - print partition UUID\n"
> +	"part uuid <interface> <dev[:part]> <varname>\n"
> +	"    - set environment variable to partition UUID"
> +);
>
Tom Rini Sept. 5, 2012, 11:58 p.m. UTC | #2
On Wed, Sep 05, 2012 at 06:51:58PM -0500, Rob Herring wrote:
> On 09/05/2012 05:03 PM, Stephen Warren wrote:
> > From: Stephen Warren <swarren@nvidia.com>
> > 
> > This implements the following:
> > 
> > part uuid mmc 0:1
> >   -> print partition UUID
> > part uuid mmc 0:1 uuid
> >   -> set environment variable to partition UUID
> 
> What's the reason to not always both print out and set the uuid env var?
> 
> Perhaps the env name should be partuuid or part_uuid as you could have
> uuid's for other purposes?
> 
> > 
> > This can be useful when writing a bootcmd which searches all known
> > devices for something bootable, and then wants the kernel to use the
> > same partition as the root device, e.g.:
> > 
> > part uuid ${devtype} ${devnum}:${rootpart} uuid
> > setenv bootargs root=PARTUUID=${uuid} ...
> > 
> > It is expected that further part sub-commands will be added later, e.g.
> > to find which partition on a disk is marked bootable, to write new
> > partition tables to disk, etc.
> 
> A list command would be useful and would be better located here than
> under scsi or other interface commands. Perhaps instead of printing a
> single part uuid, you should make a list command that prints all
> partitions and their UUIDs. That would address my first question.

Sounds like a good idea to me as well.

[snip]
> > Signed-off-by: Stephen Warren <swarren@nvidia.com>
> > ---
> > v2: validate that CONFIG_PARTITION_UUID is defined when CONFIG_CMD_PART is
> > 
> > Note: If Rob Herring's proposed patch "disk/part: introduce
> > get_device_and_partition" is applied, the body of do_partuuid() should
> > be reworked to use Rob's new function get_device_and_partition().

I think the best idea here would be to make the next version just depend
on Rob's series.
Stephen Warren Sept. 6, 2012, 2:38 a.m. UTC | #3
On 09/05/2012 05:51 PM, Rob Herring wrote:
> On 09/05/2012 05:03 PM, Stephen Warren wrote:
>> From: Stephen Warren <swarren@nvidia.com>
>>
>> This implements the following:
>>
>> part uuid mmc 0:1
>>   -> print partition UUID
>> part uuid mmc 0:1 uuid
>>   -> set environment variable to partition UUID
> 
> What's the reason to not always both print out and set the uuid env var?
> 
> Perhaps the env name should be partuuid or part_uuid as you could have
> uuid's for other purposes?

The idea is that if you're running the command interactively, you won't
pass a variable name on the command-line, so the command will print out
the UUID for you to read. In this case, it's pointless to set any
environment variable.

However, if you're writing a script, you want to capture the UUID into
an environment variable, and it's quite unlikely you want to litter
stdout with that content too. Hence, either-or, not both.

Note that in the second command above, the final parameter "uuid" is the
environment variable name, so you can save as many UUIDs for different
partitions into whatever variables you want; IIRC in the scripts I wrote
to use this, I did name the variable root_uuid or somesuch.

>> This can be useful when writing a bootcmd which searches all known
>> devices for something bootable, and then wants the kernel to use the
>> same partition as the root device, e.g.:
>>
>> part uuid ${devtype} ${devnum}:${rootpart} uuid
>> setenv bootargs root=PARTUUID=${uuid} ...
>>
>> It is expected that further part sub-commands will be added later, e.g.
>> to find which partition on a disk is marked bootable, to write new
>> partition tables to disk, etc.
> 
> A list command would be useful and would be better located here than
> under scsi or other interface commands. Perhaps instead of printing a
> single part uuid, you should make a list command that prints all
> partitions and their UUIDs. That would address my first question.

Yes, I wondered about "part list mmc 0", which would do essentially the
same thing as e.g. "mmc dev 0; mmc part", and also expanding the
partition printing functions to dump extra information, such as GPT's
partition type UUID, partition UUID, and attributes.
Tom Rini Sept. 6, 2012, 5:12 p.m. UTC | #4
On Wed, Sep 05, 2012 at 08:38:26PM -0600, Stephen Warren wrote:
> On 09/05/2012 05:51 PM, Rob Herring wrote:
> > On 09/05/2012 05:03 PM, Stephen Warren wrote:
> >> From: Stephen Warren <swarren@nvidia.com>
> >>
> >> This implements the following:
> >>
> >> part uuid mmc 0:1
> >>   -> print partition UUID
> >> part uuid mmc 0:1 uuid
> >>   -> set environment variable to partition UUID
> > 
> > What's the reason to not always both print out and set the uuid env var?
> > 
> > Perhaps the env name should be partuuid or part_uuid as you could have
> > uuid's for other purposes?
> 
> The idea is that if you're running the command interactively, you won't
> pass a variable name on the command-line, so the command will print out
> the UUID for you to read. In this case, it's pointless to set any
> environment variable.
> 
> However, if you're writing a script, you want to capture the UUID into
> an environment variable, and it's quite unlikely you want to litter
> stdout with that content too. Hence, either-or, not both.

Do other commands have a "I'm being scripted, probably, don't stdout"
and "I'm being interactive, use stdout" distinction like this?  IMHO,
always printing out makes sense so you can "see" that your script is
working as you expect.
Stephen Warren Sept. 6, 2012, 6:46 p.m. UTC | #5
On 09/06/2012 11:12 AM, Tom Rini wrote:
> On Wed, Sep 05, 2012 at 08:38:26PM -0600, Stephen Warren wrote:
>> On 09/05/2012 05:51 PM, Rob Herring wrote:
>>> On 09/05/2012 05:03 PM, Stephen Warren wrote:
>>>> From: Stephen Warren <swarren@nvidia.com>
>>>>
>>>> This implements the following:
>>>>
>>>> part uuid mmc 0:1
>>>>   -> print partition UUID
>>>> part uuid mmc 0:1 uuid
>>>>   -> set environment variable to partition UUID
>>>
>>> What's the reason to not always both print out and set the uuid env var?
>>>
>>> Perhaps the env name should be partuuid or part_uuid as you could have
>>> uuid's for other purposes?
>>
>> The idea is that if you're running the command interactively, you won't
>> pass a variable name on the command-line, so the command will print out
>> the UUID for you to read. In this case, it's pointless to set any
>> environment variable.
>>
>> However, if you're writing a script, you want to capture the UUID into
>> an environment variable, and it's quite unlikely you want to litter
>> stdout with that content too. Hence, either-or, not both.
> 
> Do other commands have a "I'm being scripted, probably, don't stdout"
> and "I'm being interactive, use stdout" distinction like this?  IMHO,
> always printing out makes sense so you can "see" that your script is
> working as you expect.

In general, as a script writer, yes you do have the ability to choose.
Typically, I'd write:

part uuid ....

vs.

var=`part uuid ....`

in order to control this. However, U-Boot's shell doesn't support
backticks. As a script writer, I certainly desire the ability to control
what commands spam to the console, and really don't think it's useful to
print the UUID from a script (does the user really care, and any script
developer can just echo it for debugging if they need it).

I'm not aware of other U-Boot commands whose purpose it is to set
environment variables, so can't really compare.

Still, if you're insistent on this point, I can change the code to
always print, and optionally write an environment variable.
Tom Rini Sept. 6, 2012, 10:45 p.m. UTC | #6
On 09/06/2012 11:46 AM, Stephen Warren wrote:
> On 09/06/2012 11:12 AM, Tom Rini wrote:
>> On Wed, Sep 05, 2012 at 08:38:26PM -0600, Stephen Warren wrote:
>>> On 09/05/2012 05:51 PM, Rob Herring wrote:
>>>> On 09/05/2012 05:03 PM, Stephen Warren wrote:
>>>>> From: Stephen Warren <swarren@nvidia.com>
>>>>>
>>>>> This implements the following:
>>>>>
>>>>> part uuid mmc 0:1
>>>>>   -> print partition UUID
>>>>> part uuid mmc 0:1 uuid
>>>>>   -> set environment variable to partition UUID
>>>>
>>>> What's the reason to not always both print out and set the uuid env var?
>>>>
>>>> Perhaps the env name should be partuuid or part_uuid as you could have
>>>> uuid's for other purposes?
>>>
>>> The idea is that if you're running the command interactively, you won't
>>> pass a variable name on the command-line, so the command will print out
>>> the UUID for you to read. In this case, it's pointless to set any
>>> environment variable.
>>>
>>> However, if you're writing a script, you want to capture the UUID into
>>> an environment variable, and it's quite unlikely you want to litter
>>> stdout with that content too. Hence, either-or, not both.
>>
>> Do other commands have a "I'm being scripted, probably, don't stdout"
>> and "I'm being interactive, use stdout" distinction like this?  IMHO,
>> always printing out makes sense so you can "see" that your script is
>> working as you expect.
> 
> In general, as a script writer, yes you do have the ability to choose.
> Typically, I'd write:
> 
> part uuid ....
> 
> vs.
> 
> var=`part uuid ....`
> 
> in order to control this. However, U-Boot's shell doesn't support
> backticks. As a script writer, I certainly desire the ability to control
> what commands spam to the console, and really don't think it's useful to
> print the UUID from a script (does the user really care, and any script
> developer can just echo it for debugging if they need it).
> 
> I'm not aware of other U-Boot commands whose purpose it is to set
> environment variables, so can't really compare.
> 
> Still, if you're insistent on this point, I can change the code to
> always print, and optionally write an environment variable.

No, you make a good point.  Thanks!
Stephen Warren Sept. 7, 2012, 7:42 p.m. UTC | #7
On 09/05/2012 05:58 PM, Tom Rini wrote:
> On Wed, Sep 05, 2012 at 06:51:58PM -0500, Rob Herring wrote:
>> On 09/05/2012 05:03 PM, Stephen Warren wrote:
>>> From: Stephen Warren <swarren@nvidia.com>
>>>
>>> This implements the following:
>>>
>>> part uuid mmc 0:1
>>>   -> print partition UUID
>>> part uuid mmc 0:1 uuid
>>>   -> set environment variable to partition UUID
>>
>> What's the reason to not always both print out and set the uuid env var?
>>
>> Perhaps the env name should be partuuid or part_uuid as you could have
>> uuid's for other purposes?
>>
>>>
>>> This can be useful when writing a bootcmd which searches all known
>>> devices for something bootable, and then wants the kernel to use the
>>> same partition as the root device, e.g.:
>>>
>>> part uuid ${devtype} ${devnum}:${rootpart} uuid
>>> setenv bootargs root=PARTUUID=${uuid} ...
>>>
>>> It is expected that further part sub-commands will be added later, e.g.
>>> to find which partition on a disk is marked bootable, to write new
>>> partition tables to disk, etc.
>>
>> A list command would be useful and would be better located here than
>> under scsi or other interface commands. Perhaps instead of printing a
>> single part uuid, you should make a list command that prints all
>> partitions and their UUIDs. That would address my first question.
> 
> Sounds like a good idea to me as well.

In order to avoid too much feature creep in this patch-set, would it be
OK to implement a "part list" command that simply calls print_part(),
without changing what print_part() does right now, and then later send
patches to enhance print_part() to print the various partition UUIDs and
attributes?

>>> v2: validate that CONFIG_PARTITION_UUID is defined when CONFIG_CMD_PART is
>>>
>>> Note: If Rob Herring's proposed patch "disk/part: introduce
>>> get_device_and_partition" is applied, the body of do_partuuid() should
>>> be reworked to use Rob's new function get_device_and_partition().
> 
> I think the best idea here would be to make the next version just depend
> on Rob's series.

OK. Is it fairly certain that Rob's patches will be accepted then? There
hasn't been much feedback on them...

Rob, it sounds like we agreed to change the default partition
specification to use "auto" to mean "select a default partition". Were
you going to repost for that, or do you want me to make the modifications?

Thanks.
Stephen Warren Sept. 11, 2012, 10:52 p.m. UTC | #8
On 09/05/2012 05:58 PM, Tom Rini wrote:
> On Wed, Sep 05, 2012 at 06:51:58PM -0500, Rob Herring wrote:
>> On 09/05/2012 05:03 PM, Stephen Warren wrote:
>>> From: Stephen Warren <swarren@nvidia.com>
>>>
>>> This implements the following:
>>>
>>> part uuid mmc 0:1
>>>   -> print partition UUID
>>> part uuid mmc 0:1 uuid
>>>   -> set environment variable to partition UUID
>>
>> What's the reason to not always both print out and set the uuid env var?
>>
>> Perhaps the env name should be partuuid or part_uuid as you could have
>> uuid's for other purposes?
>>
>>>
>>> This can be useful when writing a bootcmd which searches all known
>>> devices for something bootable, and then wants the kernel to use the
>>> same partition as the root device, e.g.:
>>>
>>> part uuid ${devtype} ${devnum}:${rootpart} uuid
>>> setenv bootargs root=PARTUUID=${uuid} ...
>>>
>>> It is expected that further part sub-commands will be added later, e.g.
>>> to find which partition on a disk is marked bootable, to write new
>>> partition tables to disk, etc.
>>
>> A list command would be useful and would be better located here than
>> under scsi or other interface commands. Perhaps instead of printing a
>> single part uuid, you should make a list command that prints all
>> partitions and their UUIDs. That would address my first question.
> 
> Sounds like a good idea to me as well.
> 
> [snip]
>>> Signed-off-by: Stephen Warren <swarren@nvidia.com>
>>> ---
>>> v2: validate that CONFIG_PARTITION_UUID is defined when CONFIG_CMD_PART is
>>>
>>> Note: If Rob Herring's proposed patch "disk/part: introduce
>>> get_device_and_partition" is applied, the body of do_partuuid() should
>>> be reworked to use Rob's new function get_device_and_partition().
> 
> I think the best idea here would be to make the next version just depend
> on Rob's series.

Tom,

Rob's series depends on Wolfgang(?)'s u-boot/ext4 branch at present. I'm
not sure what the status of that branch is right now - is it something
that's ready to be submitted, or is more work there needed, so the
branch won't be pulled into u-boot/master in the near future? I'm mainly
asking so Rob and I know if Rob's patches should be rebased first onto
something else, before I rebase my patches on his.

Thanks.
Ɓukasz Majewski Sept. 12, 2012, 7 a.m. UTC | #9
Hi Stephen, Tom,


> Rob's series depends on Wolfgang(?)'s u-boot/ext4 branch at present.
> I'm not sure what the status of that branch is right now - is it
> something that's ready to be submitted, or is more work there needed,
> so the branch won't be pulled into u-boot/master in the near future?
> I'm mainly asking so Rob and I know if Rob's patches should be
> rebased first onto something else, before I rebase my patches on his.
> 
> Thanks.

I'd also like to know if those patches will be accepted soon. I'm
working on a GPT restoration support and those patches might be a
pre-requisite for my development (if were pulled into u-boot/master).
Tom Rini Sept. 12, 2012, 4:47 p.m. UTC | #10
On 09/11/2012 03:52 PM, Stephen Warren wrote:
> On 09/05/2012 05:58 PM, Tom Rini wrote:
>> On Wed, Sep 05, 2012 at 06:51:58PM -0500, Rob Herring wrote:
>>> On 09/05/2012 05:03 PM, Stephen Warren wrote:
>>>> From: Stephen Warren <swarren@nvidia.com>
>>>>
>>>> This implements the following:
>>>>
>>>> part uuid mmc 0:1
>>>>   -> print partition UUID
>>>> part uuid mmc 0:1 uuid
>>>>   -> set environment variable to partition UUID
>>>
>>> What's the reason to not always both print out and set the uuid env var?
>>>
>>> Perhaps the env name should be partuuid or part_uuid as you could have
>>> uuid's for other purposes?
>>>
>>>>
>>>> This can be useful when writing a bootcmd which searches all known
>>>> devices for something bootable, and then wants the kernel to use the
>>>> same partition as the root device, e.g.:
>>>>
>>>> part uuid ${devtype} ${devnum}:${rootpart} uuid
>>>> setenv bootargs root=PARTUUID=${uuid} ...
>>>>
>>>> It is expected that further part sub-commands will be added later, e.g.
>>>> to find which partition on a disk is marked bootable, to write new
>>>> partition tables to disk, etc.
>>>
>>> A list command would be useful and would be better located here than
>>> under scsi or other interface commands. Perhaps instead of printing a
>>> single part uuid, you should make a list command that prints all
>>> partitions and their UUIDs. That would address my first question.
>>
>> Sounds like a good idea to me as well.
>>
>> [snip]
>>>> Signed-off-by: Stephen Warren <swarren@nvidia.com>
>>>> ---
>>>> v2: validate that CONFIG_PARTITION_UUID is defined when CONFIG_CMD_PART is
>>>>
>>>> Note: If Rob Herring's proposed patch "disk/part: introduce
>>>> get_device_and_partition" is applied, the body of do_partuuid() should
>>>> be reworked to use Rob's new function get_device_and_partition().
>>
>> I think the best idea here would be to make the next version just depend
>> on Rob's series.
> 
> Tom,
> 
> Rob's series depends on Wolfgang(?)'s u-boot/ext4 branch at present. I'm
> not sure what the status of that branch is right now - is it something
> that's ready to be submitted, or is more work there needed, so the
> branch won't be pulled into u-boot/master in the near future? I'm mainly
> asking so Rob and I know if Rob's patches should be rebased first onto
> something else, before I rebase my patches on his.

So, I want the ext4 work to make it into the next release.  At this
point I am aware there is an issue with large volumes but I need to
research a little more and make sure it's localized to ext4 only.  If
so, my feeling is that it's good enough to start with and then yes, it
will get merged to master, around -rc1 time.
Tom Rini Sept. 12, 2012, 4:48 p.m. UTC | #11
On 09/12/2012 12:00 AM, Lukasz Majewski wrote:
> Hi Stephen, Tom,
> 
> 
>> Rob's series depends on Wolfgang(?)'s u-boot/ext4 branch at present.
>> I'm not sure what the status of that branch is right now - is it
>> something that's ready to be submitted, or is more work there needed,
>> so the branch won't be pulled into u-boot/master in the near future?
>> I'm mainly asking so Rob and I know if Rob's patches should be
>> rebased first onto something else, before I rebase my patches on his.
>>
>> Thanks.
> 
> I'd also like to know if those patches will be accepted soon. I'm
> working on a GPT restoration support and those patches might be a
> pre-requisite for my development (if were pulled into u-boot/master).

In short, yes, merged to master.  In longer form, please see the other
email I just sent in this thread.
diff mbox

Patch

diff --git a/common/Makefile b/common/Makefile
index 3d62775..449b390 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -129,6 +129,7 @@  COBJS-$(CONFIG_CMD_NAND) += cmd_nand.o
 COBJS-$(CONFIG_CMD_NET) += cmd_net.o
 COBJS-$(CONFIG_CMD_ONENAND) += cmd_onenand.o
 COBJS-$(CONFIG_CMD_OTP) += cmd_otp.o
+COBJS-$(CONFIG_CMD_PART) += cmd_part.o
 ifdef CONFIG_PCI
 COBJS-$(CONFIG_CMD_PCI) += cmd_pci.o
 endif
diff --git a/common/cmd_part.c b/common/cmd_part.c
new file mode 100644
index 0000000..1b15ae9
--- /dev/null
+++ b/common/cmd_part.c
@@ -0,0 +1,104 @@ 
+/*
+ * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
+ *
+ * made from cmd_ext2, which was:
+ *
+ * (C) Copyright 2004
+ * esd gmbh <www.esd-electronics.com>
+ * Reinhard Arlt <reinhard.arlt@esd-electronics.com>
+ *
+ * made from cmd_reiserfs by
+ *
+ * (C) Copyright 2003 - 2004
+ * Sysgo Real-Time Solutions, AG <www.elinos.com>
+ * Pavel Bartusek <pba@sysgo.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <common.h>
+#include <config.h>
+#include <command.h>
+#include <part.h>
+#include <vsprintf.h>
+
+#ifndef CONFIG_PARTITION_UUIDS
+#error CONFIG_PARTITION_UUIDS must be enabled for CONFIG_CMD_PART to be enabled
+#endif
+
+int do_partuuid(int argc, char * const argv[])
+{
+	int dev;
+	int part;
+	char *ep;
+	block_dev_desc_t *dev_desc;
+	disk_partition_t info;
+
+	if (argc < 2)
+		return CMD_RET_USAGE;
+	if (argc > 3)
+		return CMD_RET_USAGE;
+
+	dev = (int)simple_strtoul(argv[1], &ep, 16);
+	dev_desc = get_dev(argv[0], dev);
+	if (dev_desc == NULL) {
+		printf("Block device %s %d not supported\n", argv[0], dev);
+		return 1;
+	}
+
+	if (*ep) {
+		if (*ep != ':') {
+			puts("Invalid device; use dev[:part]\n");
+			return 1;
+		}
+		part = (int)simple_strtoul(++ep, NULL, 16);
+	} else {
+		part = 1;
+	}
+
+	if (get_partition_info(dev_desc, part, &info)) {
+		printf("Bad partition %d\n", part);
+		return 1;
+	}
+
+	if (argc > 2)
+		setenv(argv[2], info.uuid);
+	else
+		printf("%s\n", info.uuid);
+
+	return 0;
+}
+
+int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	if (argc < 2)
+		return CMD_RET_USAGE;
+
+	if (!strcmp(argv[1], "uuid"))
+		return do_partuuid(argc - 2, argv + 2);
+
+	return CMD_RET_USAGE;
+}
+
+U_BOOT_CMD(
+	part,	5,	1,	do_part,
+	"disk partition related commands",
+	"part uuid <interface> <dev[:part]>\n"
+	"    - print partition UUID\n"
+	"part uuid <interface> <dev[:part]> <varname>\n"
+	"    - set environment variable to partition UUID"
+);