fatfs: extend gpt support
This commit is contained in:
@@ -473,6 +473,10 @@ static const char* const VolumeStr[FF_VOLUMES] = {FF_VOLUME_STRS}; /* Pre-define
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if FF_SIMPLE_GPT
|
||||||
|
static const BYTE GUID_MS_Basic[16] = {0xA2,0xA0,0xD0,0xEB,0xE5,0xB9,0x33,0x44,0x87,0xC0,0x68,0xB6,0xB7,0x26,0x99,0xC7};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------*/
|
/*--------------------------------*/
|
||||||
/* LFN/Directory working buffer */
|
/* LFN/Directory working buffer */
|
||||||
@@ -3319,15 +3323,28 @@ static FRESULT find_volume ( /* FR_OK(0): successful, !=0: an error occurred */
|
|||||||
}
|
}
|
||||||
#if FF_SIMPLE_GPT
|
#if FF_SIMPLE_GPT
|
||||||
if (fmt >= 2) {
|
if (fmt >= 2) {
|
||||||
/* If GPT Check the first partition */
|
/* If GPT, iterate over all part entries and check MS Basic partitions */
|
||||||
gpt_header_t *gpt_header = (gpt_header_t *)fs->win;
|
gpt_header_t *gpt_header = (gpt_header_t *)fs->win;
|
||||||
if (move_window(fs, 1) != FR_OK) return FR_DISK_ERR;
|
if (move_window(fs, 1) != FR_OK) return FR_DISK_ERR;
|
||||||
if (!mem_cmp(&gpt_header->signature, "EFI PART", 8)) {
|
if (!mem_cmp(&gpt_header->signature, "EFI PART", 8)) {
|
||||||
if (move_window(fs, gpt_header->part_ent_lba) != FR_OK) return FR_DISK_ERR;
|
DWORD cur_entry, ofs, part;
|
||||||
gpt_entry_t *gpt_entry = (gpt_entry_t *)fs->win;
|
part = LD2PT(vol);
|
||||||
fs->part_type = 1;
|
cur_entry = 0;
|
||||||
bsect = gpt_entry->lba_start;
|
for(i = 0; i < gpt_header->num_part_ents; i++){
|
||||||
fmt = bsect ? check_fs(fs, bsect) : 3; /* Check the partition */
|
if (move_window(fs, gpt_header->part_ent_lba + i * sizeof(gpt_entry_t) / SS(fs))) return FR_DISK_ERR;
|
||||||
|
ofs = i * sizeof(gpt_entry_t) % SS(fs);
|
||||||
|
gpt_entry_t *gpt_entry = (gpt_entry_t *)fs->win + ofs;
|
||||||
|
if (!mem_cmp(gpt_entry->type_guid, GUID_MS_Basic, 16)){
|
||||||
|
cur_entry++;
|
||||||
|
bsect = gpt_entry->lba_start;
|
||||||
|
fmt = bsect ? check_fs(fs, bsect) : 3;
|
||||||
|
if(part == 0 && fmt <= 1) break;
|
||||||
|
if(part != 0 && cur_entry == part) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(part && part != cur_entry){
|
||||||
|
fmt = 3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user