All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] gpt: add part-uuid and part-num subcommands
@ 2017-11-08  0:43 your name
  2017-11-08 10:47 ` Otavio Salvador
  0 siblings, 1 reply; 16+ messages in thread
From: your name @ 2017-11-08  0:43 UTC (permalink / raw)
  To: u-boot

From: Andrey Yurovsky <yurovsky@gmail.com>

It is useful to be able to retrieve a partition UUID or number given
the partition label, for instance some systems use the partition label
to indicate the purpose of the partition (such as "rootfs0" being the
0th root file system in an A/B image scheme).

Add "gpt part-uuid" to retrieve the partition UUID for a given label and
"gpt part-num" to retrieve the partition number for a given label along
with some documentation.

Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
---
 cmd/gpt.c      | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 doc/README.gpt | 21 ++++++++++++++++++
 2 files changed, 88 insertions(+)

diff --git a/cmd/gpt.c b/cmd/gpt.c
index 707d861766..bef292230e 100644
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -355,6 +355,64 @@ static int do_get_gpt_info(struct blk_desc *dev_desc)
 	}
 	return ret;
 }
+
+static struct disk_part *find_part_by_label(const char *label)
+{
+	struct disk_part *part = NULL;
+	struct disk_part *curr;
+
+	list_for_each_entry(curr, &disk_partitions, list) {
+		/* Check for the first match of the label we're looking
+		 * for against the partition label */
+		if (!strcmp((const char*)curr->gpt_part_info.name,
+					label)) {
+			part = curr;
+			break;
+		}
+	}
+
+	return part;
+}
+
+/* Find a partition UUID by label and save that UUID to the environment
+ * variable specified */
+static int do_get_part_uuid(struct blk_desc *dev_desc, const char *label,
+		const char *namestr)
+{
+	int ret;
+
+	ret = get_gpt_info(dev_desc);
+	if (ret > 0) {
+		struct disk_part *part = find_part_by_label(label);
+		if (part) {
+			env_set(namestr, part->gpt_part_info.uuid);
+			ret = 0;
+		}
+
+		del_gpt_info();
+	}
+
+	return ret;
+}
+
+/* Find a partition number by label and save that number to the environment
+ * variable specified */
+static int do_get_part_num(struct blk_desc *dev_desc, const char *label,
+		const char *namestr)
+{
+	int ret = get_gpt_info(dev_desc);
+	if (ret > 0) {
+		struct disk_part *part = find_part_by_label(label);
+		if (part) {
+			env_set_ulong(namestr, part->partnum);
+			ret = 0;
+		}
+
+		del_gpt_info();
+	}
+
+	return ret;
+}
 #endif
 
 /**
@@ -851,6 +909,10 @@ static int do_gpt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 #ifdef CONFIG_CMD_GPT_RENAME
 	} else if (strcmp(argv[1], "read") == 0) {
 		ret = do_get_gpt_info(blk_dev_desc);
+	} else if (strcmp(argv[1], "part-uuid") == 0 && argc == 6) {
+		ret = do_get_part_uuid(blk_dev_desc, argv[4], argv[5]);
+	} else if (strcmp(argv[1], "part-num") == 0 && argc == 6) {
+		ret = do_get_part_num(blk_dev_desc, argv[4], argv[5]);
 	} else if ((strcmp(argv[1], "swap") == 0) ||
 		   (strcmp(argv[1], "rename") == 0)) {
 		ret = do_rename_gpt_parts(blk_dev_desc, argv[1], argv[4], argv[5]);
@@ -887,6 +949,11 @@ U_BOOT_CMD(gpt, CONFIG_SYS_MAXARGS, 1, do_gpt,
 	" gpt guid mmc 0\n"
 	" gpt guid mmc 0 varname\n"
 #ifdef CONFIG_CMD_GPT_RENAME
+	"gpt partition label commands:\n"
+	"gpt part-uuid <interface> <dev> <label> <varname>\n"
+	"    - set environment variable to UUID of label\n"
+	"gpt part-num <interface> <dev> <label> <varname>\n"
+	"    - set environment variable to partition number of label\n"
 	"gpt partition renaming commands:\n"
 	"gpt swap <interface> <dev> <name1> <name2>\n"
 	"    - change all partitions named name1 to name2\n"
diff --git a/doc/README.gpt b/doc/README.gpt
index d3db8bce1c..edb99b6c68 100644
--- a/doc/README.gpt
+++ b/doc/README.gpt
@@ -275,6 +275,27 @@ Some strings can be also used at the place of known GUID :
 
 They are also used to display the type of partition in "part list" command.
 
+Identifying Partitions in U-Boot:
+=================================
+
+Two subcommands may be used to identify partitions by their label. This can be
+useful for determining which partition to use or for setting boot arguments.
+The 'gpt part-uuid' command looks up a partition UUID for a given label and
+stores it in an environment variable. The 'gpt part-num' command looks up a
+partition number for a given label and stores it in an environment variable.
+The first partition with a matching label is used.
+
+For example, to find the UUID of a partition named 'rootfs0' and then use it
+for boot arguments:
+
+U-BOOT> gpt part-uuid mmc 0 rootfs0 rootfsuuid
+U-BOOT> setenv bootargs root=PARTUUID=${rootfsuuid}
+
+Or, for example, to find the partition number for a partition named 'kernel'
+and load a file from it:
+
+U-BOOT> gpt part-num mmc 0 kernel kernelnum
+U-BOOT> fatload mmc 0:${kernelnum} ${loadaddr} zImage
 
 Useful info:
 ============
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH] gpt: add part-uuid and part-num subcommands
  2017-11-08  0:43 [U-Boot] [PATCH] gpt: add part-uuid and part-num subcommands your name
@ 2017-11-08 10:47 ` Otavio Salvador
  2017-11-08 17:10   ` Andrey Yurovsky
  2017-11-08 17:16   ` Andrey Yurovsky
  0 siblings, 2 replies; 16+ messages in thread
From: Otavio Salvador @ 2017-11-08 10:47 UTC (permalink / raw)
  To: u-boot

On Tue, Nov 7, 2017 at 10:43 PM, your name <yurovsky@gmail.com> wrote:
> From: Andrey Yurovsky <yurovsky@gmail.com>
>
> It is useful to be able to retrieve a partition UUID or number given
> the partition label, for instance some systems use the partition label
> to indicate the purpose of the partition (such as "rootfs0" being the
> 0th root file system in an A/B image scheme).
>
> Add "gpt part-uuid" to retrieve the partition UUID for a given label and
> "gpt part-num" to retrieve the partition number for a given label along
> with some documentation.
>
> Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>

Why not use the 'part' cmd? it provides it.


-- 
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH] gpt: add part-uuid and part-num subcommands
  2017-11-08 10:47 ` Otavio Salvador
@ 2017-11-08 17:10   ` Andrey Yurovsky
  2017-11-09  9:55     ` Lukasz Majewski
  2017-11-08 17:16   ` Andrey Yurovsky
  1 sibling, 1 reply; 16+ messages in thread
From: Andrey Yurovsky @ 2017-11-08 17:10 UTC (permalink / raw)
  To: u-boot

Hi Otavio,

