On 18/03/2024 06.14, Kautuk Consul wrote:
Hi,
On 2024-02-22 01:10:46, 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..e680847 100644
--- a/slof/fs/packages/disk-label.fs
+++ b/slof/fs/packages/disk-label.fs
@@ -139,6 +139,13 @@ CONSTANT /gpt-part-entry
block block-size read drop \ read sector
;
+\ read sector to array "block" and return actual bytes read
+: read-sector-ret ( sector-number -- actual)
Please add a space between "actual" and ")". I'd maybe also rather say
"actual-bytes" so that nobody expects "actual-sectors" here.
+ \ block-size is 0x200 on disks, 0x800 on cdrom drives
+ block-size * 0 seek drop \ seek to sector
+ block block-size read \ read sector
+;
Could we please avoid duplicating code here? "read-sector" could now simply
be implemented via read-sector-ret instead:
\ 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 \ read sector
;
: read-sector ( sector-number -- )
read-sector-ret drop
;
: (.part-entry) ( part-entry )
cr ." part-entry>active: " dup part-entry>active c@ .d
cr ." part-entry>start-head: " dup part-entry>start-head c@ .d
@@ -204,7 +211,8 @@ CONSTANT /gpt-part-entry
part-entry>sector-offset l@-le ( current sector )
dup to part-start to lpart-start ( current )
BEGIN
- part-start read-sector \ read EBR
+ part-start read-sector-ret \ read EBR
+ block-size < IF UNLOOP 0 EXIT THEN
1 partition>start-sector IF
\ ." Logical Partition found at " part-start .d cr
1+
@@ -279,6 +287,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 +361,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
debug-disk-label? IF
." Found " dos-logical-partitions .d ." logical partitions" cr
--
2.31.1
So how does the patch look ? Any comments from anyone ?
Sorry, your original patch somehow didn't make it to my Inbox (though it's
visible on http://patchwork.ozlabs.org/project/slof/list/ so the problem is
certainly on my receiving side), so I just learnt about this patch today.
Anyway, apart from the code duplication, it looks fine to me, so if you
could fix that in a v2, that would be great!
Thomas