From c8a7c639630e353f103bed1c963a6e1a2cb5d52c Mon Sep 17 00:00:00 2001 From: Wolfvak Date: Mon, 29 Jul 2019 14:40:11 -0300 Subject: [PATCH] fix unicode FAT labels (#508) --- arm9/source/filesys/fsdrive.c | 4 ++-- arm9/source/filesys/fsdrive.h | 2 ++ arm9/source/godmode.c | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/arm9/source/filesys/fsdrive.c b/arm9/source/filesys/fsdrive.c index 51b3dd6..f852f2e 100644 --- a/arm9/source/filesys/fsdrive.c +++ b/arm9/source/filesys/fsdrive.c @@ -83,9 +83,9 @@ bool GetRootDirContentsWorker(DirStruct* contents) { static const char* drvnum[] = { FS_DRVNUM }; u32 n_entries = 0; - char sdlabel[16]; + char sdlabel[DRV_LABEL_LEN]; if (!GetFATVolumeLabel("0:", sdlabel) || !(*sdlabel)) - snprintf(sdlabel, 16, "NOLABEL"); + strcpy(sdlabel, "NOLABEL"); char carttype[16]; GetVCartTypeString(carttype); diff --git a/arm9/source/filesys/fsdrive.h b/arm9/source/filesys/fsdrive.h index 1289a76..7e7b104 100644 --- a/arm9/source/filesys/fsdrive.h +++ b/arm9/source/filesys/fsdrive.h @@ -29,6 +29,8 @@ #define DRV_SEARCH (1UL<<16) #define DRV_STDFAT (1UL<<17) // standard FAT drive without limitations +#define DRV_LABEL_LEN (36) + #define FS_DRVNAME \ "SDCARD", \ "SYSNAND CTRNAND", "SYSNAND TWLN", "SYSNAND TWLP", "SYSNAND SD", "SYSNAND VIRTUAL", \ diff --git a/arm9/source/godmode.c b/arm9/source/godmode.c index a1ac21c..7d54d40 100644 --- a/arm9/source/godmode.c +++ b/arm9/source/godmode.c @@ -421,7 +421,7 @@ u32 SdFormatMenu(const char* slabel) { u64 sysnand_min_size_mb = ((sysnand_min_size_sectors * 0x200) + 0xFFFFF) / 0x100000; u64 sysnand_multi_size_mb = (align(sysnand_min_size_sectors + 1, 0x2000) * 0x200) / 0x100000; u64 sysnand_size_mb = (((u64)GetNandSizeSectors(NAND_SYSNAND) * 0x200) + 0xFFFFF) / 0x100000; - char label[16]; + char label[DRV_LABEL_LEN + 4]; u32 cluster_size = 0; u64 sdcard_size_mb = 0; u64 emunand_size_mb = (u64) -1; @@ -450,7 +450,7 @@ u32 SdFormatMenu(const char* slabel) { if (!user_select) return 1; else cluster_size = cluster_size_table[user_select]; - snprintf(label, 16, "0:%s", (slabel && *slabel) ? slabel : "GM9SD"); + snprintf(label, DRV_LABEL_LEN + 4, "0:%s", (slabel && *slabel) ? slabel : "GM9SD"); if (!ShowKeyboardOrPrompt(label + 2, 11 + 1, "Format SD card (%lluMB)?\nEnter label:", sdcard_size_mb)) return 1; @@ -1949,7 +1949,7 @@ u32 HomeMoreMenu(char* current_path) { int user_select = ShowSelectPrompt(n_opt, optionstr, promptstr); if (user_select == sdformat) { // format SD card bool sd_state = CheckSDMountState(); - char slabel[16] = { '\0' }; + char slabel[DRV_LABEL_LEN] = { '\0' }; if (clipboard->n_entries && (DriveType(clipboard->entry[0].path) & (DRV_SDCARD|DRV_ALIAS|DRV_EMUNAND|DRV_IMAGE))) clipboard->n_entries = 0; // remove SD clipboard entries GetFATVolumeLabel("0:", slabel); // get SD volume label