fat: Loosen up check more and lower its priority in file.s2.c

This commit is contained in:
mintsuki 2022-07-09 12:42:34 +02:00
parent afedae6d08
commit b1672e4ab9
2 changed files with 9 additions and 11 deletions

View File

@ -111,23 +111,21 @@ static int fat32_init_context(struct fat32_context* context, struct volume *part
// Checks for FAT12/16
if (strncmp((((void *)&bpb) + 0x36), "FAT", 3) == 0) {
if (*(((uint8_t *)&bpb) + 0x26) != 0x29) {
return 1;
}
uint8_t sig = *(((uint8_t *)&bpb) + 0x26);
if (sig == 0x29 || sig == 0xd0) {
goto valid;
}
}
// Checks for FAT32
if (strncmp((((void *)&bpb) + 0x52), "FAT", 3) == 0) {
uint8_t sig = *(((uint8_t *)&bpb) + 0x42);
if (sig != 0x29 && sig != 0x28 && sig != 0xd0) {
return 1;
}
if (sig == 0x29 || sig == 0x28 || sig == 0xd0) {
goto valid;
}
}
return 1;

View File

@ -60,15 +60,15 @@ struct file_handle *fopen(struct volume *part, const char *filename) {
if ((ret = ext2_open(part, filename)) != NULL) {
goto success;
}
if ((ret = fat32_open(part, filename)) != NULL) {
goto success;
}
if ((ret = iso9660_open(part, filename)) != NULL) {
goto success;
}
if ((ret = ntfs_open(part, filename)) != NULL) {
goto success;
}
if ((ret = fat32_open(part, filename)) != NULL) {
goto success;
}
return NULL;