Le mer. 23 août 2023, 13:55, Vitaly Kuzmichev <vitaly.kuzmic...@rtsoft.de>
a écrit :

> Hi Vladimir,
>
> On Wed, 2023-08-23 at 00:02 +0200, Vladimir 'phcoder' Serbinenko wrote:
> >
> > >
> > > +       {
> > > +         disk = grub_disk_open (dev->disk->name);
> > > +         if (disk && grub_disk_read (disk, pt->offset, pt->index,
> > > +                                     sizeof (gptdata), &gptdata)
> > > == 0)
> > Did you test this? It looks like you're missing a line
> > disk->partition = disk->partition->parent;
> > And the restore disk->partition
>
> Yes, I tested this code multiple times and it works as it is.
> I did not find any place in Grub that would use the code you suggested.
> I do not think it is needed.
> What is the purpose of this code?
>
I see what you have done here. You open the disk again. This is not needed
and in fact some OFW variants dislike it. Also it breaks nested partition
case (rare for gpt but possible). Instead of doing grub_disk_open do:
disk = dev->disk;
pt = disk->partition:
disk->partition = pt->parent;
<Use disk>
disk->partition = pt;

Similar code is used in couple of places which neednto access parent
device. E.g.
https://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/parttool/msdospart.c#n53
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to