On Wed, Nov 8, 2017 at 2:47 AM, Otavio Salvador
<otavio.salvador@ossystems.com.br> wrote:
> On Tue, Nov 7, 2017 at 10:43 PM, your name <yurovsky@gmail.com> wrote:
>> From: Andrey Yurovsky <yurovsky@gmail.com>
>>
>> It is useful to be able to retrieve a partition UUID or number given
>> the partition label, for instance some systems use the partition label
>> to indicate the purpose of the partition (such as "rootfs0" being the
>> 0th root file system in an A/B image scheme).
>>
>> Add "gpt part-uuid" to retrieve the partition UUID for a given label and
>> "gpt part-num" to retrieve the partition number for a given label along
>> with some documentation.
>>
>> Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
>
> Why not use the 'part' cmd? it provides it.

Sorry, I missed the part cmd, it doesn't seem to be documented in doc/
and it's unclear what <dev> means there. I'll investigate and see if I
can use it for what I'm trying to do, it looks like it should work.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH] gpt: add part-uuid and part-num subcommands
  2017-11-08 10:47 ` Otavio Salvador
  2017-11-08 17:10   ` Andrey Yurovsky
@ 2017-11-08 17:16   ` Andrey Yurovsky
  2017-11-08 18:05     ` Otavio Salvador
  1 sibling, 1 reply; 16+ messages in thread
From: Andrey Yurovsky @ 2017-11-08 17:16 UTC (permalink / raw)
  To: u-boot

On Wed, Nov 8, 2017 at 2:47 AM Otavio Salvador <
otavio.salvador@ossystems.com.br> wrote:

> On Tue, Nov 7, 2017 at 10:43 PM, your name <yurovsky@gmail.com> wrote:
> > From: Andrey Yurovsky <yurovsky@gmail.com>
> >
> > It is useful to be able to retrieve a partition UUID or number given
> > the partition label, for instance some systems use the partition label
> > to indicate the purpose of the partition (such as "rootfs0" being the
> > 0th root file system in an A/B image scheme).
> >
> > Add "gpt part-uuid" to retrieve the partition UUID for a given label and
> > "gpt part-num" to retrieve the partition number for a given label along
> > with some documentation.
> >
> > Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
>
> Why not use the 'part' cmd? it provides it.
>

The use case is, given a label, find the UUID and/or the partition number.
I see that 'part' can give me the UUID if I knew the partition number, it
can print the whole table (but I don't think I can use that output
cleanly), and it can list the partition numbers. I don't think I can solve
my problem with 'part' as-is unless I have missed something.

If that's the case would it be alright to add these subcommands to 'part'?
Thank you again,

 -Andrey

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH] gpt: add part-uuid and part-num subcommands
  2017-11-08 17:16   ` Andrey Yurovsky
@ 2017-11-08 18:05     ` Otavio Salvador
  0 siblings, 0 replies; 16+ messages in thread
From: Otavio Salvador @ 2017-11-08 18:05 UTC (permalink / raw)
  To: u-boot

On Wed, Nov 8, 2017 at 3:16 PM, Andrey Yurovsky <yurovsky@gmail.com> wrote:
> On Wed, Nov 8, 2017 at 2:47 AM Otavio Salvador
> <otavio.salvador@ossystems.com.br> wrote:
>>
>> On Tue, Nov 7, 2017 at 10:43 PM, your name <yurovsky@gmail.com> wrote:
>> > From: Andrey Yurovsky <yurovsky@gmail.com>
>> >
>> > It is useful to be able to retrieve a partition UUID or number given
>> > the partition label, for instance some systems use the partition label
>> > to indicate the purpose of the partition (such as "rootfs0" being the
>> > 0th root file system in an A/B image scheme).
>> >
>> > Add "gpt part-uuid" to retrieve the partition UUID for a given label and
>> > "gpt part-num" to retrieve the partition number for a given label along
>> > with some documentation.
>> >
>> > Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
>>
>> Why not use the 'part' cmd? it provides it.
>
>
> The use case is, given a label, find the UUID and/or the partition number. I
> see that 'part' can give me the UUID if I knew the partition number, it can
> print the whole table (but I don't think I can use that output cleanly), and
> it can list the partition numbers. I don't think I can solve my problem with
> 'part' as-is unless I have missed something.
>
> If that's the case would it be alright to add these subcommands to 'part'?
> Thank you again,

It looks to be the best approach for me.

-- 
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH] gpt: add part-uuid and part-num subcommands
  2017-11-08 17:10   ` Andrey Yurovsky
@ 2017-11-09  9:55     ` Lukasz Majewski
  2017-11-09 15:34       ` Andrey Yurovsky
  0 siblings, 1 reply; 16+ messages in thread
From: Lukasz Majewski @ 2017-11-09  9:55 UTC (permalink / raw)
  To: u-boot

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="windows-1254", Size: 1623 bytes --]

Hi Andrey,

> Hi Otavio,
> 
> On Wed, Nov 8, 2017 at 2:47 AM, Otavio Salvador
> <otavio.salvador@ossystems.com.br> wrote:
> > On Tue, Nov 7, 2017 at 10:43 PM, your name <yurovsky@gmail.com>
> > wrote:  
> >> From: Andrey Yurovsky <yurovsky@gmail.com>
> >>
> >> It is useful to be able to retrieve a partition UUID or number
> >> given the partition label, for instance some systems use the
> >> partition label to indicate the purpose of the partition (such as
> >> "rootfs0" being the 0th root file system in an A/B image scheme).
> >>
> >> Add "gpt part-uuid" to retrieve the partition UUID for a given
> >> label and "gpt part-num" to retrieve the partition number for a
> >> given label along with some documentation.
> >>
> >> Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>  
> >
> > Why not use the 'part' cmd? it provides it.  
> 
> Sorry, I missed the part cmd, it doesn't seem to be documented in doc/
> and it's unclear what <dev> means there.

If I may ask - Andrey, if you are now on this "topic" - would you dare
to add some ./doc entry for 'part' command?

> I'll investigate and see if I
> can use it for what I'm trying to do, it looks like it should work.
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot



-- 
Best regards,

Łukasz Majewski
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171109/ff9876a7/attachment.sig>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH] gpt: add part-uuid and part-num subcommands
  2017-11-09  9:55     ` Lukasz Majewski
@ 2017-11-09 15:34       ` Andrey Yurovsky
  2017-11-09 22:28         ` Lukasz Majewski
  0 siblings, 1 reply; 16+ messages in thread
From: Andrey Yurovsky @ 2017-11-09 15:34 UTC (permalink / raw)
  To: u-boot

On Thu, Nov 9, 2017 at 1:55 AM, Lukasz Majewski <l.majewski@majess.pl> wrote:
> Hi Andrey,
>
>> Hi Otavio,
>>
>> On Wed, Nov 8, 2017 at 2:47 AM, Otavio Salvador
>> <otavio.salvador@ossystems.com.br> wrote:
>> > On Tue, Nov 7, 2017 at 10:43 PM, your name <yurovsky@gmail.com>
>> > wrote:
>> >> From: Andrey Yurovsky <yurovsky@gmail.com>
>> >>
>> >> It is useful to be able to retrieve a partition UUID or number
>> >> given the partition label, for instance some systems use the
>> >> partition label to indicate the purpose of the partition (such as
>> >> "rootfs0" being the 0th root file system in an A/B image scheme).
>> >>
>> >> Add "gpt part-uuid" to retrieve the partition UUID for a given
>> >> label and "gpt part-num" to retrieve the partition number for a
>> >> given label along with some documentation.
>> >>
>> >> Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
>> >
>> > Why not use the 'part' cmd? it provides it.
>>
>> Sorry, I missed the part cmd, it doesn't seem to be documented in doc/
>> and it's unclear what <dev> means there.
>
> If I may ask - Andrey, if you are now on this "topic" - would you dare
> to add some ./doc entry for 'part' command?

