147 #error Wrong include file (ff.h).
151 #if _MAX_SS != 512 && _MAX_SS != 1024 && _MAX_SS != 2048 && _MAX_SS != 4096
152 #error Wrong sector size.
155 #define SS(fs) ((fs)->ssize)
163 #error Static LFN work area cannot be used at thread-safe configuration.
166 #define ENTER_FF(fs) { if (!lock_fs(fs)) return FR_TIMEOUT; }
168 #define LEAVE_FF(fs, res) { unlock_fs(fs, res); return res; }
173 #define LEAVE_FF(fs, res) return res
177 #define ABORT(fs, res) { fp->err = (BYTE)(res); LEAVE_FF(fs, res); }
182 #error _FS_LOCK must be 0 at read-only cfg.
199 #if _CODE_PAGE == 932
209 #elif _CODE_PAGE == 936
217 #elif _CODE_PAGE == 949
227 #elif _CODE_PAGE == 950
235 #elif _CODE_PAGE == 437
237 #define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F,0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
238 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
239 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
240 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
242 #elif _CODE_PAGE == 720
244 #define _EXCVT {0x80,0x81,0x45,0x41,0x84,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x49,0x49,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
245 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
246 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
247 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
249 #elif _CODE_PAGE == 737
251 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \
252 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
253 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0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9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
373 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF}
375 #elif _CODE_PAGE == 1258
377 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0xAC,0x9D,0x9E,0x9F, \
378 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \
379 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
380 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xEC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xFE,0x9F}
382 #elif _CODE_PAGE == 1
384 #error Cannot use LFN feature without valid code page.
389 #error Unknown code page
394 #define IsUpper(c) (((c)>='A')&&((c)<='Z'))
395 #define IsLower(c) (((c)>='a')&&((c)<='z'))
396 #define IsDigit(c) (((c)>='0')&&((c)<='9'))
404 #define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E))
409 #define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E)
416 #define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E))
421 #define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E))
441 #define MIN_FAT16 4086U
442 #define MIN_FAT32 65526U
450 #define BPB_BytsPerSec 11
451 #define BPB_SecPerClus 13
452 #define BPB_RsvdSecCnt 14
453 #define BPB_NumFATs 16
454 #define BPB_RootEntCnt 17
456 #define BPB_TotSec16 19
458 #define BPB_FATSz16 22
459 #define BPB_SecPerTrk 24
460 #define BPB_NumHeads 26
461 #define BPB_HiddSec 28
463 #define BPB_TotSec32 32
465 #define BS_BootSig 38
468 #define BS_FilSysType 54
469 #define BPB_FATSz32 36
470 #define BPB_ExtFlags 40
472 #define BPB_RootClus 44
473 #define BPB_FSInfo 48
474 #define BPB_BkBootSec 50
475 #define BS_DrvNum32 64
476 #define BS_BootSig32 66
477 #define BS_VolID32 67
478 #define BS_VolLab32 71
479 #define BS_FilSysType32 82
480 #define FSI_LeadSig 0
481 #define FSI_StrucSig 484
482 #define FSI_Free_Count 488
483 #define FSI_Nxt_Free 492
484 #define MBR_Table 446
492 #define DIR_CrtTimeTenth 13
493 #define DIR_CrtTime 14
494 #define DIR_CrtDate 16
495 #define DIR_LstAccDate 18
496 #define DIR_FstClusHI 20
497 #define DIR_WrtTime 22
498 #define DIR_WrtDate 24
499 #define DIR_FstClusLO 26
500 #define DIR_FileSize 28
504 #define LDIR_Chksum 13
505 #define LDIR_FstClusLO 26
526 #error Number of volumes must not be 0.
531 #if _FS_RPATH && _VOLUMES >= 2
541 #define DEF_NAMEBUF BYTE sfn[12]
542 #define INIT_BUF(dobj) (dobj).fn = sfn
548 #define DEF_NAMEBUF BYTE sfn[12]
549 #define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = LfnBuf; }
554 #define DEF_NAMEBUF BYTE sfn[12]; WCHAR lbuf[_MAX_LFN+1]
555 #define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = lbuf; }
560 #define DEF_NAMEBUF BYTE sfn[12]; WCHAR *lfn
561 #define INIT_BUF(dobj) { \
562 lfn = ff_memalloc((_MAX_LFN + 1) * 2); \
564 LEAVE_FF((dobj).fs, FR_NOT_ENOUGH_CORE); \
568 #define FREE_BUF() ff_memfree(lfn)
571 #error Wrong LFN configuration.
575 static const BYTE ExCvt[] = _EXCVT;
607 static void mem_cpy(
void* dst,
const void* src, UINT cnt) {
608 BYTE *d = (BYTE*) dst;
609 const BYTE *s = (
const BYTE*) src;
611 #if _WORD_ACCESS == 1
612 while (cnt >=
sizeof (
int)) {
614 d +=
sizeof (int); s +=
sizeof (int);
628 static void mem_set(
void* dst,
int val, UINT cnt) {
629 BYTE *d = (BYTE*) dst;
642 static int mem_cmp(
const void* dst,
const void* src, UINT cnt) {
643 const BYTE *d = (
const BYTE *) dst, *s = (
const BYTE *) src;
646 while (cnt-- && (r = *d++ - *s++) == 0)
657 static int chk_chr(
const char* str,
int chr) {
658 while (*str && *str != chr)
679 static int lock_fs(
FATFS* fs) {
722 for (i = be = 0; i <
_FS_LOCK; i++) {
724 if (Files[i].fs == dp->
fs &&
725 Files[i].clu == dp->
sclust &&
726 Files[i].idx == dp->
index)
break;
744 static int enq_lock(
void) {
747 for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ;
748 return (i == _FS_LOCK) ? 0 : 1;
763 static UINT inc_lock(
DIR* dp,
int acc) {
768 if (Files[i].fs == dp->
fs &&
769 Files[i].clu == dp->
sclust &&
770 Files[i].idx == dp->
index)
break;
774 for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ;
775 if (i == _FS_LOCK)
return 0;
776 Files[i].fs = dp->
fs;
777 Files[i].clu = dp->
sclust;
778 Files[i].idx = dp->
index;
782 if (acc && Files[i].ctr)
return 0;
784 Files[i].ctr = acc ? 0x100 : Files[i].ctr + 1;
796 static FRESULT dec_lock(UINT i) {
800 if (--i < _FS_LOCK) {
802 if (n == 0x100) n = 0;
805 if (!n) Files[i].fs = 0;
819 static void clear_lock(
FATFS *fs) {
823 if (Files[i].fs == fs) Files[i].fs = 0;
851 if (disk_write(fs->
drv, fs->
win, wsect, 1))
855 for (nf = fs->
n_fats; nf >= 2; nf--) {
857 disk_write(fs->
drv, fs->
win, wsect, 1);
949 if (clst >= (fs->
n_fatent - 2))
return 0;
981 bc = (UINT)clst; bc += bc / 2;
983 wc = fs->
win[bc %
SS(fs)]; bc++;
985 wc |= fs->
win[bc %
SS(fs)] << 8;
986 return clst & 1 ? wc >> 4 : (wc & 0xFFF);
990 p = &fs->
win[clst * 2 %
SS(fs)];
995 p = &fs->
win[clst * 4 %
SS(fs)];
996 return LD_DWORD(p) & 0x0FFFFFFF;
1016 if (clst < 2 || clst >= fs->
n_fatent) {
1022 bc = (UINT)clst; bc += bc / 2;
1024 if (res !=
FR_OK)
break;
1025 p = &fs->
win[bc %
SS(fs)];
1026 *p = (clst & 1) ? ((*p & 0x0F) | ((BYTE)val << 4)) : (BYTE)val;
1030 if (res !=
FR_OK)
break;
1031 p = &fs->
win[bc %
SS(fs)];
1032 *p = (clst & 1) ? (BYTE)(val >> 4) : ((*p & 0xF0) | ((BYTE)(val >> 8) & 0x0F));
1037 if (res !=
FR_OK)
break;
1038 p = &fs->
win[clst * 2 %
SS(fs)];
1039 ST_WORD(p, (WORD)val);
1044 if (res !=
FR_OK)
break;
1045 p = &fs->
win[clst * 4 %
SS(fs)];
1046 val |= LD_DWORD(p) & 0xF0000000;
1081 DWORD scl = clst, ecl = clst, rt[2];
1084 if (clst < 2 || clst >= fs->
n_fatent) {
1089 while (clst < fs->n_fatent) {
1091 if (nxt == 0)
break;
1093 if (nxt == 0xFFFFFFFF) { res =
FR_DISK_ERR;
break; }
1095 if (res !=
FR_OK)
break;
1101 if (ecl + 1 == nxt) {
1135 if (!scl || scl >= fs->
n_fatent) scl = 1;
1139 if (cs < 2)
return 1;
1140 if (cs < fs->n_fatent)
return cs;
1149 if (ncl > scl)
return 0;
1153 if (cs == 0xFFFFFFFF || cs == 1)
1155 if (ncl == scl)
return 0;
1158 res =
put_fat(fs, ncl, 0x0FFFFFFF);
1159 if (res ==
FR_OK && clst != 0) {
1184 static DWORD clmt_clust (
1189 DWORD cl, ncl, *tbl;
1192 tbl = fp->cltbl + 1;
1197 if (cl < ncl)
break;
1229 if (!clst && dp->
fs->
fs_type == FS_FAT32)
1271 if (!i || !dp->
sect)
1298 for (c = 0; c < dp->
fs->
csize; c++) {
1338 if (res !=
FR_OK)
break;
1339 if (dp->
dir[0] ==
DDE || dp->
dir[0] == 0) {
1340 if (++n == nent)
break;
1345 }
while (res ==
FR_OK);
1376 static void st_clust(BYTE* dir, DWORD cl) {
1396 static const BYTE LfnOfs[] = {1,3,5,7,9,14,16,18,20,22,24,28,30};
1407 static int cmp_lfn (
1419 uc = LD_WORD(dir+LfnOfs[s]);
1421 wc = ff_wtoupper(uc);
1422 if (i >=
_MAX_LFN || wc != ff_wtoupper(lfnbuf[i++]))
1425 if (uc != 0xFFFF)
return 0;
1444 static int pick_lfn (
1453 i = ((dir[
LDIR_Ord] & 0x3F) - 1) * 13;
1457 uc = LD_WORD(dir+LfnOfs[s]);
1460 lfnbuf[i++] = wc = uc;
1462 if (uc != 0xFFFF)
return 0;
1475 #if _USE_LFN && !_FS_READONLY
1483 static void fit_lfn (
1484 const WCHAR* lfnbuf,
1502 if (wc != 0xFFFF) wc = lfnbuf[i++];
1503 ST_WORD(dir+LfnOfs[s], wc);
1504 if (!wc) wc = 0xFFFF;
1506 if (wc == 0xFFFF || !lfnbuf[i]) ord |=
LLE;
1537 do seq = (seq >> 1) + (seq << 15) + (WORD)*lfn++;
while (*lfn);
1543 c = (seq % 16) +
'0';
1544 if (c >
'9') c += 7;
1551 for (j = 0; j < i && dst[j] !=
' '; j++) {
1553 if (j == i - 1)
break;
1558 dst[j++] = (i < 8) ? ns[i++] :
' ';
1569 static BYTE sum_sfn (
1576 do sum = (sum >> 1) + (sum << 7) + *dir++;
while (--n);
1599 if (res !=
FR_OK)
return res;
1606 if (res !=
FR_OK)
break;
1620 dp->lfn_idx = dp->
index;
1623 ord = (c == ord && sum == dir[
LDIR_Chksum] && cmp_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF;
1626 if (!ord && sum == sum_sfn(dir))
break;
1627 ord = 0xFF; dp->lfn_idx = 0xFFFF;
1636 }
while (res ==
FR_OK);
1645 #if _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2
1658 BYTE ord = 0xFF, sum = 0xFF;
1664 if (res !=
FR_OK)
break;
1670 if (c ==
DDE || (!
_FS_RPATH && c ==
'.') || (
int)(a == AM_VOL) != vol) {
1677 dp->lfn_idx = dp->
index;
1680 ord = (c == ord && sum == dir[
LDIR_Chksum] && pick_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF;
1682 if (ord || sum != sum_sfn(dir))
1683 dp->lfn_idx = 0xFFFF;
1692 if (res !=
FR_OK)
break;
1713 BYTE sn[12], *fn, sum;
1717 fn = dp->
fn; lfn = dp->lfn;
1724 fn[
NS] = 0; dp->lfn = 0;
1725 for (n = 1; n < 100; n++) {
1726 gen_numname(fn, sn, lfn, n);
1728 if (res !=
FR_OK)
break;
1732 fn[
NS] = sn[
NS]; dp->lfn = lfn;
1736 for (n = 0; lfn[n]; n++) ;
1743 if (res ==
FR_OK && --ne) {
1746 sum = sum_sfn(dp->
fn);
1749 if (res !=
FR_OK)
break;
1750 fit_lfn(dp->lfn, dp->
dir, (BYTE)ne, sum);
1753 }
while (res ==
FR_OK && --ne);
1776 #if !_FS_READONLY && !_FS_MINIMIZE
1789 res =
dir_sdi(dp, (WORD)((dp->lfn_idx == 0xFFFF) ? i : dp->lfn_idx));
1793 if (res !=
FR_OK)
break;
1796 if (dp->
index >= i)
break;
1798 }
while (res ==
FR_OK);
1832 for (p = *path; *p ==
'/' || *p ==
'\\'; p++) ;
1837 if (w <
' ' || w ==
'/' || w ==
'\\')
break;
1848 w = ff_convert(w, 1);
1851 if (w < 0x80 &&
chk_chr(
"\"*:<>\?|\x7F", w))
1858 if ((di == 1 && lfn[di-1] ==
'.') ||
1859 (di == 2 && lfn[di-1] ==
'.' && lfn[di-2] ==
'.')) {
1861 for (i = 0; i < 11; i++)
1862 dp->
fn[i] = (i < di) ?
'.' :
' ';
1869 if (w !=
' ' && w !=
'.')
break;
1878 for (si = 0; lfn[si] ==
' ' || lfn[si] ==
'.'; si++) ;
1879 if (si) cf |= NS_LOSS |
NS_LFN;
1880 while (di && lfn[di - 1] !=
'.') di--;
1886 if (w ==
' ' || (w ==
'.' && si != di)) {
1887 cf |= NS_LOSS |
NS_LFN;
continue;
1890 if (i >= ni || si == di) {
1892 cf |= NS_LOSS |
NS_LFN;
break;
1894 if (si != di) cf |= NS_LOSS |
NS_LFN;
1896 si = di; i = 8; ni = 11;
1902 w = ff_convert(w, 0);
1903 if (w) w = ExCvt[w - 0x80];
1905 w = ff_convert(ff_wtoupper(w), 0);
1910 if (_DF1S && w >= 0x100) {
1912 cf |= NS_LOSS |
NS_LFN; i = ni;
continue;
1914 dp->
fn[i++] = (BYTE)(w >> 8);
1916 if (!w ||
chk_chr(
"+,;=[]", w)) {
1917 w =
'_'; cf |= NS_LOSS |
NS_LFN;
1928 dp->
fn[i++] = (BYTE)w;
1933 if (ni == 8) b <<= 2;
1934 if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03)
1936 if (!(cf & NS_LFN)) {
1937 if ((b & 0x03) == 0x01) cf |=
NS_EXT;
1938 if ((b & 0x0C) == 0x04) cf |=
NS_BODY;
1952 for (p = *path; *p ==
'/' || *p ==
'\\'; p++) ;
1955 si = i = b = 0; ni = 8;
1960 if (c !=
'.' || si >= 3)
break;
1965 sfn[
NS] = (c <=
' ') ?
NS_LAST | NS_DOT : NS_DOT;
1971 if (c <=
' ' || c ==
'/' || c ==
'\\')
break;
1972 if (c ==
'.' || i >= ni) {
1980 c = ExCvt[c - 0x80];
1989 if (!
IsDBCS2(d) || i >= ni - 1)
1994 if (
chk_chr(
"\"*+,:;<=>\?[]|\x7F", c))
2010 if (sfn[0] ==
DDE) sfn[0] =
NDDE;
2012 if (ni == 8) b <<= 2;
2013 if ((b & 0x03) == 0x01) c |=
NS_EXT;
2014 if ((b & 0x0C) == 0x04) c |=
NS_BODY;
2022 #if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2
2035 BYTE *dir = dp->
dir;
2039 c = (TCHAR)dir[i++];
2040 if (c ==
' ')
continue;
2041 if (c ==
NDDE) c = (TCHAR)
DDE;
2042 if (i == 9) *p++ =
'.';
2048 c = c << 8 | dir[i++];
2049 c = ff_convert(c, 1);
2066 i = 0; p = fno->lfname;
2067 if (dp->
sect && fno->lfsize && dp->lfn_idx != 0xFFFF) {
2069 while ((w = *lfn++) != 0) {
2071 w = ff_convert(w, 0);
2072 if (!w) { i = 0;
break; }
2073 if (_DF1S && w >= 0x100)
2074 p[i++] = (TCHAR)(w >> 8);
2076 if (i >= fno->lfsize - 1) { i = 0;
break; }
2096 vol = (*path)[0] -
'0';
2097 if ((UINT)vol < 9 && (*path)[1] ==
':') {
2101 #if _FS_RPATH && _VOLUMES >= 2
2124 if (*path ==
'/' || *path ==
'\\') {
2130 if (*path ==
'/' || *path ==
'\\')
2135 if ((UINT)*path <
' ') {
2141 if (res !=
FR_OK)
break;
2148 if (!(ns &
NS_LAST))
continue;
2205 DWORD bsect, fasize, tsect, sysect, nclst, szbfat;
2237 if (stat & STA_NOINIT)
2248 if (fmt == 1 || (!fmt && (
LD2PT(vol)))) {
2252 for (i = 0; i < 4; i++) {
2254 br[i] = pt[4] ? LD_DWORD(&pt[8]) : 0;
2260 fmt = bsect ?
check_fs(fs, bsect) : 2;
2261 }
while (!
LD2PT(vol) && fmt && ++i < 4);
2297 nclst = (tsect - sysect) / fs->
csize;
2308 if (fmt == FS_FAT32) {
2315 szbfat = (fmt == FS_FAT16) ?
2318 if (fs->
fsize < (szbfat + (
SS(fs) - 1)) /
SS(fs))
2415 if (!fs || opt != 1)
return FR_OK;
2457 res = chk_lock(&dj, (mode & ~
FA_READ) ? 1 : 0);
2511 if (mode & FA_CREATE_ALWAYS)
2512 mode |= FA__WRITTEN;
2562 DWORD clst, sect, remain;
2564 BYTE csect, *rbuff = (BYTE*)buff;
2576 if (btr > remain) btr = (UINT)remain;
2579 rbuff += rcnt, fp->
fptr += rcnt, *br += rcnt, btr -= rcnt) {
2580 if ((fp->
fptr %
SS(fp->
fs)) == 0) {
2583 if (fp->
fptr == 0) {
2588 clst = clmt_clust(fp, fp->
fptr);
2600 cc = btr /
SS(fp->
fs);
2602 if (csect + cc > fp->
fs->
csize)
2606 #if !_FS_READONLY && _FS_MINIMIZE <= 2
2611 if ((fp->
flag & FA__DIRTY) && fp->
dsect - sect < cc)
2615 rcnt =
SS(fp->
fs) * cc;
2619 if (fp->
dsect != sect) {
2621 if (fp->
flag & FA__DIRTY) {
2624 fp->
flag &= ~FA__DIRTY;
2634 if (rcnt > btr) rcnt = btr;
2663 const BYTE *wbuff = (
const BYTE*)buff;
2675 if (fp->
fptr + btw < fp->fptr) btw = 0;
2678 wbuff += wcnt, fp->
fptr += wcnt, *bw += wcnt, btw -= wcnt) {
2679 if ((fp->
fptr %
SS(fp->
fs)) == 0) {
2682 if (fp->
fptr == 0) {
2689 clst = clmt_clust(fp, fp->
fptr);
2694 if (clst == 0)
break;
2703 if (fp->
flag & FA__DIRTY) {
2706 fp->
flag &= ~FA__DIRTY;
2712 cc = btw /
SS(fp->
fs);
2714 if (csect + cc > fp->
fs->
csize)
2716 if (disk_write(fp->
fs->
drv, wbuff, sect, cc))
2718 #if _FS_MINIMIZE <= 2
2725 if (fp->
dsect - sect < cc) {
2727 fp->
flag &= ~FA__DIRTY;
2731 wcnt =
SS(fp->
fs) * cc;
2740 if (fp->
dsect != sect) {
2749 if (wcnt > btw) wcnt = btw;
2757 fp->
flag |= FA__DIRTY;
2762 fp->
flag |= FA__WRITTEN;
2782 if (fp->
flag & FA__WRITTEN) {
2785 if (fp->
flag & FA__DIRTY) {
2788 fp->
flag &= ~FA__DIRTY;
2801 fp->
flag &= ~FA__WRITTEN;
2826 if (res ==
FR_OK) fs = fp->
fs;
2838 res = dec_lock(fp->
lockid);
2842 res = dec_lock(fp->
lockid);
2851 #if _FS_RPATH >= 1 && _VOLUMES >= 2
2867 CurrVol = (BYTE)vol;
2939 while ((ccl = dj.
sclust) != 0) {
2941 if (res !=
FR_OK)
break;
2943 if (res !=
FR_OK)
break;
2946 if (res !=
FR_OK)
break;
2949 if (res !=
FR_OK)
break;
2952 }
while (res ==
FR_OK);
2954 if (res !=
FR_OK)
break;
2962 if (*buff) tp = buff;
2964 for (n = 0; tp[n]; n++) ;
2968 while (n) buff[--i] = tp[--n];
2974 *tp++ =
'0' + CurrVol;
2993 #if _FS_MINIMIZE <= 2
3011 DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl;
3013 if (ofs == CREATE_LINKMAP) {
3015 tlen = *tbl++; ulen = 2;
3020 tcl = cl; ncl = 0; ulen += 2;
3026 }
while (cl == pcl + 1);
3028 *tbl++ = ncl; *tbl++ = tcl;
3039 if (ofs > fp->
fsize)
3043 fp->
clust = clmt_clust(fp, ofs - 1);
3046 dsc += (ofs - 1) /
SS(fp->
fs) & (fp->
fs->
csize - 1);
3050 if (fp->
flag & FA__DIRTY) {
3053 fp->
flag &= ~FA__DIRTY;
3068 DWORD clst, bcs, nsect, ifptr;
3077 fp->
fptr = nsect = 0;
3081 (ofs - 1) / bcs >= (ifptr - 1) / bcs) {
3082 fp->
fptr = (ifptr - 1) & ~(bcs - 1);
3115 if (ofs %
SS(fp->
fs)) {
3118 nsect += ofs /
SS(fp->
fs);
3125 if (fp->
flag & FA__DIRTY) {
3128 fp->
flag &= ~FA__DIRTY;
3139 fp->
flag |= FA__WRITTEN;
3148 #if _FS_MINIMIZE <= 1
3183 dp->
lockid = inc_lock(dp, 0);
3201 #if _FS_MINIMIZE <= 1
3215 res = dec_lock(dp->
lockid);
3226 #if _FS_MINIMIZE <= 1
3265 #if _FS_MINIMIZE == 0
3297 #if _FS_MINIMIZE == 0 && !_FS_READONLY
3309 DWORD n, clst, sect, stat;
3325 if (fat == FS_FAT12) {
3329 if (stat == 0xFFFFFFFF) { res =
FR_DISK_ERR;
break; }
3332 }
while (++clst < fs->n_fatent);
3340 if (res !=
FR_OK)
break;
3344 if (fat == FS_FAT16) {
3345 if (LD_WORD(p) == 0) n++;
3348 if ((LD_DWORD(p) & 0x0FFFFFFF) == 0) n++;
3362 #if _FS_MINIMIZE == 0 && !_FS_READONLY
3385 fp->
flag |= FA__WRITTEN;
3386 if (fp->
fptr == 0) {
3400 if (res ==
FR_OK && (fp->
flag & FA__DIRTY)) {
3404 fp->
flag &= ~FA__DIRTY;
3415 #if _FS_MINIMIZE == 0 && !_FS_READONLY
3437 if (res ==
FR_OK) res = chk_lock(&dj, 2);
3459 || dclst == dj.
fs->cdir
3482 #if _FS_MINIMIZE == 0 && !_FS_READONLY
3526 for (n = dj.
fs->
csize; n; n--) {
3530 if (res !=
FR_OK)
break;
3553 #if _FS_MINIMIZE == 0 && !_FS_READONLY
3593 #if _FS_MINIMIZE == 0 && !_FS_READONLY
3632 #if _FS_MINIMIZE == 0 && !_FS_READONLY
3656 if (res ==
FR_OK) res = chk_lock(&djo, 2);
3681 if (res ==
FR_OK && dir[1] ==
'.') {
3728 if (res ==
FR_OK && label) {
3738 w = (i < 11) ? dj.
dir[i++] :
' ';
3740 w = w << 8 | dj.
dir[i++];
3741 label[j++] = ff_convert(w, 1);
3750 }
while (label[--j] ==
' ');
3760 if (res ==
FR_OK && sn) {
3764 *sn = LD_DWORD(&dj.
fs->
win[i]);
3772 #if _USE_LABEL && !_FS_READONLY
3796 for (sl = 0; label[sl]; sl++) ;
3797 for ( ; sl && label[sl-1] ==
' '; sl--) ;
3802 w = ff_convert(ff_wtoupper(label[i++]), 0);
3804 w = (BYTE)label[i++];
3806 w = (j < 10 && i < sl &&
IsDBCS2(label[i])) ? w << 8 | (BYTE)label[i++] : 0;
3808 w = ff_convert(ff_wtoupper(ff_convert(w, 1)), 0);
3812 if (w >= 0x80) w = ExCvt[w - 0x80];
3814 if (!_DF1S && w >= 0x80) w = 0;
3818 if (!w ||
chk_chr(
"\"*+,.:;<=>\?[]|\x7F", w) || j >= (UINT)((w >= 0x100) ? 10 : 11))
3820 if (w >= 0x100) vn[j++] = (BYTE)(w >> 8);
3823 while (j < 11) vn[j++] =
' ';
3864 #if _USE_FORWARD && _FS_TINY
3875 UINT (*func)(
const BYTE*, UINT),
3881 DWORD remain, clst, sect;
3896 if (btf > remain) btf = (UINT)remain;
3898 for ( ; btf && (*func)(0, 0);
3899 fp->
fptr += rcnt, *bf += rcnt, btf -= rcnt) {
3901 if ((fp->
fptr %
SS(fp->
fs)) == 0) {
3903 clst = (fp->
fptr == 0) ?
3917 if (rcnt > btf) rcnt = btf;
3918 rcnt = (*func)(&fp->
fs->
win[(WORD)fp->
fptr %
SS(fp->
fs)], rcnt);
3926 #if _USE_MKFS && !_FS_READONLY
3927 #define N_ROOTDIR 512
3932 #if _USE_MKFS && !_FS_READONLY
3942 FRESULT f_mkfs(
const TCHAR* path, BYTE sfd, UINT au) {
3943 static const WORD vst[] = { 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 0 };
3944 static const WORD cst[] = { 32768, 16384, 8192, 4096, 2048, 16384, 8192,
3945 4096, 2048, 1024, 512 };
3947 BYTE fmt, md, sys, *tbl, pdrv, part;
3948 DWORD n_clst, vs, n, wsect;
3950 DWORD b_vol, b_fat, b_dir, b_data;
3951 DWORD n_vol, n_rsv, n_fat, n_dir;
3981 b_vol = LD_DWORD(tbl+8);
3982 n_vol = LD_DWORD(tbl+12);
3987 b_vol = (sfd) ? 0 : 63;
3992 vs = n_vol / (2000 / (
SS(fs) / 512));
3993 for (i = 0; vs < vst[i]; i++) ;
3997 if (au == 0) au = 1;
3998 if (au > 128) au = 128;
4001 n_clst = n_vol / au;
4003 if (n_clst >=
MIN_FAT16) fmt = FS_FAT16;
4004 if (n_clst >=
MIN_FAT32) fmt = FS_FAT32;
4007 if (fmt == FS_FAT32) {
4008 n_fat = ((n_clst * 4) + 8 +
SS(fs) - 1) /
SS(fs);
4012 n_fat = (fmt == FS_FAT12) ? (n_clst * 3 + 1) / 2 + 3 : (n_clst * 2) + 4;
4013 n_fat = (n_fat +
SS(fs) - 1) /
SS(fs);
4015 n_dir = (DWORD)N_ROOTDIR *
SZ_DIR /
SS(fs);
4017 b_fat = b_vol + n_rsv;
4018 b_dir = b_fat + n_fat * N_FATS;
4019 b_data = b_dir + n_dir;
4024 n = (b_data + n - 1) & ~(n - 1);
4025 n = (n - b_data) / N_FATS;
4026 if (fmt == FS_FAT32) {
4034 n_clst = (n_vol - n_rsv - n_fat * N_FATS - n_dir) / au;
4035 if ( (fmt == FS_FAT16 && n_clst <
MIN_FAT16)
4036 || (fmt == FS_FAT32 && n_clst <
MIN_FAT32))
4040 if (fmt == FS_FAT32) {
4043 if (fmt == FS_FAT12 && n_vol < 0x10000) {
4046 sys = (n_vol < 0x10000) ? 0x04 : 0x06;
4054 if (disk_write(pdrv, fs->
win, 0, 1))
4068 n = (b_vol + n_vol) / 63 / 255;
4069 tbl[6] = (BYTE)(n >> 2 | 63);
4071 ST_DWORD(tbl+8, 63);
4072 ST_DWORD(tbl+12, n_vol);
4074 if (disk_write(pdrv, fs->
win, 0, 1))
4083 mem_cpy(tbl,
"\xEB\xFE\x90" "MSDOS5.0", 11);
4089 i = (fmt == FS_FAT32) ? 0 : N_ROOTDIR;
4091 if (n_vol < 0x10000) {
4101 if (fmt == FS_FAT32) {
4118 if (disk_write(pdrv, tbl, b_vol, 1))
4120 if (fmt == FS_FAT32)
4121 disk_write(pdrv, tbl, b_vol + 6, 1);
4125 for (i = 0; i < N_FATS; i++) {
4128 if (fmt != FS_FAT32) {
4129 n |= (fmt == FS_FAT12) ? 0x00FFFF00 : 0xFFFFFF00;
4134 ST_DWORD(tbl+4, 0xFFFFFFFF);
4135 ST_DWORD(tbl+8, 0x0FFFFFFF);
4137 if (disk_write(pdrv, tbl, wsect++, 1))
4140 for (n = 1; n < n_fat; n++) {
4141 if (disk_write(pdrv, tbl, wsect++, 1))
4147 i = (fmt == FS_FAT32) ? au : n_dir;
4149 if (disk_write(pdrv, tbl, wsect++, 1))
4157 eb[0] = wsect; eb[1] = wsect + (n_clst - ((fmt == FS_FAT32) ? 1 : 0)) * au - 1;
4163 if (fmt == FS_FAT32) {
4169 disk_write(pdrv, tbl, b_vol + 1, 1);
4170 disk_write(pdrv, tbl, b_vol + 7, 1);
4177 #if _USE_MKFS && !_FS_READONLY && _MULTI_PARTITION
4191 UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl;
4192 BYTE s_hd, e_hd, *p, *buf = (BYTE*)work;
4194 DWORD sz_disk, sz_part, s_part;
4203 for (n = 16; n < 256 && sz_disk / n / 63 > 1024; n *= 2) ;
4207 tot_cyl = sz_disk / sz_cyl;
4212 for (i = 0; i < 4; i++, p +=
SZ_PTE) {
4213 p_cyl = (szt[i] <= 100U) ? (DWORD)tot_cyl * szt[i] / 100 : szt[i] / sz_cyl;
4214 if (!p_cyl)
continue;
4215 s_part = (DWORD)sz_cyl * b_cyl;
4216 sz_part = (DWORD)sz_cyl * p_cyl;
4219 s_part += 63; sz_part -= 63;
4223 e_cyl = b_cyl + p_cyl - 1;
4228 p[2] = (BYTE)((b_cyl >> 2) + 1);
4232 p[6] = (BYTE)((e_cyl >> 2) + 63);
4234 ST_DWORD(p + 8, s_part);
4235 ST_DWORD(p + 12, sz_part);
4255 TCHAR* f_gets(TCHAR* buff,
int len,
FIL* fp) {
4262 while (n < len - 1) {
4264 #if _STRF_ENCODE == 3
4269 if (c < 0xC0)
continue;
4273 c = (c & 0x1F) << 6 | (s[0] & 0x3F);
4274 if (c < 0x80) c =
'?';
4279 c = c << 12 | (s[0] & 0x3F) << 6 | (s[1] & 0x3F);
4280 if (c < 0x800) c =
'?';
4286 #elif _STRF_ENCODE == 2
4289 c = s[1] + (s[0] << 8);
4290 #elif _STRF_ENCODE == 1
4293 c = s[0] + (s[1] << 8);
4301 c = (c << 8) + s[0];
4303 c = ff_convert(c, 1);
4314 if (c ==
'\n')
break;
4317 return n ? buff : 0;
4321 #if _USE_STRFUNC && !_FS_READONLY
4325 #if _USE_STRFUNC && !_FS_READONLY
4338 #if _USE_STRFUNC && !_FS_READONLY
4344 static void putc_bfd(putbuff* pb, TCHAR c) {
4356 #if _STRF_ENCODE == 3
4358 pb->buf[i++] = (BYTE)c;
4361 pb->buf[i++] = (BYTE)(0xC0 | c >> 6);
4363 pb->buf[i++] = (BYTE)(0xE0 | c >> 12);
4364 pb->buf[i++] = (BYTE)(0x80 | (c >> 6 & 0x3F));
4366 pb->buf[i++] = (BYTE)(0x80 | (c & 0x3F));
4368 #elif _STRF_ENCODE == 2
4369 pb->buf[i++] = (BYTE)(c >> 8);
4370 pb->buf[i++] = (BYTE)c;
4371 #elif _STRF_ENCODE == 1
4372 pb->buf[i++] = (BYTE)c;
4373 pb->buf[i++] = (BYTE)(c >> 8);
4375 c = ff_convert(c, 0);
4378 pb->buf[i++] = (BYTE)(c >> 8);
4379 pb->buf[i++] = (BYTE)c;
4382 pb->buf[i++] = (BYTE)c;
4385 if (i >= (
int)(
sizeof pb->buf) - 3) {
4386 f_write(pb->fp, pb->buf, (UINT)i, &bw);
4387 i = (bw == (UINT)i) ? 0 : -1;
4394 #if _USE_STRFUNC && !_FS_READONLY
4402 int f_putc(TCHAR c,
FIL* fp) {
4408 pb.nchr = pb.idx = 0;
4414 && (UINT)pb.idx == nw)
return pb.nchr;
4419 #if _USE_STRFUNC && !_FS_READONLY
4427 int f_puts(
const TCHAR* str,
FIL* fp) {
4433 pb.nchr = pb.idx = 0;
4436 putc_bfd(&pb, *str++);
4440 && (UINT)pb.idx == nw)
return pb.nchr;
4445 #if _USE_STRFUNC && !_FS_READONLY
4454 int f_printf(
FIL* fp,
const TCHAR* fmt, ...) {
4459 TCHAR c, d, s[16], *p;
4464 pb.nchr = pb.idx = 0;
4485 w = w * 10 + c -
'0';
4488 if (c ==
'l' || c ==
'L') {
4496 p = va_arg(arp, TCHAR*);
4497 for (j = 0; p[j]; j++) ;
4499 while (j++ < w) putc_bfd(&pb,
' ');
4501 while (*p) putc_bfd(&pb, *p++);
4502 while (j++ < w) putc_bfd(&pb,
' ');
4505 putc_bfd(&pb, (TCHAR)va_arg(arp,
int));
continue;
4516 putc_bfd(&pb, c);
continue;
4520 v = (f & 4) ? (DWORD)va_arg(arp,
long) : ((d ==
'D') ? (DWORD)(long)va_arg(arp, int) : (DWORD)va_arg(arp, unsigned int));
4521 if (d ==
'D' && (v & 0x80000000)) {
4527 d = (TCHAR)(v % r); v /= r;
4528 if (d > 9) d += (c ==
'x') ? 0x27 : 0x07;
4530 }
while (v && i <
sizeof s /
sizeof s[0]);
4531 if (f & 8) s[i++] =
'-';
4532 j = i; d = (f & 1) ?
'0' :
' ';
4533 while (!(f & 2) && j++ < w) putc_bfd(&pb, d);
4534 do putc_bfd(&pb, s[--i]);
while (i);
4535 while (j++ < w) putc_bfd(&pb, d);
4542 && (UINT)pb.idx == nw)
return pb.nchr;
FRESULT f_opendir(DIR *dp, const TCHAR *path)
Create a Directory Object.
static void get_fileinfo(DIR *dp, FILINFO *fno)
Get file information from directory entry.
static int chk_chr(const char *str, int chr)
Check if chr is contained in the string.
FRESULT f_chmod(const TCHAR *path, BYTE value, BYTE mask)
Change Attribute.
FRESULT f_lseek(FIL *fp, DWORD ofs)
Seek File R/W Pointer.
#define LEAVE_FF(fs, res)
Exit from a thread-safe state.
static FRESULT dir_remove(DIR *dp)
Remove an object from the directory.
FRESULT
File function return code.
static DWORD create_chain(FATFS *fs, DWORD clst)
Stretch or Create a cluster chain.
static FRESULT dir_sdi(DIR *dp, WORD idx)
Set directory index.
int ff_del_syncobj(_SYNC_t sobj)
Directory object structure.
File system object structure.
#define ENTER_FF(fs)
Enter in a thread-safe state.
#define ABORT(fs, res)
Abort.
#define _FS_READONLY
Setting _FS_READONLY to 1 defines read only configuration. This removes writing functions, f_write(), f_sync(), f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate() and useless f_getfree().
static DWORD ld_clust(FATFS *fs, BYTE *dir)
Load/Store start cluster number.
static FRESULT validate(void *obj)
Check if the file/directory object is valid or not.
static FRESULT dir_alloc(DIR *dp, UINT nent)
Reserve directory entry.
#define CTRL_ERASE_SECTOR
FRESULT f_mkdir(const TCHAR *path)
Create a Directory.
uint32_t get_fattime(void)
Get the time from the RTC. This function is used from the FatFs and the function prototype is given ...
FRESULT f_rename(const TCHAR *path_old, const TCHAR *path_new)
Rename File/Directory.
static FRESULT remove_chain(FATFS *fs, DWORD clst)
Remove a cluster chain.
FRESULT f_close(FIL *fp)
Close File.
static void st_clust(BYTE *dir, DWORD cl)
#define _MULTI_PARTITION
When set to 0, each volume is bound to the same physical drive number and it can mount only first pri...
FRESULT f_getfree(const TCHAR *path, DWORD *nclst, FATFS **fatfs)
Get Number of Free Clusters.
static FRESULT dir_register(DIR *dp)
Register an object to the directory.
DRESULT disk_read(BYTE drv, BYTE *buff, DWORD sector, UINT count)
Read from the SD Card.
#define _MAX_LFN
Maximum LFN length to handle.
static FRESULT sync_fs(FATFS *fs)
Synchronize file system and storage device.
FRESULT f_utime(const TCHAR *path, const FILINFO *fno)
Change Timestamp.
FRESULT f_write(FIL *fp, const void *buff, UINT btw, UINT *bw)
Write File.
FRESULT f_read(FIL *fp, void *buff, UINT btr, UINT *br)
Read File.
DWORD clust2sect(FATFS *fs, DWORD clst)
Synchronize file system and storage device.
FRESULT f_mount(FATFS *fs, const TCHAR *path, BYTE opt)
Mount/Unmount a Logical Drive.
FRESULT f_stat(const TCHAR *path, FILINFO *fno)
Get File Status.
static void mem_cpy(void *dst, const void *src, UINT cnt)
Copy memory to memory.
#define _FS_RPATH
The _FS_RPATH option configures relative path feature.
static void mem_set(void *dst, int val, UINT cnt)
Fill memory.
BYTE DSTATUS
Status of Disk Functions.
FRESULT put_fat(FATFS *fs, DWORD clst, DWORD val)
Change value of a FAT entry.
static BYTE check_fs(FATFS *fs, DWORD sect)
Load a sector and check if it is an FAT boot sector.
static FRESULT dir_next(DIR *dp, int stretch)
Move directory table index next.
static FRESULT create_name(DIR *dp, const TCHAR **path)
Pick a segment and create the object name in directory form.
FRESULT f_truncate(FIL *fp)
Truncate File.
FRESULT f_unlink(const TCHAR *path)
Delete a File or Directory.
FRESULT f_open(FIL *fp, const TCHAR *path, BYTE mode)
Open or Create a File.
static FRESULT follow_path(DIR *dp, const TCHAR *path)
Follow a file path.
static FRESULT dir_find(DIR *dp)
Find an object in the directory.
#define _MAX_SS
Maximum sector size to be handled. Always set 512 for memory card and hard disk but a larger value ma...
static int get_ldnumber(const TCHAR **path)
Get logical drive number from path name.
static int mem_cmp(const void *dst, const void *src, UINT cnt)
Compare memory to memory.
FRESULT f_readdir(DIR *dp, FILINFO *fno)
Read Directory Entries in Sequence.
DSTATUS disk_status(BYTE drv)
Return disk status.
FRESULT f_closedir(DIR *dp)
Close Directory.
static FRESULT find_volume(FATFS **rfs, const TCHAR **path, BYTE wmode)
Find logical drive and check if the volume is mounted.
static FRESULT sync_window(FATFS *fs)
Sync window.
int ff_cre_syncobj(BYTE vol, _SYNC_t *sobj)
static FRESULT dir_read(DIR *dp, int vol)
Read an object from the directory.
void ff_rel_grant(_SYNC_t sobj)
#define _FS_LOCK
To enable file lock control feature, set _FS_LOCK to 1 or greater. The value defines how many files c...
DSTATUS disk_initialize(BYTE drv)
Initialize the SD Card Returns the disk status.
int ff_req_grant(_SYNC_t sobj)
DWORD get_fat(FATFS *fs, DWORD clst)
Read value of a FAT entry.
#define _VOLUMES
Number of volumes (logical drives) to be used.
FRESULT f_sync(FIL *fp)
Synchronize the File.
#define _USE_STRFUNC
To enable string functions, set _USE_STRFUNC to 1 or 2.
static FRESULT move_window(FATFS *fs, DWORD sector)
Move window.