:: commit 1c466b37fa9b89c19840e38218478073fd58bf6e

mintsuki <mintsuki@protonmail.com> — 2022-07-06 01:17

parents: 610d6865e8

part: Misc EBR-related bug fixes. Fixes #189

diff --git a/common/lib/part.c b/common/lib/part.c
index a048927f..c8930cad 100644
--- a/common/lib/part.c
+++ b/common/lib/part.c
@@ -10,8 +10,8 @@ void list_volumes(void) {
         print("partition: %u\n", v->partition);
         print("sector_size: %u\n", v->sector_size);
         print("max_partition: %d\n", v->max_partition);
-        print("first_sect: %X\n", v->first_sect);
-        print("sect_count: %X\n", v->sect_count);
+        print("first_sect: %U\n", v->first_sect);
+        print("sect_count: %U\n", v->sect_count);
         print("---\n");
     }
 }
diff --git a/common/lib/part.s2.c b/common/lib/part.s2.c
index 7abd51ee..b0e9decd 100644
--- a/common/lib/part.s2.c
+++ b/common/lib/part.s2.c
@@ -30,7 +30,7 @@ static bool cache_block(struct volume *volume, uint64_t block) {
         return false;
     }
 
-    size_t first_sect = volume->first_sect / (volume->sector_size / 512);
+    uint64_t first_sect = volume->first_sect / (volume->sector_size / 512);
 
     uint64_t xfer_size = volume->fastest_xfer_size;
 
@@ -304,20 +304,21 @@ static int mbr_get_logical_part(struct volume *ret, struct volume *extended_part
                                 int partition) {
     struct mbr_entry entry;
 
-    size_t ebr_sector = 0;
+    uint64_t ebr_sector = 0;
 
     for (int i = 0; i < partition; i++) {
-        size_t entry_offset = ebr_sector * 512 + 0x1ce;
+        uint64_t entry_offset = ebr_sector * 512 + 0x1ce;
 
         volume_read(extended_part, &entry, entry_offset, sizeof(struct mbr_entry));
 
-        if (entry.type != 0x0f && entry.type != 0x05)
+        if (entry.type != 0x0f && entry.type != 0x05) {
             return END_OF_TABLE;
+        }
 
         ebr_sector = entry.first_sect;
     }
 
-    size_t entry_offset = ebr_sector * 512 + 0x1be;
+    uint64_t entry_offset = ebr_sector * 512 + 0x1be;
 
     volume_read(extended_part, &entry, entry_offset, sizeof(struct mbr_entry));
 
@@ -369,11 +370,11 @@ static int mbr_get_part(struct volume *ret, struct volume *volume, int partition
 
     if (partition > 3) {
         for (int i = 0; i < 4; i++) {
-            size_t entry_offset = 0x1be + sizeof(struct mbr_entry) * i;
+            uint64_t entry_offset = 0x1be + sizeof(struct mbr_entry) * i;
 
             volume_read(volume, &entry, entry_offset, sizeof(struct mbr_entry));
 
-            if (entry.type != 0x0f)
+            if (entry.type != 0x0f && entry.type != 0x05)
                 continue;
 
             struct volume extended_part = {0};
@@ -399,7 +400,7 @@ static int mbr_get_part(struct volume *ret, struct volume *volume, int partition
         return END_OF_TABLE;
     }
 
-    size_t entry_offset = 0x1be + sizeof(struct mbr_entry) * partition;
+    uint64_t entry_offset = 0x1be + sizeof(struct mbr_entry) * partition;
 
     volume_read(volume, &entry, entry_offset, sizeof(struct mbr_entry));
 
tab: 248 wrap: offon