Yes, I will do that.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH] gpt: add part-uuid and part-num subcommands
  2017-11-09 15:34       ` Andrey Yurovsky
@ 2017-11-09 22:28         ` Lukasz Majewski
  2017-11-11 20:39           ` Andrey Yurovsky
  0 siblings, 1 reply; 16+ messages in thread
From: Lukasz Majewski @ 2017-11-09 22:28 UTC (permalink / raw)
  To: u-boot

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="windows-1254", Size: 1680 bytes --]

On Thu, 9 Nov 2017 07:34:44 -0800
Andrey Yurovsky <yurovsky@gmail.com> wrote:

> On Thu, Nov 9, 2017 at 1:55 AM, Lukasz Majewski
> <l.majewski@majess.pl> wrote:
> > Hi Andrey,
> >  
> >> Hi Otavio,
> >>
> >> On Wed, Nov 8, 2017 at 2:47 AM, Otavio Salvador
> >> <otavio.salvador@ossystems.com.br> wrote:  
> >> > On Tue, Nov 7, 2017 at 10:43 PM, your name <yurovsky@gmail.com>
> >> > wrote:  
> >> >> From: Andrey Yurovsky <yurovsky@gmail.com>
> >> >>
> >> >> It is useful to be able to retrieve a partition UUID or number
> >> >> given the partition label, for instance some systems use the
> >> >> partition label to indicate the purpose of the partition (such
> >> >> as "rootfs0" being the 0th root file system in an A/B image
> >> >> scheme).
> >> >>
> >> >> Add "gpt part-uuid" to retrieve the partition UUID for a given
> >> >> label and "gpt part-num" to retrieve the partition number for a
> >> >> given label along with some documentation.
> >> >>
> >> >> Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>  
> >> >
> >> > Why not use the 'part' cmd? it provides it.  
> >>
> >> Sorry, I missed the part cmd, it doesn't seem to be documented in
> >> doc/ and it's unclear what <dev> means there.  
> >
> > If I may ask - Andrey, if you are now on this "topic" - would you
> > dare to add some ./doc entry for 'part' command?  
> 
> Yes, I will do that.

Thanks :-)

-- 
Best regards,

Łukasz Majewski
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171109/63ae3258/attachment.sig>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH] gpt: add part-uuid and part-num subcommands
  2017-11-09 22:28         ` Lukasz Majewski
@ 2017-11-11 20:39           ` Andrey Yurovsky
  2017-11-14  9:45             ` Lukasz Majewski
  0 siblings, 1 reply; 16+ messages in thread
From: Andrey Yurovsky @ 2017-11-11 20:39 UTC (permalink / raw)
  To: u-boot

Hi Lukasz,

On Thu, Nov 9, 2017 at 2:28 PM, Lukasz Majewski <l.majewski@majess.pl> wrote:
> On Thu, 9 Nov 2017 07:34:44 -0800
> Andrey Yurovsky <yurovsky@gmail.com> wrote:
>
>> On Thu, Nov 9, 2017 at 1:55 AM, Lukasz Majewski
>> <l.majewski@majess.pl> wrote:
>> > Hi Andrey,
>> >
>> >> Hi Otavio,
>> >>
>> >> On Wed, Nov 8, 2017 at 2:47 AM, Otavio Salvador
>> >> <otavio.salvador@ossystems.com.br> wrote:
>> >> > On Tue, Nov 7, 2017 at 10:43 PM, your name <yurovsky@gmail.com>
>> >> > wrote:
>> >> >> From: Andrey Yurovsky <yurovsky@gmail.com>
>> >> >>
>> >> >> It is useful to be able to retrieve a partition UUID or number
>> >> >> given the partition label, for instance some systems use the
>> >> >> partition label to indicate the purpose of the partition (such
>> >> >> as "rootfs0" being the 0th root file system in an A/B image
>> >> >> scheme).
>> >> >>
>> >> >> Add "gpt part-uuid" to retrieve the partition UUID for a given
>> >> >> label and "gpt part-num" to retrieve the partition number for a
>> >> >> given label along with some documentation.
>> >> >>
>> >> >> Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
>> >> >
>> >> > Why not use the 'part' cmd? it provides it.
>> >>
>> >> Sorry, I missed the part cmd, it doesn't seem to be documented in
>> >> doc/ and it's unclear what <dev> means there.
>> >
>> > If I may ask - Andrey, if you are now on this "topic" - would you
>> > dare to add some ./doc entry for 'part' command?
>>
>> Yes, I will do that.
>
> Thanks :-)

On further investigation I am not sure that it's possible to extend
the part command to retrieve UUIDs by label because of the design of
the partition type drivers. Here is how I understand it to work:
1. the "part" command uses part_get_info() and in turn gets a
partition driver and can call print() there (which is how EFI/GPT
disks are printed with "part list"). The right information (including
label) is printed but it's not tied to the caller in any way.
2. "part uuid"  blk_get_device_part_str() which in turn can get
information but referenced by partition number (and only partition
number, due to how part_get_info() works). There's nothing at the
'part' layer tying a label to a number though so one would already
need to know the number, which is the problem I'm trying to solve.

