@@ -278,6 +278,7 @@ typedef struct {
278
278
279
279
280
280
/* SBCS up-case tables (\x80-\xFF) */
281
+ // CIRCUITPY-CHANGE
281
282
// Optimize the 437-only case with a truncated lookup table.
282
283
#if FF_CODE_PAGE == 437
283
284
#define TBL_CT437 {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \
@@ -1187,6 +1188,7 @@ static DWORD get_fat ( /* 0xFFFFFFFF:Disk error, 1:Internal error, 2..0x7FF
1187
1188
break ;
1188
1189
}
1189
1190
}
1191
+ // CIRCUITPY-CHANGE: explicit fallthrough
1190
1192
MP_FALLTHROUGH
1191
1193
/* go to default */
1192
1194
#endif
@@ -1997,6 +1999,7 @@ static void gen_numname (
1997
1999
if (c > '9' ) c += 7 ;
1998
2000
ns [i -- ] = c ;
1999
2001
seq /= 16 ;
2002
+ // CIRCUITPY-CHANGE: limit to 8 digits
2000
2003
} while (seq && i > 0 );
2001
2004
ns [i ] = '~' ;
2002
2005
@@ -2894,6 +2897,7 @@ static FRESULT create_name ( /* FR_OK: successful, FR_INVALID_NAME: could not
2894
2897
}
2895
2898
#elif FF_CODE_PAGE < 900 /* SBCS cfg */
2896
2899
wc = ff_uni2oem (wc , CODEPAGE ); /* Unicode ==> ANSI/OEM code */
2900
+ // CIRCUITPY-CHANGE
2897
2901
// Optimize the 437-only case with a truncated lookup table.
2898
2902
#if FF_CODE_PAGE == 437
2899
2903
if (wc & 0x80 && wc < (0xA5 - 0x80 )) wc = ExCvt [wc & 0x7F ]; /* Convert extended character to upper (SBCS) */
@@ -4832,7 +4836,7 @@ FRESULT f_rename (
4832
4836
DWORD dw ;
4833
4837
DEF_NAMBUF
4834
4838
4835
-
4839
+ // CIRCUITPY-CHANGE
4836
4840
// Check to see if we're moving a directory into itself. This occurs when we're moving a
4837
4841
// directory where the old path is a prefix of the new and the next character is a "/" and thus
4838
4842
// preserves the original directory name.
@@ -5425,6 +5429,7 @@ FRESULT f_mkfs (
5425
5429
// CIRCUITPY-CHANGE: Make number of root directory entries changeable. See below.
5426
5430
UINT n_rootdir = 512 ; /* Default number of root directory entries for FAT volume */
5427
5431
static const WORD cst [] = {1 , 4 , 16 , 64 , 256 , 512 , 0 }; /* Cluster size boundary for FAT volume (4Ks unit) */
5432
+ // CIRCUITPY-CHANGE: optional FAT32 support
5428
5433
#if FF_MKFS_FAT32
5429
5434
static const WORD cst32 [] = {1 , 2 , 4 , 8 , 16 , 32 , 0 }; /* Cluster size boundary for FAT32 volume (128Ks unit) */
5430
5435
#endif
@@ -5439,6 +5444,7 @@ FRESULT f_mkfs (
5439
5444
DWORD tbl [3 ];
5440
5445
#endif
5441
5446
5447
+ // CIRCUITPY-CHANGE: random volids
5442
5448
DWORD volid = MAKE_VOLID ();
5443
5449
5444
5450
/* Check mounted drive and clear work area */
@@ -5500,6 +5506,7 @@ FRESULT f_mkfs (
5500
5506
}
5501
5507
}
5502
5508
if (au > 128 ) LEAVE_MKFS (FR_INVALID_PARAMETER ); /* Too large au for FAT/FAT32 */
5509
+ // CIRCUITPY-CHANGE: optional FAT32 support
5503
5510
if (FF_MKFS_FAT32 && (opt & FM_FAT32 )) { /* FAT32 possible? */
5504
5511
if ((opt & FM_ANY ) == FM_FAT32 || !(opt & FM_FAT )) { /* FAT32 only or no-FAT? */
5505
5512
fmt = FS_FAT32 ; break ;
@@ -5555,6 +5562,7 @@ FRESULT f_mkfs (
5555
5562
}
5556
5563
st = 1 ; /* Do not compress short run */
5557
5564
/* go to next case */
5565
+ // CIRCUITPY-CHANGE: explicit fallthrough
5558
5566
MP_FALLTHROUGH
5559
5567
case 1 :
5560
5568
ch = si ++ ; /* Fill the short run */
@@ -5641,6 +5649,7 @@ FRESULT f_mkfs (
5641
5649
st_dword (buf + BPB_DataOfsEx , b_data - b_vol ); /* Data offset [sector] */
5642
5650
st_dword (buf + BPB_NumClusEx , n_clst ); /* Number of clusters */
5643
5651
st_dword (buf + BPB_RootClusEx , 2 + tbl [0 ] + tbl [1 ]); /* Root dir cluster # */
5652
+ // CIRCUITPY-CHANGE: random volids
5644
5653
st_dword (buf + BPB_VolIDEx , volid ); /* VSN */
5645
5654
st_word (buf + BPB_FSVerEx , 0x100 ); /* Filesystem version (1.00) */
5646
5655
for (buf [BPB_BytsPerSecEx ] = 0 , i = ss ; i >>= 1 ; buf [BPB_BytsPerSecEx ]++ ) ; /* Log2 of sector size [byte] */
@@ -5677,6 +5686,7 @@ FRESULT f_mkfs (
5677
5686
do {
5678
5687
pau = au ;
5679
5688
/* Pre-determine number of clusters and FAT sub-type */
5689
+ // CIRCUITPY-CHANGE: optional FAT32 support
5680
5690
#if FF_MKFS_FAT32
5681
5691
if (fmt == FS_FAT32 ) { /* FAT32 volume */
5682
5692
if (pau == 0 ) { /* au auto-selection */
@@ -5725,6 +5735,7 @@ FRESULT f_mkfs (
5725
5735
/* Determine number of clusters and final check of validity of the FAT sub-type */
5726
5736
if (sz_vol < b_data + pau * 16 - b_vol ) LEAVE_MKFS (FR_MKFS_ABORTED ); /* Too small volume */
5727
5737
n_clst = (sz_vol - sz_rsv - sz_fat * n_fats - sz_dir ) / pau ;
5738
+ // CIRCUITPY-CHANGE: optional FAT32 support
5728
5739
#if FF_MKFS_FAT32
5729
5740
if (fmt == FS_FAT32 ) {
5730
5741
if (n_clst <= MAX_FAT16 ) { /* Too few clusters for FAT32 */
@@ -5766,6 +5777,7 @@ FRESULT f_mkfs (
5766
5777
buf [BPB_SecPerClus ] = (BYTE )pau ; /* Cluster size [sector] */
5767
5778
st_word (buf + BPB_RsvdSecCnt , (WORD )sz_rsv ); /* Size of reserved area */
5768
5779
buf [BPB_NumFATs ] = (BYTE )n_fats ; /* Number of FATs */
5780
+ // CIRCUITPY-CHANGE: optional FAT32 support
5769
5781
#if FF_MKFS_FAT32
5770
5782
st_word (buf + BPB_RootEntCnt , (WORD )((fmt == FS_FAT32 ) ? 0 : n_rootdir )); /* Number of root directory entries */
5771
5783
#else
@@ -5780,6 +5792,7 @@ FRESULT f_mkfs (
5780
5792
st_word (buf + BPB_SecPerTrk , 63 ); /* Number of sectors per track (for int13) */
5781
5793
st_word (buf + BPB_NumHeads , 255 ); /* Number of heads (for int13) */
5782
5794
st_dword (buf + BPB_HiddSec , b_vol ); /* Volume offset in the physical drive [sector] */
5795
+ // CIRCUITPY-CHANGE: optional FAT32 support
5783
5796
#if FF_MKFS_FAT32
5784
5797
if (fmt == FS_FAT32 ) {
5785
5798
st_dword (buf + BS_VolID32 , volid ); /* VSN */
@@ -5803,6 +5816,7 @@ FRESULT f_mkfs (
5803
5816
if (disk_write (pdrv , buf , b_vol , 1 ) != RES_OK ) LEAVE_MKFS (FR_DISK_ERR ); /* Write it to the VBR sector */
5804
5817
5805
5818
/* Create FSINFO record if needed */
5819
+ // CIRCUITPY-CHANGE: optional FAT32 support
5806
5820
#if FF_MKFS_FAT32
5807
5821
if (fmt == FS_FAT32 ) {
5808
5822
disk_write (pdrv , buf , b_vol + 6 , 1 ); /* Write backup VBR (VBR + 6) */
@@ -5821,6 +5835,7 @@ FRESULT f_mkfs (
5821
5835
mem_set (buf , 0 , (UINT )szb_buf );
5822
5836
sect = b_fat ; /* FAT start sector */
5823
5837
for (i = 0 ; i < n_fats ; i ++ ) { /* Initialize FATs each */
5838
+ // CIRCUITPY-CHANGE: optional FAT32 support
5824
5839
#if FF_MKFS_FAT32
5825
5840
if (fmt == FS_FAT32 ) {
5826
5841
st_dword (buf + 0 , 0xFFFFFFF8 ); /* Entry 0 */
@@ -5841,6 +5856,7 @@ FRESULT f_mkfs (
5841
5856
}
5842
5857
5843
5858
/* Initialize root directory (fill with zero) */
5859
+ // CIRCUITPY-CHANGE: optional FAT32 support
5844
5860
#if FF_MKFS_FAT32
5845
5861
nsect = (fmt == FS_FAT32 ) ? pau : sz_dir ; /* Number of root directory sectors */
5846
5862
#else
@@ -5857,6 +5873,7 @@ FRESULT f_mkfs (
5857
5873
if (FF_FS_EXFAT && fmt == FS_EXFAT ) {
5858
5874
sys = 0x07 ; /* HPFS/NTFS/exFAT */
5859
5875
} else {
5876
+ // CIRCUITPY-CHANGE: optional FAT32 support
5860
5877
if (FF_MKFS_FAT32 && fmt == FS_FAT32 ) {
5861
5878
sys = 0x0C ; /* FAT32X */
5862
5879
} else {
0 commit comments