diff --git a/arm9/src/storage.c b/arm9/src/storage.c index cfe03f5..c8df794 100644 --- a/arm9/src/storage.c +++ b/arm9/src/storage.c @@ -512,6 +512,15 @@ 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(); @@ -530,16 +539,9 @@ unsigned long long getDsiFree() size -= appSize; } - return size; -} + unsigned long long realFree = getDsiRealFree(); -unsigned long long getDsiRealFree() -{ - struct statvfs st; - if (statvfs(sdnandMode ? "sd:/" : "nand:/", &st) == 0) - return st.f_bsize * st.f_bavail; - - return 0; + return (realFree < size) ? realFree : size; } u32 getDsiClusterSize() diff --git a/arm9/src/storage.h b/arm9/src/storage.h index d99a6d3..ace54be 100644 --- a/arm9/src/storage.h +++ b/arm9/src/storage.h @@ -41,8 +41,8 @@ unsigned long long getSDCardFree(); //internal storage unsigned long long getDsiSize(); -unsigned long long getDsiFree(); unsigned long long getDsiRealFree(); +unsigned long long getDsiFree(); u32 getDsiClusterSize(); #define getDsiUsed() (getDSIStorageSize() - getDSIStorageFree())