114 #error Wrong include file (ff.h). 119 #if _MAX_SS != 512 && _MAX_SS != 1024 && _MAX_SS != 2048 && _MAX_SS != 4096 120 #error Wrong sector size. 123 #define SS(fs) ((fs)->ssize) 132 #error Static LFN work area must not be used in re-entrant configuration. 134 #define ENTER_FF(fs) { if (!lock_fs(fs)) return FR_TIMEOUT; } 135 #define LEAVE_FF(fs, res) { unlock_fs(fs, res); return res; } 138 #define LEAVE_FF(fs, res) return res 141 #define ABORT(fs, res) { fp->flag |= FA__ERROR; LEAVE_FF(fs, res); } 147 #error _FS_SHARE must be 0 on read-only cfg. 159 #define LD_CLUST(dir) (((DWORD)LD_WORD(dir+DIR_FstClusHI)<<16) | LD_WORD(dir+DIR_FstClusLO)) 160 #define ST_CLUST(dir,cl) {ST_WORD(dir+DIR_FstClusLO, cl); ST_WORD(dir+DIR_FstClusHI, (DWORD)cl>>16);} 165 #if _CODE_PAGE == 932 175 #elif _CODE_PAGE == 936 183 #elif _CODE_PAGE == 949 193 #elif _CODE_PAGE == 950 201 #elif _CODE_PAGE == 437 203 #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, \ 204 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, \ 205 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, \ 206 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FE,0xFF} 271 #elif _CODE_PAGE == 866 273 #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,0x9C,0x9D,0x9E,0x9F, \ 274 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ 275 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, \ 276 0x90,0x91,0x92,0x93,0x9d,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} 278 #elif _CODE_PAGE == 874 280 #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,0x9C,0x9D,0x9E,0x9F, \ 281 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, \ 282 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,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,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} 348 #elif _CODE_PAGE == 1 350 #error Cannot use LFN feature without valid code page. 355 #error Unknown code page 361 #define IsUpper(c) (((c)>='A')&&((c)<='Z')) 362 #define IsLower(c) (((c)>='a')&&((c)<='z')) 363 #define IsDigit(c) (((c)>='0')&&((c)<='9')) 368 #define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) 370 #define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) 374 #define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) 376 #define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) 399 #define MIN_FAT16 4086 400 #define MIN_FAT32 65526 409 #define BPB_BytsPerSec 11 410 #define BPB_SecPerClus 13 411 #define BPB_RsvdSecCnt 14 412 #define BPB_NumFATs 16 413 #define BPB_RootEntCnt 17 414 #define BPB_TotSec16 19 416 #define BPB_FATSz16 22 417 #define BPB_SecPerTrk 24 418 #define BPB_NumHeads 26 419 #define BPB_HiddSec 28 420 #define BPB_TotSec32 32 422 #define BS_BootSig 38 425 #define BS_FilSysType 54 426 #define BPB_FATSz32 36 427 #define BPB_ExtFlags 40 429 #define BPB_RootClus 44 430 #define BPB_FSInfo 48 431 #define BPB_BkBootSec 50 432 #define BS_DrvNum32 64 433 #define BS_BootSig32 66 434 #define BS_VolID32 67 435 #define BS_VolLab32 71 436 #define BS_FilSysType32 82 437 #define FSI_LeadSig 0 438 #define FSI_StrucSig 484 439 #define FSI_Free_Count 488 440 #define FSI_Nxt_Free 492 441 #define MBR_Table 446 448 #define DIR_CrtTime 14 449 #define DIR_CrtDate 16 450 #define DIR_FstClusHI 20 451 #define DIR_WrtTime 22 452 #define DIR_WrtDate 24 453 #define DIR_FstClusLO 26 454 #define DIR_FileSize 28 458 #define LDIR_Chksum 13 459 #define LDIR_FstClusLO 26 478 #error Number of volumes must not be 0. 495 #define DEF_NAMEBUF BYTE sfn[12] 496 #define INIT_BUF(dobj) (dobj).fn = sfn 501 #define DEF_NAMEBUF BYTE sfn[12] 502 #define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = LfnBuf; } 506 #define DEF_NAMEBUF BYTE sfn[12]; WCHAR lbuf[_MAX_LFN+1] 507 #define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = lbuf; } 511 #define DEF_NAMEBUF BYTE sfn[12]; WCHAR *lfn 512 #define INIT_BUF(dobj) { lfn = ff_memalloc((_MAX_LFN + 1) * 2); \ 513 if (!lfn) LEAVE_FF((dobj).fs, FR_NOT_ENOUGH_CORE); \ 514 (dobj).lfn = lfn; (dobj).fn = sfn; } 515 #define FREE_BUF() ff_memfree(lfn) 518 #error Wrong LFN configuration. 541 #if _WORD_ACCESS == 1 542 while (cnt >=
sizeof(
int)) {
544 d +=
sizeof(int); s +=
sizeof(int);
567 while (cnt-- && (r = *d++ - *
s++) == 0) ;
574 while (*str && *str != chr) str++;
590 return ff_req_grant(fs->sobj);
604 ff_rel_grant(fs->sobj);
627 if (Files[i].fs == dj->
fs &&
628 Files[i].clu == dj->
sclust &&
629 Files[i].idx == dj->
index)
break;
647 for (i = 0; i <
_FS_SHARE && Files[i].fs; i++) ;
662 if (Files[i].fs == dj->
fs &&
663 Files[i].clu == dj->
sclust &&
664 Files[i].idx == dj->
index)
break;
667 if (i == _FS_SHARE) {
668 for (i = 0; i < _FS_SHARE && Files[i].fs; i++) ;
669 if (i == _FS_SHARE)
return 0;
670 Files[i].fs = dj->
fs;
671 Files[i].clu = dj->
sclust;
672 Files[i].idx = dj->
index;
676 if (acc && Files[i].ctr)
return 0;
678 Files[i].ctr = acc ? 0x100 : Files[i].ctr + 1;
695 if (n == 0x100) n = 0;
698 if (!n) Files[i].fs = 0;
715 if (Files[i].fs == fs) Files[i].fs = 0;
736 if (wsect != sector) {
744 for (nf = fs->
n_fats; nf > 1; nf--) {
815 if (clst >= (fs->
n_fatent - 2))
return 0;
836 if (clst < 2 || clst >= fs->
n_fatent)
841 bc = (
UINT)clst; bc += bc / 2;
843 wc = fs->
win[bc %
SS(fs)]; bc++;
845 wc |= fs->
win[bc %
SS(fs)] << 8;
846 return (clst & 1) ? (wc >> 4) : (wc & 0xFFF);
850 p = &fs->
win[clst * 2 %
SS(fs)];
855 p = &fs->
win[clst * 4 %
SS(fs)];
881 if (clst < 2 || clst >= fs->
n_fatent) {
887 bc = clst; bc += bc / 2;
889 if (res !=
FR_OK)
break;
890 p = &fs->
win[bc %
SS(fs)];
891 *p = (clst & 1) ? ((*p & 0x0F) | ((
BYTE)val << 4)) : (
BYTE)val;
895 if (res !=
FR_OK)
break;
896 p = &fs->
win[bc %
SS(fs)];
897 *p = (clst & 1) ? (
BYTE)(val >> 4) : ((*p & 0xF0) | ((
BYTE)(val >> 8) & 0x0F));
902 if (res !=
FR_OK)
break;
903 p = &fs->
win[clst * 2 %
SS(fs)];
909 if (res !=
FR_OK)
break;
910 p = &fs->
win[clst * 4 %
SS(fs)];
941 DWORD scl = clst, ecl = clst, resion[2];
944 if (clst < 2 || clst >= fs->
n_fatent) {
949 while (clst < fs->n_fatent) {
953 if (nxt == 0xFFFFFFFF) { res =
FR_DISK_ERR;
break; }
955 if (res !=
FR_OK)
break;
961 if (ecl + 1 == nxt) {
997 if (!scl || scl >= fs->
n_fatent) scl = 1;
1001 if (cs < 2)
return 1;
1002 if (cs < fs->n_fatent)
return cs;
1011 if (ncl > scl)
return 0;
1015 if (cs == 0xFFFFFFFF || cs == 1)
1017 if (ncl == scl)
return 0;
1020 res =
put_fat(fs, ncl, 0x0FFFFFFF);
1021 if (res ==
FR_OK && clst != 0) {
1051 DWORD cl, ncl, *tbl;
1054 tbl = fp->cltbl + 1;
1059 if (cl < ncl)
break;
1132 if (!i || !dj->
sect)
1138 if (dj->
clust == 0) {
1159 for (c = 0; c < dj->
fs->
csize; c++) {
1189 const BYTE LfnOfs[] = {1,3,5,7,9,14,16,18,20,22,24,28,30};
1211 if (uc != 0xFFFF)
return 0;
1233 i = ((dir[
LDIR_Ord] & 0x3F) - 1) * 13;
1240 lfnbuf[i++] = wc = uc;
1242 if (uc != 0xFFFF)
return 0;
1258 const WCHAR *lfnbuf,
1276 if (wc != 0xFFFF) wc = lfnbuf[i++];
1278 if (!wc) wc = 0xFFFF;
1280 if (wc == 0xFFFF || !lfnbuf[i]) ord |=
LLE;
1307 do seq = (seq >> 1) + (seq << 15) + (
WORD)*lfn++;
while (*lfn);
1313 c = (seq % 16) +
'0';
1314 if (c >
'9') c += 7;
1321 for (j = 0; j < i && dst[j] !=
' '; j++) {
1323 if (j == i - 1)
break;
1328 dst[j++] = (i < 8) ? ns[i++] :
' ';
1348 do sum = (sum >> 1) + (sum << 7) + *dir++;
while (--n);
1372 if (res !=
FR_OK)
return res;
1379 if (res !=
FR_OK)
break;
1399 if (!ord && sum ==
sum_sfn(dir))
break;
1400 ord = 0xFF; dj->
lfn_idx = 0xFFFF;
1409 }
while (res ==
FR_OK);
1420 #if _FS_MINIMIZE <= 1 1429 BYTE a, ord = 0xFF, sum = 0xFF;
1435 if (res !=
FR_OK)
break;
1453 if (ord || sum !=
sum_sfn(dir))
1463 if (res !=
FR_OK)
break;
1487 BYTE sn[12], *fn, sum;
1491 fn = dj->
fn; lfn = dj->
lfn;
1498 fn[
NS] = 0; dj->
lfn = 0;
1499 for (n = 1; n < 100; n++) {
1502 if (res !=
FR_OK)
break;
1506 fn[
NS] = sn[
NS]; dj->
lfn = lfn;
1510 for (ne = 0; lfn[ne]; ne++) ;
1511 ne = (ne + 25) / 13;
1518 if (res !=
FR_OK)
return res;
1522 if (res !=
FR_OK)
break;
1524 if (c ==
DDE || c == 0) {
1525 if (n == 0) is = dj->
index;
1526 if (++n == ne)
break;
1531 }
while (res ==
FR_OK);
1533 if (res ==
FR_OK && ne > 1) {
1540 if (res !=
FR_OK)
break;
1544 }
while (res ==
FR_OK && --ne);
1553 if (res !=
FR_OK)
break;
1555 if (c ==
DDE || c == 0)
break;
1557 }
while (res ==
FR_OK);
1584 #if !_FS_READONLY && !_FS_MINIMIZE 1599 if (res !=
FR_OK)
break;
1602 if (dj->
index >= i)
break;
1604 }
while (res ==
FR_OK);
1647 for (p = *path; *p ==
'/' || *p ==
'\\'; p++) ;
1652 if (w <
' ' || w ==
'/' || w ==
'\\')
break;
1666 if (w < 0x80 &&
chk_chr(
"\"*:<>\?|\x7F", w))
1673 if ((di == 1 && lfn[di-1] ==
'.') ||
1674 (di == 2 && lfn[di-1] ==
'.' && lfn[di-2] ==
'.')) {
1676 for (i = 0; i < 11; i++)
1677 dj->
fn[i] = (i < di) ?
'.' :
' ';
1684 if (w !=
' ' && w !=
'.')
break;
1693 for (si = 0; lfn[si] ==
' ' || lfn[si] ==
'.'; si++) ;
1695 while (di && lfn[di - 1] !=
'.') di--;
1701 if (w ==
' ' || (w ==
'.' && si != di)) {
1705 if (i >= ni || si == di) {
1711 si = di; i = 8; ni = 11;
1718 if (w) w = excvt[w - 0x80];
1725 if (
_DF1S && w >= 0x100) {
1729 dj->
fn[i++] = (
BYTE)(w >> 8);
1731 if (!w ||
chk_chr(
"+,;=[]", w)) {
1748 if (ni == 8) b <<= 2;
1749 if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03)
1752 if ((b & 0x03) == 0x01) cf |=
NS_EXT;
1753 if ((b & 0x0C) == 0x04) cf |=
NS_BODY;
1767 for (p = *path; *p ==
'/' || *p ==
'\\'; p++) ;
1770 si = i = b = 0; ni = 8;
1775 if (c !=
'.' || si >= 3)
break;
1786 if (c <=
' ' || c ==
'/' || c ==
'\\')
break;
1787 if (c ==
'.' || i >= ni) {
1804 if (!
IsDBCS2(d) || i >= ni - 1)
1809 if (
chk_chr(
"\"*+,:;<=>\?[]|\x7F", c))
1825 if (sfn[0] ==
DDE) sfn[0] =
NDDE;
1827 if (ni == 8) b <<= 2;
1828 if ((b & 0x03) == 0x01) c |=
NS_EXT;
1829 if ((b & 0x0C) == 0x04) c |=
NS_BODY;
1843 #if _FS_MINIMIZE <= 1 1859 for (i = 0; i < 8; i++) {
1861 if (c ==
' ')
break;
1866 c = (c << 8) | dir[++i];
1872 if (dir[8] !=
' ') {
1874 for (i = 8; i < 11; i++) {
1876 if (c ==
' ')
break;
1880 c = (c << 8) | dir[++i];
1902 while ((w = *lfn++) != 0) {
1905 if (!w) { i = 0;
break; }
1906 if (
_DF1S && w >= 0x100)
1907 tp[i++] = (
TCHAR)(w >> 8);
1909 if (i >= fno->
lfsize - 1) { i = 0;
break; }
1937 if (*path ==
'/' || *path ==
'\\') {
1943 if (*path ==
'/' || *path ==
'\\')
1948 if ((
UINT)*path <
' ') {
1955 if (res !=
FR_OK)
break;
1964 if (!(ns &
NS_LAST))
continue;
2022 BYTE fmt, b, pi, *tbl;
2025 DWORD bsect, fasize, tsect, sysect, nclst, szbfat;
2027 const TCHAR *p = *path;
2032 if (vol <= 9 && p[1] ==
':') {
2045 *rfs = fs = FatFs[vol];
2075 if (
LD2PT(vol) && !fmt) fmt = 1;
2117 nclst = (tsect - sysect) / fs->
csize;
2137 if (fs->
fsize < (szbfat + (
SS(fs) - 1)) /
SS(fs))
2185 if (!fs || !fs->
fs_type || fs->
id !=
id)
2228 if (!ff_del_syncobj(rfs->sobj))
return FR_INT_ERR;
2236 if (!ff_cre_syncobj(vol, &fs->sobj))
return FR_INT_ERR;
2283 res = chk_lock(&dj, (mode & ~
FA_READ) ? 1 : 0);
2342 fp->lockid = inc_lock(&dj, (mode & ~
FA_READ) ? 1 : 0);
2389 DWORD clst, sect, remain;
2391 BYTE csect, *rbuff = buff;
2403 if (btr > remain) btr = (
UINT)remain;
2406 rbuff += rcnt, fp->
fptr += rcnt, *br += rcnt, btr -= rcnt) {
2407 if ((fp->
fptr %
SS(fp->
fs)) == 0) {
2410 if (fp->
fptr == 0) {
2415 clst = clmt_clust(fp, fp->
fptr);
2427 cc = btr /
SS(fp->
fs);
2429 if (csect + cc > fp->
fs->
csize)
2433 #if !_FS_READONLY && _FS_MINIMIZE <= 2 2442 rcnt =
SS(fp->
fs) * cc;
2446 if (fp->
dsect != sect) {
2461 if (rcnt > btr) rcnt = btr;
2492 const BYTE *wbuff = buff;
2507 wbuff += wcnt, fp->
fptr += wcnt, *bw += wcnt, btw -= wcnt) {
2508 if ((fp->
fptr %
SS(fp->
fs)) == 0) {
2511 if (fp->
fptr == 0) {
2518 clst = clmt_clust(fp, fp->
fptr);
2523 if (clst == 0)
break;
2541 cc = btw /
SS(fp->
fs);
2543 if (csect + cc > fp->
fs->
csize)
2553 if (fp->
dsect - sect < cc) {
2558 wcnt =
SS(fp->
fs) * cc;
2567 if (fp->
dsect != sect) {
2576 if (wcnt > btw) wcnt = btw;
2667 res = dec_lock(fp->lockid);
2671 res = dec_lock(fp->lockid);
2754 while ((ccl = dj.
sclust) != 0) {
2756 if (res !=
FR_OK)
break;
2758 if (res !=
FR_OK)
break;
2761 if (res !=
FR_OK)
break;
2764 if (res !=
FR_OK)
break;
2767 }
while (res ==
FR_OK);
2769 if (res !=
FR_OK)
break;
2777 for (n = 0; tp[n]; n++) ;
2781 while (n) path[--i] = tp[--n];
2786 *tp++ =
'0' + CurrVol;
2793 while (i < sz_path);
2807 #if _FS_MINIMIZE <= 2 2827 DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl;
2831 tlen = *tbl++; ulen = 2;
2836 tcl = cl; ncl = 0; ulen += 2;
2842 }
while (cl == pcl + 1);
2844 *tbl++ = ncl; *tbl++ = tcl;
2855 if (ofs > fp->
fsize)
2859 fp->
clust = clmt_clust(fp, ofs - 1);
2862 dsc += (ofs - 1) /
SS(fp->
fs) & (fp->
fs->
csize - 1);
2884 DWORD clst, bcs, nsect, ifptr;
2893 fp->
fptr = nsect = 0;
2897 (ofs - 1) / bcs >= (ifptr - 1) / bcs) {
2898 fp->
fptr = (ifptr - 1) & ~(bcs - 1);
2931 if (ofs %
SS(fp->
fs)) {
2934 nsect += ofs /
SS(fp->
fs);
2965 #if _FS_MINIMIZE <= 1 3047 #if _FS_MINIMIZE == 0 3092 DWORD n, clst, sect, stat;
3101 if ((*fatfs)->free_clust <= (*fatfs)->n_fatent - 2) {
3102 *nclst = (*fatfs)->free_clust;
3105 fat = (*fatfs)->fs_type;
3111 if (stat == 0xFFFFFFFF) { res =
FR_DISK_ERR;
break; }
3114 }
while (++clst < (*fatfs)->n_fatent);
3116 clst = (*fatfs)->n_fatent;
3117 sect = (*fatfs)->fatbase;
3122 if (res !=
FR_OK)
break;
3130 if ((
LD_DWORD(p) & 0x0FFFFFFF) == 0) n++;
3135 (*fatfs)->free_clust = n;
3136 if (fat ==
FS_FAT32) (*fatfs)->fsi_flag = 1;
3171 if (fp->
fptr == 0) {
3216 if (res ==
FR_OK) res = chk_lock(&dj, 2);
3238 || dclst == sdj.
fs->cdir
3302 dir[33] =
'.'; pcl = dj.
sclust;
3306 for (n = dj.
fs->
csize; n; n--) {
3310 if (res !=
FR_OK)
break;
3423 const TCHAR *path_old,
3424 const TCHAR *path_new
3442 if (res ==
FR_OK) res = chk_lock(&djo, 2);
3467 if (res ==
FR_OK && dir[1] ==
'.') {
3499 #if _USE_FORWARD && _FS_TINY 3509 DWORD remain, clst, sect;
3524 if (btr > remain) btr = (
UINT)remain;
3526 for ( ; btr && (*func)(0, 0);
3527 fp->
fptr += rcnt, *bf += rcnt, btr -= rcnt) {
3529 if ((fp->
fptr %
SS(fp->
fs)) == 0) {
3531 clst = (fp->
fptr == 0) ?
3545 if (rcnt > btr) rcnt = btr;
3556 #if _USE_MKFS && !_FS_READONLY 3560 #define N_ROOTDIR 512 3570 static const WORD vst[] = { 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 0};
3571 static const WORD cst[] = {32768, 16384, 8192, 4096, 2048, 16384, 8192, 4096, 2048, 1024, 512};
3572 BYTE fmt, md, sys, *tbl, pdrv, part;
3573 DWORD n_clst, vs, n, wsect;
3575 DWORD b_vol, b_fat, b_dir, b_data;
3576 DWORD n_vol, n_rsv, n_fat, n_dir;
3611 b_vol = (sfd) ? 0 : 63;
3616 vs = n_vol / (2000 / (
SS(fs) / 512));
3617 for (i = 0; vs < vst[i]; i++) ;
3621 if (au == 0) au = 1;
3622 if (au > 128) au = 128;
3625 n_clst = n_vol / au;
3632 n_fat = ((n_clst * 4) + 8 +
SS(fs) - 1) /
SS(fs);
3636 n_fat = (fmt ==
FS_FAT12) ? (n_clst * 3 + 1) / 2 + 3 : (n_clst * 2) + 4;
3637 n_fat = (n_fat +
SS(fs) - 1) /
SS(fs);
3641 b_fat = b_vol + n_rsv;
3642 b_dir = b_fat + n_fat * N_FATS;
3643 b_data = b_dir + n_dir;
3648 n = (b_data + n - 1) & ~(n - 1);
3649 n = (n - b_data) / N_FATS;
3658 n_clst = (n_vol - n_rsv - n_fat * N_FATS - n_dir) / au;
3665 case FS_FAT16: sys = (n_vol < 0x10000) ? 0x04 : 0x06;
break;
3666 default: sys = 0x0C;
3686 n = (b_vol + n_vol) / 63 / 255;
3687 tbl[6] = (
BYTE)((n >> 2) | 63);
3701 mem_cpy(tbl,
"\xEB\xFE\x90" "MSDOS5.0", 11);
3707 i = (fmt ==
FS_FAT32) ? 0 : N_ROOTDIR;
3709 if (n_vol < 0x10000) {
3743 for (i = 0; i < N_FATS; i++) {
3747 n |= (fmt ==
FS_FAT12) ? 0x00FFFF00 : 0xFFFFFF00;
3758 for (n = 1; n < n_fat; n++) {
3765 i = (fmt ==
FS_FAT32) ? au : n_dir;
3775 eb[0] = wsect; eb[1] = wsect + (n_clst - ((fmt ==
FS_FAT32) ? 1 : 0)) * au - 1;
3795 #if _MULTI_PARTITION == 2 3806 UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl;
3807 BYTE s_hd, e_hd, *p, *buf = (
BYTE*)work;
3809 DWORD sz_disk, sz_part, s_part;
3818 for (n = 16; n < 256 && sz_disk / n / 63 > 1024; n *= 2) ;
3822 tot_cyl = sz_disk / sz_cyl;
3827 for (i = 0; i < 4; i++, p +=
SZ_PTE) {
3828 p_cyl = (szt[i] <= 100) ? (
DWORD)tot_cyl * szt[i] / 100 : szt[i] / sz_cyl;
3829 if (!p_cyl)
continue;
3830 s_part = (
DWORD)sz_cyl * b_cyl;
3831 sz_part = (
DWORD)sz_cyl * p_cyl;
3834 s_part += 63; sz_part -= 63;
3838 e_cyl = b_cyl + p_cyl - 1;
3843 p[2] = (
BYTE)((b_cyl >> 2) + 1);
3847 p[6] = (
BYTE)((e_cyl >> 2) + 63);
3884 while (n < len - 1) {
3890 if (c < 0xC0)
continue;
3894 c = ((c & 0x1F) << 6) | (s[0] & 0x3F);
3895 if (c < 0x80) c =
'?';
3900 c = (c << 12) | ((s[0] & 0x3F) << 6) | (s[1] & 0x3F);
3901 if (c < 0x800) c =
'?';
3908 #if _USE_STRFUNC >= 2 3909 if (c ==
'\r')
continue;
3913 if (c ==
'\n')
break;
3916 return n ? buff : 0;
3935 #if _USE_STRFUNC >= 2 3936 if (c ==
'\n')
f_putc (
'\r', fil);
3945 s[0] = (
BYTE)(0xC0 | (c >> 6));
3946 s[1] = (
BYTE)(0x80 | (c & 0x3F));
3949 s[0] = (
BYTE)(0xE0 | (c >> 12));
3950 s[1] = (
BYTE)(0x80 | ((c >> 6) & 0x3F));
3951 s[2] = (
BYTE)(0x80 | (c & 0x3F));
3960 return (bw == btw) ? 1 :
EOF;
3977 for (n = 0; *str; str++, n++) {
4017 for (cc = res = 0; cc !=
EOF; res += cc) {
4022 if (cc !=
EOF) cc = 1;
4035 w = w * 10 + c -
'0';
4038 if (c ==
'l' || c ==
'L') {
4046 p = va_arg(arp,
TCHAR*);
4047 for (j = 0; p[j]; j++) ;
4050 while (j++ < w) chc += (cc =
f_putc(
' ', fil));
4052 chc += (cc =
f_puts(p, fil));
4053 while (j++ < w) chc += (cc =
f_putc(
' ', fil));
4054 if (cc !=
EOF) cc = chc;
4057 cc =
f_putc((
TCHAR)va_arg(arp,
int), fil);
continue;
4068 cc =
f_putc(c, fil);
continue;
4072 v = (f & 4) ? (
ULONG)va_arg(arp,
long) : ((d ==
'D') ? (
ULONG)(long)va_arg(arp,
int) : (
ULONG)va_arg(arp,
unsigned int));
4073 if (d ==
'D' && (v & 0x80000000)) {
4079 d = (
TCHAR)(v % r); v /= r;
4080 if (d > 9) d += (c ==
'x') ? 0x27 : 0x07;
4082 }
while (v && i <
sizeof(s) /
sizeof(s[0]));
4083 if (f & 8) s[i++] =
'-';
4084 j = i; d = (f & 1) ?
'0' :
' ';
4086 while (!(f & 2) && j++ < w) res += (cc =
f_putc(d, fil));
4087 do res += (cc =
f_putc(s[--i], fil));
while(i);
4088 while (j++ < w) res += (cc =
f_putc(
' ', fil));
4089 if (cc !=
EOF) cc = res;
4092 return (cc ==
EOF) ? cc : res;
DRESULT disk_write(BYTE drv, BYTE const *buff, DWORD sector, BYTE count)
Write sector(s).
FRESULT f_write(FIL *fp, const void *buff, UINT btw, UINT *bw)
DSTATUS disk_status(BYTE drv)
Return disk status.
FRESULT f_getcwd(TCHAR *, UINT)
static FRESULT follow_path(DIR *dj, const TCHAR *path)
static FRESULT dir_sdi(DIR *dj, WORD idx)
static const BYTE LfnOfs[]
static DWORD create_chain(FATFS *fs, DWORD clst)
FRESULT f_mkfs(BYTE, BYTE, UINT)
DRESULT disk_read(BYTE drv, BYTE *buff, DWORD sector, BYTE count)
Read sector(s).
static FRESULT dir_remove(DIR *dj)
GeneratorWrapper< T > value(T &&value)
FRESULT f_forward(FIL *, UINT(*)(const BYTE *, UINT), UINT, UINT *)
int f_printf(FIL *, const TCHAR *,...)
static BYTE sum_sfn(const BYTE *dir)
FRESULT f_rename(const TCHAR *path_old, const TCHAR *path_new)
FRESULT f_truncate(FIL *fp)
#define ST_DWORD(ptr, val)
static int pick_lfn(WCHAR *lfnbuf, BYTE *dir)
FRESULT f_read(FIL *fp, void *buff, UINT btr, UINT *br)
#define CTRL_ERASE_SECTOR
static FRESULT dir_find(DIR *dj)
uint32_t get_fattime(void)
Current time returned is packed into a DWORD value.
static void mem_cpy(void *dst, const void *src, UINT cnt)
static int cmp_lfn(WCHAR *lfnbuf, BYTE *dir)
static void get_fileinfo(DIR *dj, FILINFO *fno)
#define ST_CLUST(dir, cl)
FRESULT f_chdir(const TCHAR *)
int f_vprintf(FIL *, const TCHAR *, va_list arp)
static BYTE check_fs(FATFS *fs, DWORD sect)
FRESULT f_utime(const TCHAR *path, const FILINFO *fno)
static FRESULT sync(FATFS *fs)
static FRESULT remove_chain(FATFS *fs, DWORD clst)
static FRESULT dir_register(DIR *dj)
FRESULT f_lseek(FIL *fp, DWORD ofs)
FRESULT f_chmod(const TCHAR *path, BYTE value, BYTE mask)
static FATFS * FatFs[_VOLUMES]
WCHAR ff_convert(WCHAR, UINT)
#define ST_WORD(ptr, val)
static FRESULT move_window(FATFS *fs, DWORD sector)
int f_puts(const TCHAR *, FIL *)
static void fit_lfn(const WCHAR *lfnbuf, BYTE *dir, BYTE ord, BYTE sum)
static FRESULT dir_read(DIR *dj)
FRESULT f_unlink(const TCHAR *path)
FRESULT f_getfree(const TCHAR *path, DWORD *nclst, FATFS **fatfs)
FRESULT f_readdir(DIR *dj, FILINFO *fno)
DRESULT disk_ioctl(BYTE drv, BYTE ctrl, void *buff)
Miscellaneous functions, which support the following commands:
FRESULT f_fdisk(BYTE, const DWORD[], void *)
FRESULT f_open(FIL *fp, const TCHAR *path, BYTE mode)
TCHAR * f_gets(TCHAR *, int, FIL *)
FRESULT f_stat(const TCHAR *path, FILINFO *fno)
static DWORD get_fat(FATFS *fs, DWORD clst)
static int chk_chr(const char *str, int chr)
static FRESULT chk_mounted(const TCHAR **path, FATFS **rfs, BYTE chk_wp)
FRESULT f_mount(BYTE vol, FATFS *fs)
static void mem_set(void *dst, int val, UINT cnt)
static FRESULT validate(FATFS *fs, WORD id)
static void gen_numname(BYTE *dst, const BYTE *src, const WCHAR *lfn, WORD seq)
static FRESULT put_fat(FATFS *fs, DWORD clst, DWORD val)
static FRESULT dir_next(DIR *dj, int stretch)
#define LEAVE_FF(fs, res)
static int mem_cmp(const void *dst, const void *src, UINT cnt)
FRESULT f_opendir(DIR *dj, const TCHAR *path)
FRESULT f_mkdir(const TCHAR *path)
DSTATUS disk_initialize(BYTE drv)
Initialize a disk.
static DWORD clust2sect(FATFS *fs, DWORD clst)
static FRESULT create_name(DIR *dj, const TCHAR **path)