This layering keeps partitioning generalized and decoupled from the
underlying partition "driver" but there's no concept of a label in the
"driver" API. I'm not sure if it's reasonable to extend it since
part_get_info() and similar really don't have a way to map labels at
this layer so perhaps extending the GPT-specific command is the only
reasonable approach?

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH] gpt: add part-uuid and part-num subcommands
  2017-11-11 20:39           ` Andrey Yurovsky
@ 2017-11-14  9:45             ` Lukasz Majewski
  2017-12-04 17:57               ` Andrey Yurovsky
  0 siblings, 1 reply; 16+ messages in thread
From: Lukasz Majewski @ 2017-11-14  9:45 UTC (permalink / raw)
  To: u-boot

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="windows-1254", Size: 3488 bytes --]

Hi Andrey,

> Hi Lukasz,
> 
> On Thu, Nov 9, 2017 at 2:28 PM, Lukasz Majewski
> <l.majewski@majess.pl> wrote:
> > On Thu, 9 Nov 2017 07:34:44 -0800
> > Andrey Yurovsky <yurovsky@gmail.com> wrote:
> >  
> >> On Thu, Nov 9, 2017 at 1:55 AM, Lukasz Majewski
> >> <l.majewski@majess.pl> wrote:  
> >> > Hi Andrey,
> >> >  
> >> >> Hi Otavio,
> >> >>
> >> >> On Wed, Nov 8, 2017 at 2:47 AM, Otavio Salvador
> >> >> <otavio.salvador@ossystems.com.br> wrote:  
> >> >> > On Tue, Nov 7, 2017 at 10:43 PM, your name
> >> >> > <yurovsky@gmail.com> wrote:  
> >> >> >> From: Andrey Yurovsky <yurovsky@gmail.com>
> >> >> >>
> >> >> >> It is useful to be able to retrieve a partition UUID or
> >> >> >> number given the partition label, for instance some systems
> >> >> >> use the partition label to indicate the purpose of the
> >> >> >> partition (such as "rootfs0" being the 0th root file system
> >> >> >> in an A/B image scheme).
> >> >> >>
> >> >> >> Add "gpt part-uuid" to retrieve the partition UUID for a
> >> >> >> given label and "gpt part-num" to retrieve the partition
> >> >> >> number for a given label along with some documentation.
> >> >> >>
> >> >> >> Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>  
> >> >> >
> >> >> > Why not use the 'part' cmd? it provides it.  
> >> >>
> >> >> Sorry, I missed the part cmd, it doesn't seem to be documented
> >> >> in doc/ and it's unclear what <dev> means there.  
> >> >
> >> > If I may ask - Andrey, if you are now on this "topic" - would you
> >> > dare to add some ./doc entry for 'part' command?  
> >>
> >> Yes, I will do that.  
> >
> > Thanks :-)  
> 
> On further investigation I am not sure that it's possible to extend
> the part command to retrieve UUIDs by label because of the design of
> the partition type drivers. Here is how I understand it to work:
> 1. the "part" command uses part_get_info() and in turn gets a
> partition driver and can call print() there (which is how EFI/GPT
> disks are printed with "part list"). The right information (including
> label) is printed but it's not tied to the caller in any way.

Maybe you can set some env variable with proper data?

For example, please refer to ./cmd/part.c do_part_start() function.

Example call from envs (include/configs/display5.h):
	"part start mmc ${mmcdev} ${kernel_part} lba_start; " \

> 2. "part uuid"  blk_get_device_part_str() which in turn can get
> information but referenced by partition number (and only partition
> number, due to how part_get_info() works). There's nothing at the
> 'part' layer tying a label to a number though so one would already
> need to know the number, which is the problem I'm trying to solve.
> 
> This layering keeps partitioning generalized and decoupled from the
> underlying partition "driver" but there's no concept of a label in the
> "driver" API. I'm not sure if it's reasonable to extend it since
> part_get_info() and similar really don't have a way to map labels at
> this layer so perhaps extending the GPT-specific command is the only
> reasonable approach?
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot



-- 
Best regards,

Łukasz Majewski
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171114/9f85a48a/attachment.sig>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH] gpt: add part-uuid and part-num subcommands
  2017-11-14  9:45             ` Lukasz Majewski
@ 2017-12-04 17:57               ` Andrey Yurovsky
  2017-12-04 21:12                 ` Lukasz Majewski
  0 siblings, 1 reply; 16+ messages in thread
From: Andrey Yurovsky @ 2017-12-04 17:57 UTC (permalink / raw)
  To: u-boot

Hi Lukasz,

On Tue, Nov 14, 2017 at 1:45 AM, Lukasz Majewski <l.majewski@majess.pl> wrote:
> Hi Andrey,
>
>> Hi Lukasz,
>>
>> On Thu, Nov 9, 2017 at 2:28 PM, Lukasz Majewski
>> <l.majewski@majess.pl> wrote:
>> > On Thu, 9 Nov 2017 07:34:44 -0800
>> > Andrey Yurovsky <yurovsky@gmail.com> wrote:
>> >
>> >> On Thu, Nov 9, 2017 at 1:55 AM, Lukasz Majewski
>> >> <l.majewski@majess.pl> wrote:
>> >> > Hi Andrey,
>> >> >
>> >> >> Hi Otavio,
>> >> >>
>> >> >> On Wed, Nov 8, 2017 at 2:47 AM, Otavio Salvador
>> >> >> <otavio.salvador@ossystems.com.br> wrote:
>> >> >> > On Tue, Nov 7, 2017 at 10:43 PM, your name
>> >> >> > <yurovsky@gmail.com> wrote:
>> >> >> >> From: Andrey Yurovsky <yurovsky@gmail.com>
>> >> >> >>
>> >> >> >> It is useful to be able to retrieve a partition UUID or
>> >> >> >> number given the partition label, for instance some systems
>> >> >> >> use the partition label to indicate the purpose of the
>> >> >> >> partition (such as "rootfs0" being the 0th root file system
>> >> >> >> in an A/B image scheme).
>> >> >> >>
>> >> >> >> Add "gpt part-uuid" to retrieve the partition UUID for a
>> >> >> >> given label and "gpt part-num" to retrieve the partition
>> >> >> >> number for a given label along with some documentation.
>> >> >> >>
>> >> >> >> Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
>> >> >> >
>> >> >> > Why not use the 'part' cmd? it provides it.
>> >> >>
>> >> >> Sorry, I missed the part cmd, it doesn't seem to be documented
>> >> >> in doc/ and it's unclear what <dev> means there.
>> >> >
>> >> > If I may ask - Andrey, if you are now on this "topic" - would you
>> >> > dare to add some ./doc entry for 'part' command?
>> >>
>> >> Yes, I will do that.
>> >
>> > Thanks :-)
>>
>> On further investigation I am not sure that it's possible to extend
>> the part command to retrieve UUIDs by label because of the design of
>> the partition type drivers. Here is how I understand it to work:
>> 1. the "part" command uses part_get_info() and in turn gets a
>> partition driver and can call print() there (which is how EFI/GPT
>> disks are printed with "part list"). The right information (including
>> label) is printed but it's not tied to the caller in any way.
>
> Maybe you can set some env variable with proper data?
>
> For example, please refer to ./cmd/part.c do_part_start() function.
>
> Example call from envs (include/configs/display5.h):
>         "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
>

