forked from Mirror/GodMode9
Allow setting the label when formatting the SD card
This commit is contained in:
parent
74ff158c93
commit
8ab2988258
@ -24,7 +24,7 @@ uint64_t GetSDCardSize() {
|
|||||||
return (u64) getMMCDevice(1)->total_size * 512;
|
return (u64) getMMCDevice(1)->total_size * 512;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FormatSDCard(u64 hidden_mb, u32 cluster_size) {
|
bool FormatSDCard(u64 hidden_mb, u32 cluster_size, const char* label) {
|
||||||
u8 mbr[0x200] = { 0 };
|
u8 mbr[0x200] = { 0 };
|
||||||
u8 mbrdata[0x42] = {
|
u8 mbrdata[0x42] = {
|
||||||
0x80, 0x01, 0x01, 0x00, 0x0C, 0xFE, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x80, 0x01, 0x01, 0x00, 0x0C, 0xFE, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
@ -70,7 +70,7 @@ bool FormatSDCard(u64 hidden_mb, u32 cluster_size) {
|
|||||||
// format the SD card
|
// format the SD card
|
||||||
InitSDCardFS();
|
InitSDCardFS();
|
||||||
UINT c_size = cluster_size;
|
UINT c_size = cluster_size;
|
||||||
bool ret = (f_mkfs("0:", FM_FAT32, c_size, MAIN_BUFFER, MAIN_BUFFER_SIZE) == FR_OK) && (f_setlabel("0:GM9SD") == FR_OK);
|
bool ret = (f_mkfs("0:", FM_FAT32, c_size, MAIN_BUFFER, MAIN_BUFFER_SIZE) == FR_OK) && (f_setlabel((label) ? label : "0:GM9SD") == FR_OK);
|
||||||
DeinitSDCardFS();
|
DeinitSDCardFS();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
uint64_t GetSDCardSize();
|
uint64_t GetSDCardSize();
|
||||||
|
|
||||||
/** Format the SD card **/
|
/** Format the SD card **/
|
||||||
bool FormatSDCard(u64 hidden_mb, u32 cluster_size);
|
bool FormatSDCard(u64 hidden_mb, u32 cluster_size, const char* label);
|
||||||
|
|
||||||
/** Check for file lock, offer to unlock if possible **/
|
/** Check for file lock, offer to unlock if possible **/
|
||||||
bool FileUnlock(const char* path);
|
bool FileUnlock(const char* path);
|
||||||
|
@ -200,6 +200,7 @@ u32 SdFormatMenu(void) {
|
|||||||
const u32 cluster_size_table[5] = { 0x0, 0x0, 0x4000, 0x8000, 0x10000 };
|
const u32 cluster_size_table[5] = { 0x0, 0x0, 0x4000, 0x8000, 0x10000 };
|
||||||
const char* option_emunand_size[6] = { "No EmuNAND", "O3DS NAND size", "N3DS NAND size", "1GB (legacy size)", "2GB (legacy size)", "User input..." };
|
const char* option_emunand_size[6] = { "No EmuNAND", "O3DS NAND size", "N3DS NAND size", "1GB (legacy size)", "2GB (legacy size)", "User input..." };
|
||||||
const char* option_cluster_size[4] = { "Auto", "16KB Clusters", "32KB Clusters", "64KB Clusters" };
|
const char* option_cluster_size[4] = { "Auto", "16KB Clusters", "32KB Clusters", "64KB Clusters" };
|
||||||
|
char label[16] = "0:GM9SD";
|
||||||
u32 cluster_size = 0;
|
u32 cluster_size = 0;
|
||||||
u64 sdcard_size_mb = 0;
|
u64 sdcard_size_mb = 0;
|
||||||
u64 emunand_size_mb = (u64) -1;
|
u64 emunand_size_mb = (u64) -1;
|
||||||
@ -225,7 +226,10 @@ u32 SdFormatMenu(void) {
|
|||||||
if (!user_select) return 1;
|
if (!user_select) return 1;
|
||||||
else cluster_size = cluster_size_table[user_select];
|
else cluster_size = cluster_size_table[user_select];
|
||||||
|
|
||||||
if (!FormatSDCard(emunand_size_mb, cluster_size)) {
|
if (!ShowStringPrompt(label + 2, 9, "Format SD card (%lluMB)?\nEnter label:", sdcard_size_mb))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (!FormatSDCard(emunand_size_mb, cluster_size, label)) {
|
||||||
ShowPrompt(false, "Format SD: failed!");
|
ShowPrompt(false, "Format SD: failed!");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user