Add checks for get_part errors
diff --git a/qloader2.bin b/qloader2.bin
index 873de69d..87e3c917 100644
Binary files a/qloader2.bin and b/qloader2.bin differ
diff --git a/src/drivers/disk.c b/src/drivers/disk.c
index b04474cf..5621e50f 100644
--- a/src/drivers/disk.c
+++ b/src/drivers/disk.c
@@ -44,6 +44,7 @@ static int cache_block(int drive, uint64_t block) {
if (r.eflags & EFLAGS_CF) {
int ah = (r.eax >> 8) & 0xff;
print("Disk error %x. Drive %x, LBA %x.\n", ah, drive, dap.lba);
+ panic("");
cached_block = CACHE_INVALID;
return ah;
}
diff --git a/src/fs/echfs.c b/src/fs/echfs.c
index ceddfe13..bc9c79ea 100644
--- a/src/fs/echfs.c
+++ b/src/fs/echfs.c
@@ -40,7 +40,9 @@ int echfs_read(struct echfs_file_handle *file, void *buf, uint64_t loc, uint64_t
int echfs_check_signature(int disk, int partition) {
struct part part;
- get_part(&part, disk, partition);
+ if (get_part(&part, disk, partition)) {
+ panic("Invalid partition");
+ }
struct echfs_identity_table id_table;
read_partition(disk, &part, &id_table, 0, sizeof(struct echfs_identity_table));
@@ -57,7 +59,9 @@ int echfs_open(struct echfs_file_handle *ret, int disk, int partition, const cha
ret->disk = disk;
- get_part(&ret->part, disk, partition);
+ if (get_part(&ret->part, disk, partition)) {
+ panic("Invalid partition");
+ }
struct echfs_identity_table id_table;
read_partition(disk, &ret->part, &id_table, 0, sizeof(struct echfs_identity_table));
diff --git a/src/fs/ext2fs.c b/src/fs/ext2fs.c
index 54fe75a7..093fa3a8 100644
--- a/src/fs/ext2fs.c
+++ b/src/fs/ext2fs.c
@@ -265,7 +265,9 @@ next:
}
int ext2fs_open(struct ext2fs_file_handle *ret, int drive, int partition, const char *path) {
- get_part(&ret->part, drive, partition);
+ if (get_part(&ret->part, drive, partition)) {
+ panic("Invalid partition");
+ }
ret->drive = drive;
@@ -353,7 +355,9 @@ static int inode_read(void *buf, uint64_t loc, uint64_t count,
// attempts to initialize the ext2 filesystem
int ext2fs_check_signature(int drive, int partition) {
struct part part;
- get_part(&part, drive, partition);
+ if (get_part(&part, drive, partition)) {
+ panic("Invalid partition");
+ }
uint16_t magic = 0;
diff --git a/src/fs/fat32.c b/src/fs/fat32.c
index ff6505f2..7a5f2c36 100644
--- a/src/fs/fat32.c
+++ b/src/fs/fat32.c
@@ -67,7 +67,9 @@ struct fat32_lfn_entry {
static int fat32_init_context(struct fat32_context* context, int disk, int partition) {
context->drive = disk;
- get_part(&context->part, disk, partition);
+ if (get_part(&context->part, disk, partition)) {
+ panic("Invalid partition");
+ }
struct fat32_bpb bpb;
read_partition(disk, &context->part, &bpb, 0, sizeof(struct fat32_bpb));
