+ unsigned int partno = grub_strtoul (partition, 0, 0);
+ partno--; /* GRUB partition numbering is 0-based. */
Right. But how can you be sure both match?
Eh? OF partition numbers are 1-based. To convert to GRUB's 0-based
numbering, we subtract one. How could that not "match"?
Because not in all cases GRUB and the firmware will count partitions
the same way. A good example is the PC partition map. In linux
primary partitions are numbers from 1 to 4, extended partitions are
numbered from 5 (IIRC). One other way to count these partitions is
just by starting counting from 1.
This is just an example. There are a lot of partition table layouts
and many ways to interpret partition numbers. I can imagine GRUB
does not always work the same as a specific firmware implementation
all the time.