From e4d4b05cc98afeaf3d54559a6c323379d71494a1 Mon Sep 17 00:00:00 2001 From: d0k3 Date: Sun, 10 Sep 2017 14:15:38 +0200 Subject: [PATCH] Workaround for empty EmuNAND partitions --- source/nand/nand.c | 1 + source/virtual/vnand.c | 7 ------- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/source/nand/nand.c b/source/nand/nand.c index b1a0352..8b4df47 100644 --- a/source/nand/nand.c +++ b/source/nand/nand.c @@ -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; diff --git a/source/virtual/vnand.c b/source/virtual/vnand.c index 4e4caa5..31a5dd8 100644 --- a/source/virtual/vnand.c +++ b/source/virtual/vnand.c @@ -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)];