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;