[SLOF] [PATCH v2] slof/fs/packages/disk-label.fs: improve checking for DOS boot partitions
Thomas Huth
thuth at redhat.com
Wed Mar 27 01:45:46 AEDT 2024
On 18/03/2024 11.30, Kautuk Consul wrote:
> While testing with a qcow2 with a DOS boot partition it was found that
> when we set the logical_block_size in the guest XML to >512 then the
> boot would fail
...
> diff --git a/slof/fs/packages/disk-label.fs b/slof/fs/packages/disk-label.fs
> index 661c6b0..2630701 100644
> --- a/slof/fs/packages/disk-label.fs
> +++ b/slof/fs/packages/disk-label.fs
> @@ -132,11 +132,16 @@ CONSTANT /gpt-part-entry
> debug-disk-label? IF dup ." actual=" .d cr THEN
> ;
>
> -\ read sector to array "block"
> -: read-sector ( sector-number -- )
> +\ read sector to array "block" and return actual bytes read
> +: read-sector-ret ( sector-number -- actual-bytes )
> \ block-size is 0x200 on disks, 0x800 on cdrom drives
> block-size * 0 seek drop \ seek to sector
> - block block-size read drop \ read sector
> + block block-size read \ read sector
> +;
> +
> +\ read sector to array "block"
> +: read-sector ( sector-number -- )
> + read-sector-ret drop
> ;
>
> : (.part-entry) ( part-entry )
> @@ -204,7 +209,8 @@ CONSTANT /gpt-part-entry
> part-entry>sector-offset l at -le ( current sector )
> dup to part-start to lpart-start ( current )
I just noticed that according to the stack comment above, there is a
"current" item on the stack...
> BEGIN
> - part-start read-sector \ read EBR
> + part-start read-sector-ret \ read EBR
> + block-size < IF UNLOOP 0 EXIT THEN
... which doesn't get dropped here before the EXIT ? Is the stack still
right after this function exited early?
> 1 partition>start-sector IF
> \ ." Logical Partition found at " part-start .d cr
> 1+
> @@ -279,6 +285,7 @@ CONSTANT /gpt-part-entry
> THEN
>
> count-dos-logical-partitions TO dos-logical-partitions
> + dos-logical-partitions 0= IF false EXIT THEN
>
> debug-disk-label? IF
> ." Found " dos-logical-partitions .d ." logical partitions" cr
> @@ -352,6 +359,7 @@ CONSTANT /gpt-part-entry
> no-mbr? IF drop FALSE EXIT THEN \ read MBR and check for DOS disk-label magic
>
> count-dos-logical-partitions TO dos-logical-partitions
> + dos-logical-partitions 0= IF 0 EXIT THEN
Similar question here, what about the "addr" stack item? Shouldn't it be
dropped first?
Thomas
PS: I'm still having trouble receiving your mail, I just discovered v2 on
patchwork and downloaded it from there...
More information about the SLOF
mailing list