Again that assumes the partition is referred to by number, I need it
to be by label, and the part/disk interface does not seem to have any
way to utilize labels. Unfortunately it looks like my original
approach with the gpt command is the only way to implement this with
the current design (at least from what I see here). Please let me know
if I've missed something. Thanks!

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH] gpt: add part-uuid and part-num subcommands
  2017-12-04 17:57               ` Andrey Yurovsky
@ 2017-12-04 21:12                 ` Lukasz Majewski
  2017-12-04 21:48                   ` Andrey Yurovsky
  0 siblings, 1 reply; 16+ messages in thread
From: Lukasz Majewski @ 2017-12-04 21:12 UTC (permalink / raw)
  To: u-boot

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="windows-1254", Size: 3701 bytes --]

Hi Andrey,

> Hi Lukasz,
> 
> On Tue, Nov 14, 2017 at 1:45 AM, Lukasz Majewski
> <l.majewski@majess.pl> wrote:
> > Hi Andrey,
> >  
> >> Hi Lukasz,
> >>
> >> On Thu, Nov 9, 2017 at 2:28 PM, Lukasz Majewski
> >> <l.majewski@majess.pl> wrote:  
> >> > On Thu, 9 Nov 2017 07:34:44 -0800
> >> > Andrey Yurovsky <yurovsky@gmail.com> wrote:
> >> >  
> >> >> On Thu, Nov 9, 2017 at 1:55 AM, Lukasz Majewski
> >> >> <l.majewski@majess.pl> wrote:  
> >> >> > Hi Andrey,
> >> >> >  
> >> >> >> Hi Otavio,
> >> >> >>
> >> >> >> On Wed, Nov 8, 2017 at 2:47 AM, Otavio Salvador
> >> >> >> <otavio.salvador@ossystems.com.br> wrote:  
> >> >> >> > On Tue, Nov 7, 2017 at 10:43 PM, your name
> >> >> >> > <yurovsky@gmail.com> wrote:  
> >> >> >> >> From: Andrey Yurovsky <yurovsky@gmail.com>
> >> >> >> >>
> >> >> >> >> It is useful to be able to retrieve a partition UUID or
> >> >> >> >> number given the partition label, for instance some
> >> >> >> >> systems use the partition label to indicate the purpose
> >> >> >> >> of the partition (such as "rootfs0" being the 0th root
> >> >> >> >> file system in an A/B image scheme).
> >> >> >> >>
> >> >> >> >> Add "gpt part-uuid" to retrieve the partition UUID for a
> >> >> >> >> given label and "gpt part-num" to retrieve the partition
> >> >> >> >> number for a given label along with some documentation.
> >> >> >> >>
> >> >> >> >> Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>  
> >> >> >> >
> >> >> >> > Why not use the 'part' cmd? it provides it.  
> >> >> >>
> >> >> >> Sorry, I missed the part cmd, it doesn't seem to be
> >> >> >> documented in doc/ and it's unclear what <dev> means there.  
> >> >> >
> >> >> > If I may ask - Andrey, if you are now on this "topic" - would
> >> >> > you dare to add some ./doc entry for 'part' command?  
> >> >>
> >> >> Yes, I will do that.  
> >> >
> >> > Thanks :-)  
> >>
> >> On further investigation I am not sure that it's possible to extend
> >> the part command to retrieve UUIDs by label because of the design
> >> of the partition type drivers. Here is how I understand it to work:
> >> 1. the "part" command uses part_get_info() and in turn gets a
> >> partition driver and can call print() there (which is how EFI/GPT
> >> disks are printed with "part list"). The right information
> >> (including label) is printed but it's not tied to the caller in
> >> any way.  
> >
> > Maybe you can set some env variable with proper data?
> >
> > For example, please refer to ./cmd/part.c do_part_start() function.
> >
> > Example call from envs (include/configs/display5.h):
> >         "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
> >  
> 
> Again that assumes the partition is referred to by number, I need it
> to be by label, and the part/disk interface does not seem to have any
> way to utilize labels. Unfortunately it looks like my original
> approach with the gpt command is the only way to implement this with
> the current design (at least from what I see here). Please let me know
> if I've missed something. Thanks!

Please correct me if I'm wrong - you need the starting LBA of the
partition named e.g. "FOO" in gpt ?

Conceptually it would be correct to have:

part start <interface> <dev> <NAME - e.g.'FOO'> <env to set>
gpt start <interface> <dev> <NAME- e.g. 'FOO'> <env to set>

If your code is really _small_ and can be used only with GPT, then lets
go for the second option.

-- 
Best regards,

Łukasz Majewski
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171204/6aa79116/attachment.sig>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH] gpt: add part-uuid and part-num subcommands
  2017-12-04 21:12                 ` Lukasz Majewski
@ 2017-12-04 21:48                   ` Andrey Yurovsky
  2017-12-05 15:10                     ` Lukasz Majewski
  0 siblings, 1 reply; 16+ messages in thread
From: Andrey Yurovsky @ 2017-12-04 21:48 UTC (permalink / raw)
  To: u-boot

On Mon, Dec 4, 2017 at 1:12 PM, Lukasz Majewski <l.majewski@majess.pl> wrote:
> Hi Andrey,
>
>> Hi Lukasz,
>>
>> On Tue, Nov 14, 2017 at 1:45 AM, Lukasz Majewski
>> <l.majewski@majess.pl> wrote:
>> > Hi Andrey,
>> >
>> >> Hi Lukasz,
>> >>
>> >> On Thu, Nov 9, 2017 at 2:28 PM, Lukasz Majewski
>> >> <l.majewski@majess.pl> wrote:
>> >> > On Thu, 9 Nov 2017 07:34:44 -0800
>> >> > Andrey Yurovsky <yurovsky@gmail.com> wrote:
>> >> >
>> >> >> On Thu, Nov 9, 2017 at 1:55 AM, Lukasz Majewski
>> >> >> <l.majewski@majess.pl> wrote:
>> >> >> > Hi Andrey,
>> >> >> >
>> >> >> >> Hi Otavio,
>> >> >> >>
>> >> >> >> On Wed, Nov 8, 2017 at 2:47 AM, Otavio Salvador
>> >> >> >> <otavio.salvador@ossystems.com.br> wrote:
>> >> >> >> > On Tue, Nov 7, 2017 at 10:43 PM, your name
>> >> >> >> > <yurovsky@gmail.com> wrote:
>> >> >> >> >> From: Andrey Yurovsky <yurovsky@gmail.com>
>> >> >> >> >>
>> >> >> >> >> It is useful to be able to retrieve a partition UUID or
>> >> >> >> >> number given the partition label, for instance some
>> >> >> >> >> systems use the partition label to indicate the purpose
>> >> >> >> >> of the partition (such as "rootfs0" being the 0th root
>> >> >> >> >> file system in an A/B image scheme).
>> >> >> >> >>
>> >> >> >> >> Add "gpt part-uuid" to retrieve the partition UUID for a
>> >> >> >> >> given label and "gpt part-num" to retrieve the partition
>> >> >> >> >> number for a given label along with some documentation.
>> >> >> >> >>
>> >> >> >> >> Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
>> >> >> >> >
>> >> >> >> > Why not use the 'part' cmd? it provides it.
>> >> >> >>
>> >> >> >> Sorry, I missed the part cmd, it doesn't seem to be
>> >> >> >> documented in doc/ and it's unclear what <dev> means there.
>> >> >> >
>> >> >> > If I may ask - Andrey, if you are now on this "topic" - would
>> >> >> > you dare to add some ./doc entry for 'part' command?
>> >> >>
>> >> >> Yes, I will do that.
>> >> >
>> >> > Thanks :-)
>> >>
>> >> On further investigation I am not sure that it's possible to extend
>> >> the part command to retrieve UUIDs by label because of the design
>> >> of the partition type drivers. Here is how I understand it to work:
>> >> 1. the "part" command uses part_get_info() and in turn gets a
>> >> partition driver and can call print() there (which is how EFI/GPT
>> >> disks are printed with "part list"). The right information
>> >> (including label) is printed but it's not tied to the caller in
>> >> any way.
>> >
>> > Maybe you can set some env variable with proper data?
>> >
>> > For example, please refer to ./cmd/part.c do_part_start() function.
>> >
>> > Example call from envs (include/configs/display5.h):
>> >         "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
>> >
>>
>> Again that assumes the partition is referred to by number, I need it
>> to be by label, and the part/disk interface does not seem to have any
>> way to utilize labels. Unfortunately it looks like my original
>> approach with the gpt command is the only way to implement this with
>> the current design (at least from what I see here). Please let me know
>> if I've missed something. Thanks!
>
> Please correct me if I'm wrong - you need the starting LBA of the
> partition named e.g. "FOO" in gpt ?
>
> Conceptually it would be correct to have:
>
> part start <interface> <dev> <NAME - e.g.'FOO'> <env to set>
> gpt start <interface> <dev> <NAME- e.g. 'FOO'> <env to set>
>
> If your code is really _small_ and can be used only with GPT, then lets
> go for the second option.

The use cases I have in mind:

