Skip to content

Commit efcb9a0

Browse files
committed
Un-comment f_getfree
In fatfs drivers for various targets.
1 parent 979a884 commit efcb9a0

File tree

2 files changed

+32
-40
lines changed

2 files changed

+32
-40
lines changed

targets/ChibiOS/_FatFs/fatfs_FS_Driver.cpp

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -168,34 +168,30 @@ HRESULT FATFS_FS_Driver::GetSizeInfo(const VOLUME_ID *volume, int64_t *totalSize
168168
{
169169
(void)totalSize;
170170

171-
// FATFS *fsPtr = &fs;
172-
// char buffer[3];
173-
// DWORD freeClusters, freeSectors, totalSectors;
171+
FATFS *fsPtr = &fs;
172+
char buffer[3];
173+
DWORD freeClusters, freeSectors, totalSectors;
174174

175-
// FATFS *fs = GetFatFsByVolumeId(volume, false);
175+
FATFS *fs = GetFatFsByVolumeId(volume, false);
176176

177177
FileSystemVolume *currentVolume = FileSystemVolumeList::FindVolume(volume->volumeId);
178178

179179
f_chdrive(currentVolume->m_rootName);
180180

181-
// this call is prone to take a long time, thus hitting the watchdog, therefore we are skipping this for now
182-
// // get free clusters
183-
// f_getfree(buffer, &freeClusters, &fsPtr);
181+
// get free clusters
182+
f_getfree(buffer, &freeClusters, &fsPtr);
184183

185-
// // Get total sectors and free sectors
186-
// totalSectors = (fs.n_fatent - 2) * fs.csize;
187-
// freeSectors = freeClusters * fs.csize;
184+
// Get total sectors and free sectors
185+
totalSectors = (fs.n_fatent - 2) * fs.csize;
186+
freeSectors = freeClusters * fs.csize;
188187

189-
// #if FF_MAX_SS != FF_MIN_SS
190-
// *totalSize = (int64_t)totalSectors * fs.ssize;
191-
// *totalFreeSpace = (int64_t)freeSectors * fs.ssize;
192-
// #else
193-
// *totalSize = (int64_t)totalSectors * FF_MAX_SS;
194-
// *totalFreeSpace = (int64_t)freeSectors * FF_MAX_SS;
195-
// #endif
196-
197-
*totalSize = -1;
198-
*totalFreeSpace = -1;
188+
#if FF_MAX_SS != FF_MIN_SS
189+
*totalSize = (int64_t)totalSectors * fs.ssize;
190+
*totalFreeSpace = (int64_t)freeSectors * fs.ssize;
191+
#else
192+
*totalSize = (int64_t)totalSectors * FF_MAX_SS;
193+
*totalFreeSpace = (int64_t)freeSectors * FF_MAX_SS;
194+
#endif
199195

200196
return S_OK;
201197
}

targets/ESP32/_FatFs/fatfs_FS_Driver.cpp

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -83,34 +83,30 @@ HRESULT FATFS_FS_Driver::GetSizeInfo(const VOLUME_ID *volume, int64_t *totalSize
8383
{
8484
(void)totalSize;
8585

86-
// FATFS *fsPtr = &fs;
87-
// char buffer[3];
88-
// DWORD freeClusters, freeSectors, totalSectors;
86+
FATFS *fsPtr = &fs;
87+
char buffer[3];
88+
DWORD freeClusters, freeSectors, totalSectors;
8989

90-
// FATFS *fs = GetFatFsByVolumeId(volume, false);
90+
FATFS *fs = GetFatFsByVolumeId(volume, false);
9191

9292
FileSystemVolume *currentVolume = FileSystemVolumeList::FindVolume(volume->volumeId);
9393

9494
f_chdrive(currentVolume->m_rootName);
9595

96-
// this call is prone to take a long time, thus hitting the watchdog, therefore we are skipping this for now
97-
// // get free clusters
98-
// f_getfree(buffer, &freeClusters, &fsPtr);
96+
// get free clusters
97+
f_getfree(buffer, &freeClusters, &fsPtr);
9998

100-
// // Get total sectors and free sectors
101-
// totalSectors = (fs.n_fatent - 2) * fs.csize;
102-
// freeSectors = freeClusters * fs.csize;
99+
// Get total sectors and free sectors
100+
totalSectors = (fs.n_fatent - 2) * fs.csize;
101+
freeSectors = freeClusters * fs.csize;
103102

104-
// #if FF_MAX_SS != FF_MIN_SS
105-
// *totalSize = (int64_t)totalSectors * fs.ssize;
106-
// *totalFreeSpace = (int64_t)freeSectors * fs.ssize;
107-
// #else
108-
// *totalSize = (int64_t)totalSectors * FF_MAX_SS;
109-
// *totalFreeSpace = (int64_t)freeSectors * FF_MAX_SS;
110-
// #endif
111-
112-
*totalSize = -1;
113-
*totalFreeSpace = -1;
103+
#if FF_MAX_SS != FF_MIN_SS
104+
*totalSize = (int64_t)totalSectors * fs.ssize;
105+
*totalFreeSpace = (int64_t)freeSectors * fs.ssize;
106+
#else
107+
*totalSize = (int64_t)totalSectors * FF_MAX_SS;
108+
*totalFreeSpace = (int64_t)freeSectors * FF_MAX_SS;
109+
#endif
114110

115111
return S_OK;
116112
}

0 commit comments

Comments
 (0)