R0.16 patch 2
September 13, 2025 From a suggestion in user forum, I have changed the minimum volume size from 128 sectors to 64 sectors. When create a volume on the very small drive with f_mkfs function, it is recommended to specify FM_SFD flag and set a proper value to n_root.
This commit is contained in:
+8
-4
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------/
|
||||
/ FatFs - Generic FAT Filesystem Module R0.16 /
|
||||
/ FatFs - Generic FAT Filesystem Module R0.16 w/patch 1 /
|
||||
/-----------------------------------------------------------------------------/
|
||||
/
|
||||
/ Copyright (C) 2025, ChaN, all right reserved.
|
||||
@@ -41,6 +41,8 @@
|
||||
#define MAX_FAT16 0xFFF5 /* Max FAT16 clusters (differs from specs, but right for real DOS/Windows behavior) */
|
||||
#define MAX_FAT32 0x0FFFFFF5 /* Max FAT32 clusters (not defined in specs, practical limit) */
|
||||
#define MAX_EXFAT 0x7FFFFFFD /* Max exFAT clusters (differs from specs, implementation limit) */
|
||||
#define MIN_FAT12 32 /* Min FAT12 clusters (Not defined in specs, implementation limit) */
|
||||
#define MIN_VOLUME 64 /* Min volume sectors (Not defined in specs, implementation limit) */
|
||||
|
||||
|
||||
/* Character code support macros */
|
||||
@@ -3392,7 +3394,7 @@ static UINT check_fs ( /* 0:FAT/FAT32 VBR, 1:exFAT VBR, 2:Not FAT and valid BS,
|
||||
&& ld_16(fs->win + BPB_RsvdSecCnt) != 0 /* Properness of number of reserved sectors (MNBZ) */
|
||||
&& (UINT)fs->win[BPB_NumFATs] - 1 <= 1 /* Properness of number of FATs (1 or 2) */
|
||||
&& ld_16(fs->win + BPB_RootEntCnt) != 0 /* Properness of root dir size (MNBZ) */
|
||||
&& (ld_16(fs->win + BPB_TotSec16) >= 128 || ld_32(fs->win + BPB_TotSec32) >= 0x10000) /* Properness of volume size (>=128) */
|
||||
&& (ld_16(fs->win + BPB_TotSec16) >= MIN_VOLUME || ld_32(fs->win + BPB_TotSec32) >= 0x10000) /* Properness of volume size (>=128) */
|
||||
&& ld_16(fs->win + BPB_FATSz16) != 0) { /* Properness of FAT size (MNBZ) */
|
||||
return 0; /* It can be presumed an FAT VBR */
|
||||
}
|
||||
@@ -3617,6 +3619,7 @@ static FRESULT mount_volume ( /* FR_OK(0): successful, !=0: an error occurred */
|
||||
if (nclst <= MAX_FAT32) fmt = FS_FAT32;
|
||||
if (nclst <= MAX_FAT16) fmt = FS_FAT16;
|
||||
if (nclst <= MAX_FAT12) fmt = FS_FAT12;
|
||||
if (nclst <= MIN_FAT12) fmt = 0;
|
||||
if (fmt == 0) return FR_NO_FILESYSTEM;
|
||||
|
||||
/* Boundaries and Limits */
|
||||
@@ -6157,7 +6160,7 @@ FRESULT f_mkfs (
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sz_vol < 128) LEAVE_MKFS(FR_MKFS_ABORTED); /* Check if volume size is >=128 sectors */
|
||||
if (sz_vol < MIN_VOLUME) LEAVE_MKFS(FR_MKFS_ABORTED); /* Check if volume size is not too small */
|
||||
|
||||
/* Now start to create an FAT volume at b_vol and sz_vol */
|
||||
|
||||
@@ -6389,7 +6392,8 @@ FRESULT f_mkfs (
|
||||
}
|
||||
|
||||
/* Determine number of clusters and final check of validity of the FAT sub-type */
|
||||
if (sz_vol < b_data + pau * 16 - b_vol) LEAVE_MKFS(FR_MKFS_ABORTED); /* Too small volume? */
|
||||
if (sz_vol < b_data + pau * MIN_FAT12 - b_vol) LEAVE_MKFS(FR_MKFS_ABORTED); /* Too small volume for this configuration? */
|
||||
|
||||
n_clst = ((DWORD)sz_vol - sz_rsv - sz_fat * n_fat - sz_dir) / pau;
|
||||
if (fsty == FS_FAT32) {
|
||||
if (n_clst <= MAX_FAT16) { /* Too few clusters for FAT32? */
|
||||
|
||||
Reference in New Issue
Block a user