1. determine which root file system to use by label, let's say
"rootfs1" and pass its UUID to the Linux kernel via the command line,
ex: "PART-UUID=${uuid}". To do this we need a way to ask for a UUID
corresponding to a label in the partition table (given duplicate
labels, assume it gives us the first or last match).
2. determine which file system to load a file from (ex: fatload) given
a label. I'm not sure that the starting LBA is helpful here, we really
are looking to map a label to a partition number in the table.

The implementation of "part start" interprets the argument as a
partition number, so I can get the stating LBA if I know the partition
number but I don't see a way (via cmd/disk.c) to get anything useful
if all I know is a label, and that is what I'm trying to solve.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH] gpt: add part-uuid and part-num subcommands
  2017-12-04 21:48                   ` Andrey Yurovsky
@ 2017-12-05 15:10                     ` Lukasz Majewski
  2017-12-05 19:00                       ` Andrey Yurovsky
  0 siblings, 1 reply; 16+ messages in thread
From: Lukasz Majewski @ 2017-12-05 15:10 UTC (permalink / raw)
  To: u-boot

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="windows-1254", Size: 5416 bytes --]

Hi Andrey,

> On Mon, Dec 4, 2017 at 1:12 PM, Lukasz Majewski
> <l.majewski@majess.pl> wrote:
> > Hi Andrey,
> >  
> >> Hi Lukasz,
> >>
> >> On Tue, Nov 14, 2017 at 1:45 AM, Lukasz Majewski
> >> <l.majewski@majess.pl> wrote:  
> >> > Hi Andrey,
> >> >  
> >> >> Hi Lukasz,
> >> >>
> >> >> On Thu, Nov 9, 2017 at 2:28 PM, Lukasz Majewski
> >> >> <l.majewski@majess.pl> wrote:  
> >> >> > On Thu, 9 Nov 2017 07:34:44 -0800
> >> >> > Andrey Yurovsky <yurovsky@gmail.com> wrote:
> >> >> >  
> >> >> >> On Thu, Nov 9, 2017 at 1:55 AM, Lukasz Majewski
> >> >> >> <l.majewski@majess.pl> wrote:  
> >> >> >> > Hi Andrey,
> >> >> >> >  
> >> >> >> >> Hi Otavio,
> >> >> >> >>
> >> >> >> >> On Wed, Nov 8, 2017 at 2:47 AM, Otavio Salvador
> >> >> >> >> <otavio.salvador@ossystems.com.br> wrote:  
> >> >> >> >> > On Tue, Nov 7, 2017 at 10:43 PM, your name
> >> >> >> >> > <yurovsky@gmail.com> wrote:  
> >> >> >> >> >> From: Andrey Yurovsky <yurovsky@gmail.com>
> >> >> >> >> >>
> >> >> >> >> >> It is useful to be able to retrieve a partition UUID or
> >> >> >> >> >> number given the partition label, for instance some
> >> >> >> >> >> systems use the partition label to indicate the purpose
> >> >> >> >> >> of the partition (such as "rootfs0" being the 0th root
> >> >> >> >> >> file system in an A/B image scheme).
> >> >> >> >> >>
> >> >> >> >> >> Add "gpt part-uuid" to retrieve the partition UUID for
> >> >> >> >> >> a given label and "gpt part-num" to retrieve the
> >> >> >> >> >> partition number for a given label along with some
> >> >> >> >> >> documentation.
> >> >> >> >> >>
> >> >> >> >> >> Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>  
> >> >> >> >> >
> >> >> >> >> > Why not use the 'part' cmd? it provides it.  
> >> >> >> >>
> >> >> >> >> Sorry, I missed the part cmd, it doesn't seem to be
> >> >> >> >> documented in doc/ and it's unclear what <dev> means
> >> >> >> >> there.  
> >> >> >> >
> >> >> >> > If I may ask - Andrey, if you are now on this "topic" -
> >> >> >> > would you dare to add some ./doc entry for 'part'
> >> >> >> > command?  
> >> >> >>
> >> >> >> Yes, I will do that.  
> >> >> >
> >> >> > Thanks :-)  
> >> >>
> >> >> On further investigation I am not sure that it's possible to
> >> >> extend the part command to retrieve UUIDs by label because of
> >> >> the design of the partition type drivers. Here is how I
> >> >> understand it to work: 1. the "part" command uses
> >> >> part_get_info() and in turn gets a partition driver and can
> >> >> call print() there (which is how EFI/GPT disks are printed with
> >> >> "part list"). The right information (including label) is
> >> >> printed but it's not tied to the caller in any way.  
> >> >
> >> > Maybe you can set some env variable with proper data?
> >> >
> >> > For example, please refer to ./cmd/part.c do_part_start()
> >> > function.
> >> >
> >> > Example call from envs (include/configs/display5.h):
> >> >         "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
> >> >  
> >>
> >> Again that assumes the partition is referred to by number, I need
> >> it to be by label, and the part/disk interface does not seem to
> >> have any way to utilize labels. Unfortunately it looks like my
> >> original approach with the gpt command is the only way to
> >> implement this with the current design (at least from what I see
> >> here). Please let me know if I've missed something. Thanks!  
> >
> > Please correct me if I'm wrong - you need the starting LBA of the
> > partition named e.g. "FOO" in gpt ?
> >
> > Conceptually it would be correct to have:
> >
> > part start <interface> <dev> <NAME - e.g.'FOO'> <env to set>
> > gpt start <interface> <dev> <NAME- e.g. 'FOO'> <env to set>
> >
> > If your code is really _small_ and can be used only with GPT, then
> > lets go for the second option.  
> 
> The use cases I have in mind:
> 
> 1. determine which root file system to use by label, let's say
> "rootfs1" and pass its UUID to the Linux kernel via the command line,
> ex: "PART-UUID=${uuid}". To do this we need a way to ask for a UUID
> corresponding to a label in the partition table (given duplicate
> labels, assume it gives us the first or last match).

I see. I thought that you need start LBA.

>From your use case it seems like extending the 'gpt' command is the
right thing to do - since already some uuid handling is done there.

> 2. determine which file system to load a file from (ex: fatload) given
> a label. 

There is a group of generic commands - like load, ls, etc.

> I'm not sure that the starting LBA is helpful here, we really
> are looking to map a label to a partition number in the table.

If you are using GPT, then you also may want to extend the 'gpt'
command -> iterate through PTEs and when label matched, return the part
number. With it you can use e.g. load mmc 0 <part> file.

> 
> The implementation of "part start" interprets the argument as a
> partition number, so I can get the stating LBA if I know the partition
> number but I don't see a way (via cmd/disk.c) to get anything useful
> if all I know is a label, and that is what I'm trying to solve.



-- 
Best regards,

Łukasz Majewski
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171205/b1939fbf/attachment.sig>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH] gpt: add part-uuid and part-num subcommands
  2017-12-05 15:10                     ` Lukasz Majewski
@ 2017-12-05 19:00                       ` Andrey Yurovsky
  2017-12-11  9:09                         ` Lukasz Majewski
  0 siblings, 1 reply; 16+ messages in thread
From: Andrey Yurovsky @ 2017-12-05 19:00 UTC (permalink / raw)
  To: u-boot

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="windows-1254", Size: 5773 bytes --]

