From 8f203aa5c5891aec9a1201275438f3ca2a43e6e3 Mon Sep 17 00:00:00 2001 From: Pk11 Date: Sat, 15 Jan 2022 02:57:45 -0600 Subject: [PATCH] Show how much space is free on NAND itself --- arm9/src/storage.c | 27 +++++++++++++++-------- arm9/src/storage.h | 3 ++- arm9/src/testmenu.c | 53 +++++++++++++++++++++++++-------------------- 3 files changed, 49 insertions(+), 34 deletions(-) diff --git a/arm9/src/storage.c b/arm9/src/storage.c index c8df794..f6631e1 100644 --- a/arm9/src/storage.c +++ b/arm9/src/storage.c @@ -512,15 +512,6 @@ unsigned long long getDsiSize() return 1024 * BYTES_PER_BLOCK; } -unsigned long long getDsiRealFree() -{ - struct statvfs st; - if (statvfs(sdnandMode ? "sd:/" : "nand:/", &st) == 0) - return st.f_bsize * st.f_bavail; - - return 0; -} - unsigned long long getDsiFree() { u32 blockSize = getDsiClusterSize(); @@ -544,6 +535,24 @@ unsigned long long getDsiFree() return (realFree < size) ? realFree : size; } +unsigned long long getDsiRealSize() +{ + struct statvfs st; + if (statvfs(sdnandMode ? "sd:/" : "nand:/", &st) == 0) + return st.f_bsize * st.f_blocks; + + return 0; +} + +unsigned long long getDsiRealFree() +{ + struct statvfs st; + if (statvfs(sdnandMode ? "sd:/" : "nand:/", &st) == 0) + return st.f_bsize * st.f_bavail; + + return 0; +} + u32 getDsiClusterSize() { struct statvfs st; diff --git a/arm9/src/storage.h b/arm9/src/storage.h index ace54be..61d4005 100644 --- a/arm9/src/storage.h +++ b/arm9/src/storage.h @@ -41,8 +41,9 @@ unsigned long long getSDCardFree(); //internal storage unsigned long long getDsiSize(); -unsigned long long getDsiRealFree(); unsigned long long getDsiFree(); +unsigned long long getDsiRealSize(); +unsigned long long getDsiRealFree(); u32 getDsiClusterSize(); #define getDsiUsed() (getDSIStorageSize() - getDSIStorageFree()) diff --git a/arm9/src/testmenu.c b/arm9/src/testmenu.c index 091f667..bae29fa 100644 --- a/arm9/src/testmenu.c +++ b/arm9/src/testmenu.c @@ -17,53 +17,58 @@ void testMenu() //home menu slots { iprintf("Free Home Menu Slots:\n"); - swiWaitForVBlank(); free = getMenuSlotsFree(); iprintf("\t%d / ", free); - swiWaitForVBlank(); size = getMenuSlots(); iprintf("%d\n", size); - swiWaitForVBlank(); + } + + //dsi menu + { + iprintf("\nFree DSi Menu Space:\n\t"); + + free = getDsiFree(); + printBytes(free); + iprintf(" / "); + + size = getDsiSize(); + printBytes(size); + iprintf("\n"); + + iprintf("\t%d / %d blocks\n", free / BYTES_PER_BLOCK, size / BYTES_PER_BLOCK); + } + + //nand + if (!sdnandMode) + { + iprintf("\nFree NAND Space:\n\t"); + + free = getDsiRealFree(); + printBytes(free); + iprintf(" / "); + + size = getDsiRealSize(); + printBytes(size); + iprintf("\n"); } //SD Card { iprintf("\nFree SD Space:\n\t"); - swiWaitForVBlank(); unsigned long long sdfree = getSDCardFree(); printBytes(sdfree); iprintf(" / "); - swiWaitForVBlank(); unsigned long long sdsize = getSDCardSize(); printBytes(sdsize); iprintf("\n"); - swiWaitForVBlank(); printf("\t%d / %d blocks\n", (unsigned int)(sdfree / BYTES_PER_BLOCK), (unsigned int)(sdsize / BYTES_PER_BLOCK)); } - //Emunand - { - iprintf("\nFree DSi Space:\n\t"); - swiWaitForVBlank(); - - free = getDsiFree(); - printBytes(free); - iprintf(" / "); - swiWaitForVBlank(); - - size = getDsiSize(); - printBytes(size); - iprintf("\n"); - swiWaitForVBlank(); - - iprintf("\t%d / %d blocks\n", free / BYTES_PER_BLOCK, size / BYTES_PER_BLOCK); - } - //end iprintf("\nBack - [B]\n"); keyWait(KEY_B);