File tree Expand file tree Collapse file tree 4 files changed +7
-2
lines changed Expand file tree Collapse file tree 4 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ Version 7.1.0
4
4
- Added DITTO to duplicate code/data in Spin2 assembly
5
5
- Many internal changes to support DITTO and future assembly work
6
6
- Updated -gbrk debug code (thanks Ada)
7
+ - Use cluster size for stat() st_blksize on FAT32
7
8
8
9
Version 7.0.5
9
10
- Fixed internal handle usage to avoid conflicts with BASIC hard-coded handles
Original file line number Diff line number Diff line change @@ -224,6 +224,7 @@ int v_stat(const char *name, struct stat *buf)
224
224
int r;
225
225
FILINFO finfo;
226
226
unsigned mode;
227
+ unsigned clustersize = 4096 ;
227
228
#ifdef _DEBUG_FATFS
228
229
__builtin_printf (" v_stat(%s)\n " , name);
229
230
#endif
@@ -234,6 +235,7 @@ int v_stat(const char *name, struct stat *buf)
234
235
r = 0 ;
235
236
} else {
236
237
r = f_stat (name, &finfo);
238
+ clustersize = finfo.fclust ;
237
239
}
238
240
if (r != 0 ) {
239
241
return _set_dos_error (r);
@@ -248,8 +250,8 @@ int v_stat(const char *name, struct stat *buf)
248
250
buf->st_mode = mode;
249
251
buf->st_nlink = 1 ;
250
252
buf->st_size = finfo.fsize ;
251
- buf->st_blksize = 512 ;
252
- buf->st_blocks = (finfo.fsize + 511 ) / 512 ;
253
+ buf->st_blksize = clustersize ;
254
+ buf->st_blocks = (finfo.fsize + clustersize - 1 ) / clustersize ;
253
255
buf->st_atime = buf->st_mtime = buf->st_ctime = unixtime (finfo.fdate , finfo.ftime );
254
256
#ifdef _DEBUG_FATFS
255
257
__builtin_printf (" v_stat returning %d mode=0x%x\n " , r, buf->st_mode );
Original file line number Diff line number Diff line change @@ -4754,6 +4754,7 @@ FRESULT f_stat (
4754
4754
FREE_NAMBUF ();
4755
4755
}
4756
4756
4757
+ if (fno ) fno -> fclust = (DWORD )dj .obj .fs -> csize * SS (dj .obj .fs );
4757
4758
LEAVE_FF (dj .obj .fs , res );
4758
4759
}
4759
4760
Original file line number Diff line number Diff line change @@ -249,6 +249,7 @@ typedef struct {
249
249
WORD fdate ; /* Modified date */
250
250
WORD ftime ; /* Modified time */
251
251
BYTE fattrib ; /* File attribute */
252
+ DWORD fclust ; /* File cluster size in bytes */
252
253
#if FF_USE_LFN
253
254
TCHAR altname [FF_SFN_BUF + 1 ];/* Altenative file name */
254
255
TCHAR fname [FF_LFN_BUF + 1 ]; /* Primary file name */
You can’t perform that action at this time.
0 commit comments