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

This commit is contained in:
mintsuki 2022-07-06 03:17:11 +02:00
parent 610d6865e8
commit 1c466b37fa
2 changed files with 11 additions and 10 deletions

View File

@ -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");
}
}

View File

@ -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));