Skip to content

Commit 42fc2fb

Browse files
authored
When FFat is mounted before SD, then filesystem reports wrong system sizes (#8520)
* Fixes wrong usedbytes/totalbytes results. drive id was implemented fixed, does not work with arbitrary initialization. See #3546 * Fixing indention/tabs
1 parent f197150 commit 42fc2fb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Diff for: libraries/SD/src/SD.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,9 @@ uint64_t SDFS::totalBytes()
9595
{
9696
FATFS* fsinfo;
9797
DWORD fre_clust;
98-
if(f_getfree("0:",&fre_clust,&fsinfo)!= 0) return 0;
99-
uint64_t size = ((uint64_t)(fsinfo->csize))*(fsinfo->n_fatent - 2)
98+
char drv[3] = {(char)(48+_pdrv), ':', 0};
99+
if(f_getfree(drv,&fre_clust,&fsinfo)!= 0) return 0;
100+
uint64_t size = ((uint64_t)(fsinfo->csize))*(fsinfo->n_fatent - 2)
100101
#if _MAX_SS != 512
101102
*(fsinfo->ssize);
102103
#else
@@ -109,7 +110,8 @@ uint64_t SDFS::usedBytes()
109110
{
110111
FATFS* fsinfo;
111112
DWORD fre_clust;
112-
if(f_getfree("0:",&fre_clust,&fsinfo)!= 0) return 0;
113+
char drv[3] = {(char)(48+_pdrv), ':', 0};
114+
if(f_getfree(drv,&fre_clust,&fsinfo)!= 0) return 0;
113115
uint64_t size = ((uint64_t)(fsinfo->csize))*((fsinfo->n_fatent - 2) - (fsinfo->free_clst))
114116
#if _MAX_SS != 512
115117
*(fsinfo->ssize);

0 commit comments

Comments
 (0)