[U-Boot] [PATCH] gpt: add part-uuid and part-num subcommands

Lukasz Majewski l.majewski at majess.pl
Mon Dec 11 09:09:12 UTC 2017


Hi Andrey,

Please resent it to u-boot ML.

> On Tue, Dec 5, 2017 at 7:10 AM, Lukasz Majewski
> <l.majewski at majess.pl> wrote:
> > Hi Andrey,
> >  
> >> On Mon, Dec 4, 2017 at 1:12 PM, Lukasz Majewski
> >> <l.majewski at majess.pl> wrote:  
> >> > Hi Andrey,
> >> >  
> >> >> Hi Lukasz,
> >> >>
> >> >> On Tue, Nov 14, 2017 at 1:45 AM, Lukasz Majewski
> >> >> <l.majewski at majess.pl> wrote:  
> >> >> > Hi Andrey,
> >> >> >  
> >> >> >> Hi Lukasz,
> >> >> >>
> >> >> >> On Thu, Nov 9, 2017 at 2:28 PM, Lukasz Majewski
> >> >> >> <l.majewski at majess.pl> wrote:  
> >> >> >> > On Thu, 9 Nov 2017 07:34:44 -0800
> >> >> >> > Andrey Yurovsky <yurovsky at gmail.com> wrote:
> >> >> >> >  
> >> >> >> >> On Thu, Nov 9, 2017 at 1:55 AM, Lukasz Majewski
> >> >> >> >> <l.majewski at majess.pl> wrote:  
> >> >> >> >> > Hi Andrey,
> >> >> >> >> >  
> >> >> >> >> >> Hi Otavio,
> >> >> >> >> >>
> >> >> >> >> >> On Wed, Nov 8, 2017 at 2:47 AM, Otavio Salvador
> >> >> >> >> >> <otavio.salvador at ossystems.com.br> wrote:  
> >> >> >> >> >> > On Tue, Nov 7, 2017 at 10:43 PM, your name
> >> >> >> >> >> > <yurovsky at gmail.com> wrote:  
> >> >> >> >> >> >> From: Andrey Yurovsky <yurovsky at 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 at 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>


More information about the U-Boot mailing list