On Tue, Dec 5, 2017 at 7:10 AM, Lukasz Majewski <l.majewski@majess.pl> wrote:
> Hi Andrey,
>
>> On Mon, Dec 4, 2017 at 1:12 PM, Lukasz Majewski
>> <l.majewski@majess.pl> wrote:
>> > Hi Andrey,
>> >
>> >> Hi Lukasz,
>> >>
>> >> On Tue, Nov 14, 2017 at 1:45 AM, Lukasz Majewski
>> >> <l.majewski@majess.pl> wrote:
>> >> > Hi Andrey,
>> >> >
>> >> >> Hi Lukasz,
>> >> >>
>> >> >> On Thu, Nov 9, 2017 at 2:28 PM, Lukasz Majewski
>> >> >> <l.majewski@majess.pl> wrote:
>> >> >> > On Thu, 9 Nov 2017 07:34:44 -0800
>> >> >> > Andrey Yurovsky <yurovsky@gmail.com> wrote:
>> >> >> >
>> >> >> >> On Thu, Nov 9, 2017 at 1:55 AM, Lukasz Majewski
>> >> >> >> <l.majewski@majess.pl> wrote:
>> >> >> >> > Hi Andrey,
>> >> >> >> >
>> >> >> >> >> Hi Otavio,
>> >> >> >> >>
>> >> >> >> >> On Wed, Nov 8, 2017 at 2:47 AM, Otavio Salvador
>> >> >> >> >> <otavio.salvador@ossystems.com.br> wrote:
>> >> >> >> >> > On Tue, Nov 7, 2017 at 10:43 PM, your name
>> >> >> >> >> > <yurovsky@gmail.com> wrote:
>> >> >> >> >> >> From: Andrey Yurovsky <yurovsky@gmail.com>
>> >> >> >> >> >>
>> >> >> >> >> >> It is useful to be able to retrieve a partition UUID or
>> >> >> >> >> >> number given the partition label, for instance some
>> >> >> >> >> >> systems use the partition label to indicate the purpose
>> >> >> >> >> >> of the partition (such as "rootfs0" being the 0th root
>> >> >> >> >> >> file system in an A/B image scheme).
>> >> >> >> >> >>
>> >> >> >> >> >> Add "gpt part-uuid" to retrieve the partition UUID for
>> >> >> >> >> >> a given label and "gpt part-num" to retrieve the
>> >> >> >> >> >> partition number for a given label along with some
>> >> >> >> >> >> documentation.
>> >> >> >> >> >>
>> >> >> >> >> >> Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
>> >> >> >> >> >
>> >> >> >> >> > Why not use the 'part' cmd? it provides it.
>> >> >> >> >>
>> >> >> >> >> Sorry, I missed the part cmd, it doesn't seem to be
>> >> >> >> >> documented in doc/ and it's unclear what <dev> means
>> >> >> >> >> there.
>> >> >> >> >
>> >> >> >> > If I may ask - Andrey, if you are now on this "topic" -
>> >> >> >> > would you dare to add some ./doc entry for 'part'
>> >> >> >> > command?
>> >> >> >>
>> >> >> >> Yes, I will do that.
>> >> >> >
>> >> >> > Thanks :-)
>> >> >>
>> >> >> On further investigation I am not sure that it's possible to
>> >> >> extend the part command to retrieve UUIDs by label because of
>> >> >> the design of the partition type drivers. Here is how I
>> >> >> understand it to work: 1. the "part" command uses
>> >> >> part_get_info() and in turn gets a partition driver and can
>> >> >> call print() there (which is how EFI/GPT disks are printed with
>> >> >> "part list"). The right information (including label) is
>> >> >> printed but it's not tied to the caller in any way.
>> >> >
>> >> > Maybe you can set some env variable with proper data?
>> >> >
>> >> > For example, please refer to ./cmd/part.c do_part_start()
>> >> > function.
>> >> >
>> >> > Example call from envs (include/configs/display5.h):
>> >> >         "part start mmc ${mmcdev} ${kernel_part} lba_start; " \
>> >> >
>> >>
>> >> Again that assumes the partition is referred to by number, I need
>> >> it to be by label, and the part/disk interface does not seem to
>> >> have any way to utilize labels. Unfortunately it looks like my
>> >> original approach with the gpt command is the only way to
>> >> implement this with the current design (at least from what I see
>> >> here). Please let me know if I've missed something. Thanks!
>> >
>> > Please correct me if I'm wrong - you need the starting LBA of the
>> > partition named e.g. "FOO" in gpt ?
>> >
>> > Conceptually it would be correct to have:
>> >
>> > part start <interface> <dev> <NAME - e.g.'FOO'> <env to set>
>> > gpt start <interface> <dev> <NAME- e.g. 'FOO'> <env to set>
>> >
>> > If your code is really _small_ and can be used only with GPT, then
>> > lets go for the second option.
>>
>> The use cases I have in mind:
>>
>> 1. determine which root file system to use by label, let's say
>> "rootfs1" and pass its UUID to the Linux kernel via the command line,
>> ex: "PART-UUID=${uuid}". To do this we need a way to ask for a UUID
>> corresponding to a label in the partition table (given duplicate
>> labels, assume it gives us the first or last match).
>
> I see. I thought that you need start LBA.
>
> From your use case it seems like extending the 'gpt' command is the
> right thing to do - since already some uuid handling is done there.

In that case would you please let me know if the patch I sent is reasonable?

>> 2. determine which file system to load a file from (ex: fatload) given
>> a label.
>
> There is a group of generic commands - like load, ls, etc.

It seems that the lowest common denominator for these is indeed the
partition number (then they can talk to the disk driver) so adding a
way to map labels to that number (as in my original patch) may be
useful, the user's script can then use these commands once it learns
that information via the gpt command.

>> I'm not sure that the starting LBA is helpful here, we really
>> are looking to map a label to a partition number in the table.
>
> If you are using GPT, then you also may want to extend the 'gpt'
> command -> iterate through PTEs and when label matched, return the part
> number. With it you can use e.g. load mmc 0 <part> file.

Right, exactly. For that I added "gpt part-num" in the patch.

>>
>> The implementation of "part start" interprets the argument as a
>> partition number, so I can get the stating LBA if I know the partition
>> number but I don't see a way (via cmd/disk.c) to get anything useful
>> if all I know is a label, and that is what I'm trying to solve.
>
>
>
> --
> Best regards,
>
> Łukasz Majewski

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH] gpt: add part-uuid and part-num subcommands
  2017-12-05 19:00                       ` Andrey Yurovsky
@ 2017-12-11  9:09                         ` Lukasz Majewski
  0 siblings, 0 replies; 16+ messages in thread
From: Lukasz Majewski @ 2017-12-11  9:09 UTC (permalink / raw)
  To: u-boot

Hi Andrey,

Please resent it to u-boot ML.

