Shrink root dir size for tiny (<=128K) FAT12 fs

This commit is contained in:
Bob Abeles 2023-11-06 16:03:30 -08:00
parent ccd667d97a
commit 966e6e4fe5
3 changed files with 4 additions and 3 deletions

View File

@ -5422,7 +5422,7 @@ FRESULT f_mkfs (
) )
{ {
const UINT n_fats = 1; /* Number of FATs for FAT/FAT32 volume (1 or 2) */ const UINT n_fats = 1; /* Number of FATs for FAT/FAT32 volume (1 or 2) */
const UINT n_rootdir = 512; /* Number of root directory entries for FAT volume */ UINT n_rootdir = 512; /* Number of root directory entries for FAT volume */
static const WORD cst[] = {1, 4, 16, 64, 256, 512, 0}; /* Cluster size boundary for FAT volume (4Ks unit) */ static const WORD cst[] = {1, 4, 16, 64, 256, 512, 0}; /* Cluster size boundary for FAT volume (4Ks unit) */
#if FF_MKFS_FAT32 #if FF_MKFS_FAT32
static const WORD cst32[] = {1, 2, 4, 8, 16, 32, 0}; /* Cluster size boundary for FAT32 volume (128Ks unit) */ static const WORD cst32[] = {1, 2, 4, 8, 16, 32, 0}; /* Cluster size boundary for FAT32 volume (128Ks unit) */
@ -5703,6 +5703,7 @@ FRESULT f_mkfs (
} }
sz_fat = (n + ss - 1) / ss; /* FAT size [sector] */ sz_fat = (n + ss - 1) / ss; /* FAT size [sector] */
sz_rsv = 1; /* Number of reserved sectors */ sz_rsv = 1; /* Number of reserved sectors */
n_rootdir = (sz_vol <= 256)? 64 : n_rootdir; /* Shrink root dir for <= 128K device */
sz_dir = (DWORD)n_rootdir * SZDIRE / ss; /* Rootdir size [sector] */ sz_dir = (DWORD)n_rootdir * SZDIRE / ss; /* Rootdir size [sector] */
} }
b_fat = b_vol + sz_rsv; /* FAT base */ b_fat = b_vol + sz_rsv; /* FAT base */

View File

@ -1,5 +1,5 @@
test <class 'VfsFat'> test <class 'VfsFat'>
(512, 512, 16, 16, 16, 0, 0, 0, 0, 255) (512, 512, 44, 44, 44, 0, 0, 0, 0, 255)
[('test', 32768, 0, 90)] [('test', 32768, 0, 90)]
some datasome datasome datasome datasome datasome datasome datasome datasome datasome data some datasome datasome datasome datasome datasome datasome datasome datasome datasome data
test <class 'VfsLfs2'> test <class 'VfsLfs2'>

View File

@ -1,7 +1,7 @@
True True
True True
label: LABEL TEST label: LABEL TEST
statvfs: (512, 512, 16, 16, 16, 0, 0, 0, 0, 255) statvfs: (512, 512, 44, 44, 44, 0, 0, 0, 0, 255)
getcwd: / getcwd: /
True True
[('foo_file.txt', 32768, 0, 6)] [('foo_file.txt', 32768, 0, 6)]