@@ -278,6 +278,7 @@ typedef struct {
278278
279279
280280/* SBCS up-case tables (\x80-\xFF) */
281+ // CIRCUITPY-CHANGE
281282// Optimize the 437-only case with a truncated lookup table.
282283#if FF_CODE_PAGE == 437
283284#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
11871188 break ;
11881189 }
11891190 }
1191+ // CIRCUITPY-CHANGE: explicit fallthrough
11901192 MP_FALLTHROUGH
11911193 /* go to default */
11921194#endif
@@ -1997,6 +1999,7 @@ static void gen_numname (
19971999 if (c > '9' ) c += 7 ;
19982000 ns [i -- ] = c ;
19992001 seq /= 16 ;
2002+ // CIRCUITPY-CHANGE: limit to 8 digits
20002003 } while (seq && i > 0 );
20012004 ns [i ] = '~' ;
20022005
@@ -2894,6 +2897,7 @@ static FRESULT create_name ( /* FR_OK: successful, FR_INVALID_NAME: could not
28942897 }
28952898#elif FF_CODE_PAGE < 900 /* SBCS cfg */
28962899 wc = ff_uni2oem (wc , CODEPAGE ); /* Unicode ==> ANSI/OEM code */
2900+ // CIRCUITPY-CHANGE
28972901 // Optimize the 437-only case with a truncated lookup table.
28982902#if FF_CODE_PAGE == 437
28992903 if (wc & 0x80 && wc < (0xA5 - 0x80 )) wc = ExCvt [wc & 0x7F ]; /* Convert extended character to upper (SBCS) */
@@ -4832,7 +4836,7 @@ FRESULT f_rename (
48324836 DWORD dw ;
48334837 DEF_NAMBUF
48344838
4835-
4839+ // CIRCUITPY-CHANGE
48364840 // Check to see if we're moving a directory into itself. This occurs when we're moving a
48374841 // directory where the old path is a prefix of the new and the next character is a "/" and thus
48384842 // preserves the original directory name.
@@ -5425,6 +5429,7 @@ FRESULT f_mkfs (
54255429 // CIRCUITPY-CHANGE: Make number of root directory entries changeable. See below.
54265430 UINT n_rootdir = 512 ; /* Default number of root directory entries for FAT volume */
54275431 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
54285433#if FF_MKFS_FAT32
54295434 static const WORD cst32 [] = {1 , 2 , 4 , 8 , 16 , 32 , 0 }; /* Cluster size boundary for FAT32 volume (128Ks unit) */
54305435#endif
@@ -5439,6 +5444,7 @@ FRESULT f_mkfs (
54395444 DWORD tbl [3 ];
54405445#endif
54415446
5447+ // CIRCUITPY-CHANGE: random volids
54425448 DWORD volid = MAKE_VOLID ();
54435449
54445450 /* Check mounted drive and clear work area */
@@ -5500,6 +5506,7 @@ FRESULT f_mkfs (
55005506 }
55015507 }
55025508 if (au > 128 ) LEAVE_MKFS (FR_INVALID_PARAMETER ); /* Too large au for FAT/FAT32 */
5509+ // CIRCUITPY-CHANGE: optional FAT32 support
55035510 if (FF_MKFS_FAT32 && (opt & FM_FAT32 )) { /* FAT32 possible? */
55045511 if ((opt & FM_ANY ) == FM_FAT32 || !(opt & FM_FAT )) { /* FAT32 only or no-FAT? */
55055512 fmt = FS_FAT32 ; break ;
@@ -5555,6 +5562,7 @@ FRESULT f_mkfs (
55555562 }
55565563 st = 1 ; /* Do not compress short run */
55575564 /* go to next case */
5565+ // CIRCUITPY-CHANGE: explicit fallthrough
55585566 MP_FALLTHROUGH
55595567 case 1 :
55605568 ch = si ++ ; /* Fill the short run */
@@ -5641,6 +5649,7 @@ FRESULT f_mkfs (
56415649 st_dword (buf + BPB_DataOfsEx , b_data - b_vol ); /* Data offset [sector] */
56425650 st_dword (buf + BPB_NumClusEx , n_clst ); /* Number of clusters */
56435651 st_dword (buf + BPB_RootClusEx , 2 + tbl [0 ] + tbl [1 ]); /* Root dir cluster # */
5652+ // CIRCUITPY-CHANGE: random volids
56445653 st_dword (buf + BPB_VolIDEx , volid ); /* VSN */
56455654 st_word (buf + BPB_FSVerEx , 0x100 ); /* Filesystem version (1.00) */
56465655 for (buf [BPB_BytsPerSecEx ] = 0 , i = ss ; i >>= 1 ; buf [BPB_BytsPerSecEx ]++ ) ; /* Log2 of sector size [byte] */
@@ -5677,6 +5686,7 @@ FRESULT f_mkfs (
56775686 do {
56785687 pau = au ;
56795688 /* Pre-determine number of clusters and FAT sub-type */
5689+ // CIRCUITPY-CHANGE: optional FAT32 support
56805690#if FF_MKFS_FAT32
56815691 if (fmt == FS_FAT32 ) { /* FAT32 volume */
56825692 if (pau == 0 ) { /* au auto-selection */
@@ -5725,6 +5735,7 @@ FRESULT f_mkfs (
57255735 /* Determine number of clusters and final check of validity of the FAT sub-type */
57265736 if (sz_vol < b_data + pau * 16 - b_vol ) LEAVE_MKFS (FR_MKFS_ABORTED ); /* Too small volume */
57275737 n_clst = (sz_vol - sz_rsv - sz_fat * n_fats - sz_dir ) / pau ;
5738+ // CIRCUITPY-CHANGE: optional FAT32 support
57285739#if FF_MKFS_FAT32
57295740 if (fmt == FS_FAT32 ) {
57305741 if (n_clst <= MAX_FAT16 ) { /* Too few clusters for FAT32 */
@@ -5766,6 +5777,7 @@ FRESULT f_mkfs (
57665777 buf [BPB_SecPerClus ] = (BYTE )pau ; /* Cluster size [sector] */
57675778 st_word (buf + BPB_RsvdSecCnt , (WORD )sz_rsv ); /* Size of reserved area */
57685779 buf [BPB_NumFATs ] = (BYTE )n_fats ; /* Number of FATs */
5780+ // CIRCUITPY-CHANGE: optional FAT32 support
57695781#if FF_MKFS_FAT32
57705782 st_word (buf + BPB_RootEntCnt , (WORD )((fmt == FS_FAT32 ) ? 0 : n_rootdir )); /* Number of root directory entries */
57715783#else
@@ -5780,6 +5792,7 @@ FRESULT f_mkfs (
57805792 st_word (buf + BPB_SecPerTrk , 63 ); /* Number of sectors per track (for int13) */
57815793 st_word (buf + BPB_NumHeads , 255 ); /* Number of heads (for int13) */
57825794 st_dword (buf + BPB_HiddSec , b_vol ); /* Volume offset in the physical drive [sector] */
5795+ // CIRCUITPY-CHANGE: optional FAT32 support
57835796#if FF_MKFS_FAT32
57845797 if (fmt == FS_FAT32 ) {
57855798 st_dword (buf + BS_VolID32 , volid ); /* VSN */
@@ -5803,6 +5816,7 @@ FRESULT f_mkfs (
58035816 if (disk_write (pdrv , buf , b_vol , 1 ) != RES_OK ) LEAVE_MKFS (FR_DISK_ERR ); /* Write it to the VBR sector */
58045817
58055818 /* Create FSINFO record if needed */
5819+ // CIRCUITPY-CHANGE: optional FAT32 support
58065820#if FF_MKFS_FAT32
58075821 if (fmt == FS_FAT32 ) {
58085822 disk_write (pdrv , buf , b_vol + 6 , 1 ); /* Write backup VBR (VBR + 6) */
@@ -5821,6 +5835,7 @@ FRESULT f_mkfs (
58215835 mem_set (buf , 0 , (UINT )szb_buf );
58225836 sect = b_fat ; /* FAT start sector */
58235837 for (i = 0 ; i < n_fats ; i ++ ) { /* Initialize FATs each */
5838+ // CIRCUITPY-CHANGE: optional FAT32 support
58245839#if FF_MKFS_FAT32
58255840 if (fmt == FS_FAT32 ) {
58265841 st_dword (buf + 0 , 0xFFFFFFF8 ); /* Entry 0 */
@@ -5841,6 +5856,7 @@ FRESULT f_mkfs (
58415856 }
58425857
58435858 /* Initialize root directory (fill with zero) */
5859+ // CIRCUITPY-CHANGE: optional FAT32 support
58445860#if FF_MKFS_FAT32
58455861 nsect = (fmt == FS_FAT32 ) ? pau : sz_dir ; /* Number of root directory sectors */
58465862#else
@@ -5857,6 +5873,7 @@ FRESULT f_mkfs (
58575873 if (FF_FS_EXFAT && fmt == FS_EXFAT ) {
58585874 sys = 0x07 ; /* HPFS/NTFS/exFAT */
58595875 } else {
5876+ // CIRCUITPY-CHANGE: optional FAT32 support
58605877 if (FF_MKFS_FAT32 && fmt == FS_FAT32 ) {
58615878 sys = 0x0C ; /* FAT32X */
58625879 } else {
0 commit comments