> On Tue, Dec 5, 2017 at 7:10 AM, Lukasz Majewski
> <l.majewski@majess.pl> wrote:
> > Hi Andrey,
> >  
> >> On Mon, Dec 4, 2017 at 1:12 PM, Lukasz Majewski
> >> <l.majewski@majess.pl> wrote:  
> >> > Hi Andrey,
> >> >  
> >> >> Hi Lukasz,
> >> >>
> >> >> On Tue, Nov 14, 2017 at 1:45 AM, Lukasz Majewski
> >> >> <l.majewski@majess.pl> wrote:  
> >> >> > Hi Andrey,
> >> >> >  
> >> >> >> Hi Lukasz,
> >> >> >>
> >> >> >> On Thu, Nov 9, 2017 at 2:28 PM, Lukasz Majewski
> >> >> >> <l.majewski@majess.pl> wrote:  
> >> >> >> > On Thu, 9 Nov 2017 07:34:44 -0800
> >> >> >> > Andrey Yurovsky <yurovsky@gmail.com> wrote:
> >> >> >> >  
> >> >> >> >> On Thu, Nov 9, 2017 at 1:55 AM, Lukasz Majewski
> >> >> >> >> <l.majewski@majess.pl> wrote:  
> >> >> >> >> > Hi Andrey,
> >> >> >> >> >  
> >> >> >> >> >> Hi Otavio,
> >> >> >> >> >>
> >> >> >> >> >> On Wed, Nov 8, 2017 at 2:47 AM, Otavio Salvador
> >> >> >> >> >> <otavio.salvador@ossystems.com.br> wrote:  
> >> >> >> >> >> > On Tue, Nov 7, 2017 at 10:43 PM, your name
> >> >> >> >> >> > <yurovsky@gmail.com> wrote:  
> >> >> >> >> >> >> From: Andrey Yurovsky <yurovsky@gmail.com>
> >> >> >> >> >> >>
> >> >> >> >> >> >> It is useful to be able to retrieve a partition
> >> >> >> >> >> >> UUID or number given the partition label, for
> >> >> >> >> >> >> instance some systems use the partition label to
> >> >> >> >> >> >> indicate the purpose of the partition (such as
> >> >> >> >> >> >> "rootfs0" being the 0th root file system in an A/B
> >> >> >> >> >> >> image scheme).
> >> >> >> >> >> >>
> >> >> >> >> >> >> Add "gpt part-uuid" to retrieve the partition UUID
> >> >> >> >> >> >> for a given label and "gpt part-num" to retrieve the
> >> >> >> >> >> >> partition number for a given label along with some
> >> >> >> >> >> >> documentation.
> >> >> >> >> >> >>
> >> >> >> >> >> >> Signed-off-by: Andrey Yurovsky
> >> >> >> >> >> >> <yurovsky@gmail.com>  
> >> >> >> >> >> >
> >> >> >> >> >> > Why not use the 'part' cmd? it provides it.  
> >> >> >> >> >>
> >> >> >> >> >> Sorry, I missed the part cmd, it doesn't seem to be
> >> >> >> >> >> documented in doc/ and it's unclear what <dev> means
> >> >> >> >> >> there.  
> >> >> >> >> >
> >> >> >> >> > If I may ask - Andrey, if you are now on this "topic" -
> >> >> >> >> > would you dare to add some ./doc entry for 'part'
> >> >> >> >> > command?  
> >> >> >> >>
> >> >> >> >> Yes, I will do that.  
> >> >> >> >
> >> >> >> > Thanks :-)  
> >> >> >>
> >> >> >> On further investigation I am not sure that it's possible to
> >> >> >> extend the part command to retrieve UUIDs by label because of
> >> >> >> the design of the partition type drivers. Here is how I
> >> >> >> understand it to work: 1. the "part" command uses
> >> >> >> part_get_info() and in turn gets a partition driver and can
> >> >> >> call print() there (which is how EFI/GPT disks are printed
> >> >> >> with "part list"). The right information (including label) is
> >> >> >> printed but it's not tied to the caller in any way.  
> >> >> >
> >> >> > Maybe you can set some env variable with proper data?
> >> >> >
> >> >> > For example, please refer to ./cmd/part.c do_part_start()
> >> >> > function.
> >> >> >
> >> >> > Example call from envs (include/configs/display5.h):
> >> >> >         "part start mmc ${mmcdev} ${kernel_part} lba_start; "
> >> >> > \ 
> >> >>
> >> >> Again that assumes the partition is referred to by number, I
> >> >> need it to be by label, and the part/disk interface does not
> >> >> seem to have any way to utilize labels. Unfortunately it looks
> >> >> like my original approach with the gpt command is the only way
> >> >> to implement this with the current design (at least from what I
> >> >> see here). Please let me know if I've missed something.
> >> >> Thanks!  
> >> >
> >> > Please correct me if I'm wrong - you need the starting LBA of the
> >> > partition named e.g. "FOO" in gpt ?
> >> >
> >> > Conceptually it would be correct to have:
> >> >
> >> > part start <interface> <dev> <NAME - e.g.'FOO'> <env to set>
> >> > gpt start <interface> <dev> <NAME- e.g. 'FOO'> <env to set>
> >> >
> >> > If your code is really _small_ and can be used only with GPT,
> >> > then lets go for the second option.  
> >>
> >> The use cases I have in mind:
> >>
> >> 1. determine which root file system to use by label, let's say
> >> "rootfs1" and pass its UUID to the Linux kernel via the command
> >> line, ex: "PART-UUID=${uuid}". To do this we need a way to ask for
> >> a UUID corresponding to a label in the partition table (given
> >> duplicate labels, assume it gives us the first or last match).  
> >
> > I see. I thought that you need start LBA.
> >
> > From your use case it seems like extending the 'gpt' command is the
> > right thing to do - since already some uuid handling is done
> > there.  
> 
> In that case would you please let me know if the patch I sent is
> reasonable?
> 
> >> 2. determine which file system to load a file from (ex: fatload)
> >> given a label.  
> >
> > There is a group of generic commands - like load, ls, etc.  
> 
> It seems that the lowest common denominator for these is indeed the
> partition number (then they can talk to the disk driver) so adding a
> way to map labels to that number (as in my original patch) may be
> useful, the user's script can then use these commands once it learns
> that information via the gpt command.
> 
> >> I'm not sure that the starting LBA is helpful here, we really
> >> are looking to map a label to a partition number in the table.  
> >
> > If you are using GPT, then you also may want to extend the 'gpt'
> > command -> iterate through PTEs and when label matched, return the
> > part number. With it you can use e.g. load mmc 0 <part> file.  
> 
> Right, exactly. For that I added "gpt part-num" in the patch.
> 
> >>
> >> The implementation of "part start" interprets the argument as a
> >> partition number, so I can get the stating LBA if I know the
> >> partition number but I don't see a way (via cmd/disk.c) to get
> >> anything useful if all I know is a label, and that is what I'm
> >> trying to solve.  
> >
> >
> >
> > --
> > Best regards,
> >
> > Łukasz Majewski  



-- 
Best regards,

Łukasz Majewski
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171211/0364f933/attachment.sig>

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2017-12-11  9:09 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-08  0:43 [U-Boot] [PATCH] gpt: add part-uuid and part-num subcommands your name
2017-11-08 10:47 ` Otavio Salvador
2017-11-08 17:10   ` Andrey Yurovsky
2017-11-09  9:55     ` Lukasz Majewski
2017-11-09 15:34       ` Andrey Yurovsky
2017-11-09 22:28         ` Lukasz Majewski
2017-11-11 20:39           ` Andrey Yurovsky
2017-11-14  9:45             ` Lukasz Majewski
2017-12-04 17:57               ` Andrey Yurovsky
2017-12-04 21:12                 ` Lukasz Majewski
2017-12-04 21:48                   ` Andrey Yurovsky
2017-12-05 15:10                     ` Lukasz Majewski
2017-12-05 19:00                       ` Andrey Yurovsky
2017-12-11  9:09                         ` Lukasz Majewski
2017-11-08 17:16   ` Andrey Yurovsky
2017-11-08 18:05     ` Otavio Salvador

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.