Workaround for empty EmuNAND partitions

This commit is contained in:
d0k3 2017-09-10 14:15:38 +02:00
parent cc31926a69
commit e4d4b05cc9
2 changed files with 1 additions and 7 deletions

View File

@ -444,6 +444,7 @@ u32 GetNandSizeSectors(u32 nand_src)
u32 emunand_max_sectors = (partition_offset >= (emunand_base_sector + 1)) ? // +1 for safety
partition_offset - (emunand_base_sector + 1) : 0;
u32 emunand_min_sectors = (emunand_base_sector % 0x2000 == 0) ? sysnand_sectors : min_sectors;
if (!emunand_min_sectors) emunand_min_sectors = GetNandMinSizeSectors(NAND_SYSNAND);
return (emunand_min_sectors > emunand_max_sectors) ? 0 : emunand_min_sectors;
} else if (nand_src == NAND_IMGNAND) { // for images
u32 img_sectors = (GetMountState() & IMG_NAND) ? GetMountSize() / 0x200 : 0;

View File

@ -83,13 +83,6 @@ bool ReadVNandDir(VirtualFile* vfile, VirtualDir* vdir) { // uses a generic vdir
vfile->offset += 0x200 - 0x42;
vfile->size = 0x42;
}
if (vfile->flags & VFLAG_NAND_SIZE) {
if ((nand_src != VRT_SYSNAND) && (GetNandSizeSectors(NAND_SYSNAND) > GetNandSizeSectors(nand_src)))
continue; // EmuNAND / ImgNAND is too small
u64 nand_size = GetNandSizeSectors(NAND_SYSNAND) * 0x200;
if (nand_size <= vfile->offset) continue;
vfile->size = nand_size - vfile->offset;
}
if (vfile->flags & VFLAG_ESSENTIAL) {
const u8 magic[] = { ESSENTIAL_MAGIC };
u8 data[sizeof(magic)];