35 #error Wrong include file (ff.h). 39 #define ABORT(fs, res) { fp->err = (BYTE)(res); LEAVE_FF(fs, res); } 45 #error Static LFN work area cannot be used at thread-safe configuration 47 #define ENTER_FF(fs) { if (!lock_fs(fs)) return FR_TIMEOUT; } 48 #define LEAVE_FF(fs, res) { unlock_fs(fs, res); return res; } 51 #define LEAVE_FF(fs, res) return res 57 #if (_MAX_SS < _MIN_SS) || (_MAX_SS != 512 && _MAX_SS != 1024 && _MAX_SS != 2048 && _MAX_SS != 4096) || (_MIN_SS != 512 && _MIN_SS != 1024 && _MIN_SS != 2048 && _MIN_SS != 4096) 58 #error Wrong sector size configuration 60 #if _MAX_SS == _MIN_SS 61 #define SS(fs) ((UINT)_MAX_SS) 63 #define SS(fs) ((fs)->ssize) 69 #if _NORTC_YEAR < 1980 || _NORTC_YEAR > 2107 || _NORTC_MON < 1 || _NORTC_MON > 12 || _NORTC_MDAY < 1 || _NORTC_MDAY > 31 70 #error Invalid _FS_NORTC settings 72 #define GET_FATTIME() ((DWORD)(_NORTC_YEAR - 1980) << 25 | (DWORD)_NORTC_MON << 21 | (DWORD)_NORTC_MDAY << 16) 74 #define GET_FATTIME() get_fattime() 81 #error _FS_LOCK must be 0 at read-only configuration 105 #elif _CODE_PAGE == 936 113 #elif _CODE_PAGE == 949 123 #elif _CODE_PAGE == 950 131 #elif _CODE_PAGE == 437 133 #define _EXCVT {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \ 134 0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ 135 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ 136 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0x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F} 153 #elif _CODE_PAGE == 737 155 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ 156 0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \ 157 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96, \ 158 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ 159 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ 160 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ 161 0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xEF,0xF5,0xF0,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ 162 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} 164 #elif _CODE_PAGE == 771 166 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ 167 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ 168 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ 169 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ 170 0xC0,0xC1,0xC2,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 862 254 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ 255 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ 256 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ 257 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ 258 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ 259 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ 260 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ 261 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} 263 #elif _CODE_PAGE == 863 265 #define _EXCVT {0x43,0x55,0x45,0x41,0x41,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x41,0x8F, \ 266 0x45,0x45,0x45,0x4F,0x45,0x49,0x55,0x55,0x98,0x4F,0x55,0x9B,0x9C,0x55,0x55,0x9F, \ 267 0xA0,0xA1,0x4F,0x55,0xA4,0xA5,0xA6,0xA7,0x49,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ 268 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ 269 0xC0,0xC1,0xC2,0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xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ 303 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ 304 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ 305 0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} 307 #elif _CODE_PAGE == 869 309 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ 310 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x86,0x9C,0x8D,0x8F,0x90, \ 311 0x91,0x90,0x92,0x95,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ 312 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ 313 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ 314 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xA4,0xA5,0xA6,0xD9,0xDA,0xDB,0xDC,0xA7,0xA8,0xDF, \ 315 0xA9,0xAA,0xAC,0xAD,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xCF,0xCF,0xD0,0xEF, \ 316 0xF0,0xF1,0xD1,0xD2,0xD3,0xF5,0xD4,0xF7,0xF8,0xF9,0xD5,0x96,0x95,0x98,0xFE,0xFF} 318 #elif _CODE_PAGE == 1 320 #error Cannot enable LFN without valid code page. 325 #error Unknown code page 331 #define IsUpper(c) (((c)>='A')&&((c)<='Z')) 332 #define IsLower(c) (((c)>='a')&&((c)<='z')) 333 #define IsDigit(c) (((c)>='0')&&((c)<='9')) 338 #define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) 340 #define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) 344 #define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) 346 #define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) 364 #define FA_SEEKEND 0x20 365 #define FA_MODIFIED 0x40 366 #define FA_DIRTY 0x80 377 #define NS_NOLFN 0x40 378 #define NS_NONAME 0x80 382 #define MAX_FAT12 0xFF5 383 #define MAX_FAT16 0xFFF5 384 #define MAX_FAT32 0xFFFFFF5 385 #define MAX_EXFAT 0x7FFFFFFD 386 #define MAX_DIR 0x200000 387 #define MAX_DIR_EX 0x10000000 396 #define BPB_BytsPerSec 11 397 #define BPB_SecPerClus 13 398 #define BPB_RsvdSecCnt 14 399 #define BPB_NumFATs 16 400 #define BPB_RootEntCnt 17 401 #define BPB_TotSec16 19 403 #define BPB_FATSz16 22 404 #define BPB_SecPerTrk 24 405 #define BPB_NumHeads 26 406 #define BPB_HiddSec 28 407 #define BPB_TotSec32 32 410 #define BS_BootSig 38 413 #define BS_FilSysType 54 414 #define BS_BootCode 62 417 #define BPB_FATSz32 36 418 #define BPB_ExtFlags32 40 419 #define BPB_FSVer32 42 420 #define BPB_RootClus32 44 421 #define BPB_FSInfo32 48 422 #define BPB_BkBootSec32 50 423 #define BS_DrvNum32 64 424 #define BS_NTres32 65 425 #define BS_BootSig32 66 426 #define BS_VolID32 67 427 #define BS_VolLab32 71 428 #define BS_FilSysType32 82 429 #define BS_BootCode32 90 431 #define BPB_ZeroedEx 11 432 #define BPB_VolOfsEx 64 433 #define BPB_TotSecEx 72 434 #define BPB_FatOfsEx 80 435 #define BPB_FatSzEx 84 436 #define BPB_DataOfsEx 88 437 #define BPB_NumClusEx 92 438 #define BPB_RootClusEx 96 439 #define BPB_VolIDEx 100 440 #define BPB_FSVerEx 104 441 #define BPB_VolFlagEx 106 442 #define BPB_ActFatEx 107 443 #define BPB_BytsPerSecEx 108 444 #define BPB_SecPerClusEx 109 445 #define BPB_NumFATsEx 110 446 #define BPB_DrvNumEx 111 447 #define BPB_PercInUseEx 112 448 #define BPB_RsvdEx 113 449 #define BS_BootCodeEx 120 451 #define FSI_LeadSig 0 452 #define FSI_StrucSig 484 453 #define FSI_Free_Count 488 454 #define FSI_Nxt_Free 492 456 #define MBR_Table 446 467 #define PTE_SizLba 12 472 #define DIR_CrtTime10 13 473 #define DIR_CrtTime 14 474 #define DIR_LstAccDate 18 475 #define DIR_FstClusHI 20 476 #define DIR_ModTime 22 477 #define DIR_FstClusLO 26 478 #define DIR_FileSize 28 482 #define LDIR_Chksum 13 483 #define LDIR_FstClusLO 26 485 #define XDIR_NumLabel 1 487 #define XDIR_CaseSum 4 488 #define XDIR_NumSec 1 489 #define XDIR_SetSum 2 491 #define XDIR_CrtTime 8 492 #define XDIR_ModTime 12 493 #define XDIR_AccTime 16 494 #define XDIR_CrtTime10 20 495 #define XDIR_ModTime10 21 496 #define XDIR_CrtTZ 22 497 #define XDIR_ModTZ 23 498 #define XDIR_AccTZ 24 499 #define XDIR_GenFlags 33 500 #define XDIR_NumName 35 501 #define XDIR_NameHash 36 502 #define XDIR_ValidFileSize 40 503 #define XDIR_FstClus 52 504 #define XDIR_FileSize 56 525 #if _VOLUMES < 1 || _VOLUMES > 9 526 #error Wrong _VOLUMES setting 531 #if _FS_RPATH != 0 && _VOLUMES >= 2 541 #define INIT_NAMBUF(fs) 542 #define FREE_NAMBUF() 544 #if _MAX_LFN < 12 || _MAX_LFN > 255 545 #error Wrong _MAX_LFN setting 554 #define INIT_NAMBUF(fs) 555 #define FREE_NAMBUF() 559 #define DEF_NAMBUF WCHAR lbuf[_MAX_LFN+1]; BYTE dbuf[SZDIRE*19]; 560 #define INIT_NAMBUF(fs) { (fs)->lfnbuf = lbuf; (fs)->dirbuf = dbuf; } 561 #define FREE_NAMBUF() 563 #define DEF_NAMBUF WCHAR lbuf[_MAX_LFN+1]; 564 #define INIT_NAMBUF(fs) { (fs)->lfnbuf = lbuf; } 565 #define FREE_NAMBUF() 570 #define DEF_NAMBUF WCHAR *lfn; 571 #define INIT_NAMBUF(fs) { lfn = ff_memalloc((_MAX_LFN+1)*2 + SZDIRE*19); if (!lfn) LEAVE_FF(fs, FR_NOT_ENOUGH_CORE); (fs)->lfnbuf = lfn; (fs)->dirbuf = (BYTE*)(lfn+_MAX_LFN+1); } 572 #define FREE_NAMBUF() ff_memfree(lfn) 574 #define DEF_NAMBUF WCHAR *lfn; 575 #define INIT_NAMBUF(fs) { lfn = ff_memalloc((_MAX_LFN+1)*2); if (!lfn) LEAVE_FF(fs, FR_NOT_ENOUGH_CORE); (fs)->lfnbuf = lfn; } 576 #define FREE_NAMBUF() ff_memfree(lfn) 580 #error Wrong _USE_LFN setting 610 rv = rv << 8 | ptr[0];
620 rv = rv << 8 | ptr[2];
621 rv = rv << 8 | ptr[1];
622 rv = rv << 8 | ptr[0];
633 rv = rv << 8 | ptr[6];
634 rv = rv << 8 | ptr[5];
635 rv = rv << 8 | ptr[4];
636 rv = rv << 8 | ptr[3];
637 rv = rv << 8 | ptr[2];
638 rv = rv << 8 | ptr[1];
639 rv = rv << 8 | ptr[0];
648 *ptr++ = (
BYTE)val; val >>= 8;
655 *ptr++ = (
BYTE)val; val >>= 8;
656 *ptr++ = (
BYTE)val; val >>= 8;
657 *ptr++ = (
BYTE)val; val >>= 8;
665 *ptr++ = (
BYTE)val; val >>= 8;
666 *ptr++ = (
BYTE)val; val >>= 8;
667 *ptr++ = (
BYTE)val; val >>= 8;
668 *ptr++ = (
BYTE)val; val >>= 8;
669 *ptr++ = (
BYTE)val; val >>= 8;
670 *ptr++ = (
BYTE)val; val >>= 8;
671 *ptr++ = (
BYTE)val; val >>= 8;
691 do *d++ = *s++;
while (--cnt);
701 do *d++ = (
BYTE)val;
while (--cnt);
708 const BYTE *d = (
const BYTE *)dst, *s = (
const BYTE *)src;
713 }
while (--cnt && r == 0);
722 while (*str && *str != chr) str++;
739 return ff_req_grant(fs->sobj);
751 ff_rel_grant(fs->sobj);
774 for (i = be = 0; i <
_FS_LOCK; i++) {
776 if (Files[i].fs == dp->
obj.
fs &&
778 Files[i].ofs == dp->
dptr)
break;
798 for (i = 0; i <
_FS_LOCK && Files[i].fs; i++) ;
814 if (Files[i].fs == dp->
obj.
fs &&
816 Files[i].ofs == dp->
dptr)
break;
820 for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ;
821 if (i == _FS_LOCK)
return 0;
822 Files[i].fs = dp->
obj.
fs;
824 Files[i].ofs = dp->
dptr;
828 if (acc && Files[i].ctr)
return 0;
830 Files[i].ctr = acc ? 0x100 : Files[i].ctr + 1;
848 if (n == 0x100) n = 0;
851 if (n == 0) Files[i].fs = 0;
869 if (Files[i].fs == fs) Files[i].fs = 0;
899 for (nf = fs->
n_fats; nf >= 2; nf--) {
992 if (clst >= fs->
n_fatent - 2)
return 0;
1015 if (clst < 2 || clst >= fs->
n_fatent) {
1023 bc = (
UINT)clst; bc += bc / 2;
1025 wc = fs->
win[bc++ %
SS(fs)];
1027 wc |= fs->
win[bc %
SS(fs)] << 8;
1028 val = (clst & 1) ? (wc >> 4) : (wc & 0xFFF);
1046 if (obj->
stat == 2) {
1048 val = (cofs == clen) ? 0x7FFFFFFF : clst + 1;
1052 if (obj->
stat == 3 && cofs < obj->n_cont) {
1056 if (obj->
stat != 2) {
1093 if (clst >= 2 && clst < fs->n_fatent) {
1096 bc = (
UINT)clst; bc += bc / 2;
1098 if (res !=
FR_OK)
break;
1099 p = fs->
win + bc++ %
SS(fs);
1100 *p = (clst & 1) ? ((*p & 0x0F) | ((
BYTE)val << 4)) : (
BYTE)val;
1103 if (res !=
FR_OK)
break;
1104 p = fs->
win + bc %
SS(fs);
1105 *p = (clst & 1) ? (
BYTE)(val >> 4) : ((*p & 0xF0) | ((
BYTE)(val >> 8) & 0x0F));
1111 if (res !=
FR_OK)
break;
1121 if (res !=
FR_OK)
break;
1123 val = (val & 0x0FFFFFFF) | (
ld_dword(fs->
win + clst * 4 %
SS(fs)) & 0xF0000000);
1138 #if _FS_EXFAT && !_FS_READONLY 1157 DWORD val, scl, ctr;
1161 if (clst >= fs->
n_fatent - 2) clst = 0;
1162 scl = val = clst; ctr = 0;
1165 i = val / 8 %
SS(fs); bm = 1 << (val % 8);
1168 bv = fs->
win[i] & bm; bm <<= 1;
1170 val = 0; bm = 0; i = 4096;
1173 if (++ctr == ncl)
return scl + 2;
1177 if (val == clst)
return 0;
1180 }
while (++i <
SS(fs));
1205 i = clst / 8 %
SS(fs);
1206 bm = 1 << (clst % 8);
1214 if (--ncl == 0)
return FR_OK;
1217 }
while (++i <
SS(fs));
1236 if (obj->
stat == 3) {
1237 for (cl = obj->
sclust, n = obj->n_cont; n; cl++, n--) {
1239 if (res !=
FR_OK)
return res;
1265 #if _FS_EXFAT || _USE_TRIM 1266 DWORD scl = clst, ecl = clst;
1276 res =
put_fat(fs, pclst, 0xFFFFFFFF);
1277 if (res !=
FR_OK)
return res;
1283 if (nxt == 0)
break;
1288 if (res !=
FR_OK)
return res;
1294 #if _FS_EXFAT || _USE_TRIM 1295 if (ecl + 1 == nxt) {
1300 res = change_bitmap(fs, scl, ecl - scl + 1, 0);
1301 if (res !=
FR_OK)
return res;
1313 }
while (clst < fs->n_fatent);
1320 if (obj->
stat == 3 && pclst >= obj->
sclust && pclst <= obj->sclust + obj->n_cont) {
1349 if (scl == 0 || scl >= fs->
n_fatent) scl = 1;
1353 if (cs < 2)
return 1;
1354 if (cs == 0xFFFFFFFF)
return cs;
1355 if (cs < fs->n_fatent)
return cs;
1361 ncl = find_bitmap(fs, scl, 1);
1362 if (ncl == 0 || ncl == 0xFFFFFFFF)
return ncl;
1363 res = change_bitmap(fs, ncl, 1, 1);
1369 if (obj->
stat == 2 && ncl != scl + 1) {
1370 obj->n_cont = scl - obj->
sclust;
1382 if (ncl > scl)
return 0;
1386 if (cs == 1 || cs == 0xFFFFFFFF)
return cs;
1387 if (ncl == scl)
return 0;
1394 res =
put_fat(fs, ncl, 0xFFFFFFFF);
1395 if (res ==
FR_OK && clst) {
1428 DWORD cl, ncl, *tbl;
1432 tbl = fp->
cltbl + 1;
1436 if (ncl == 0)
return 0;
1437 if (cl < ncl)
break;
1479 while (ofs >= csz) {
1489 dp->
sect += ofs /
SS(fs);
1490 dp->
dir = fs->
win + (ofs %
SS(fs));
1518 if (ofs %
SS(fs) == 0) {
1527 if ((ofs /
SS(fs) & (fs->
csize - 1)) == 0) {
1550 if (!stretch) dp->
sect = 0;
1590 if (res !=
FR_OK)
break;
1596 if (++n == nent)
break;
1601 }
while (res ==
FR_OK);
1658 const BYTE LfnOfs[] = {1,3,5,7,9,14,16,18,20,22,24,28,30};
1667 const WCHAR* lfnbuf,
1677 i = ((dir[
LDIR_Ord] & 0x3F) - 1) * 13;
1679 for (wc = 1, s = 0; s < 13; s++) {
1680 uc =
ld_word(dir + LfnOfs[s]);
1687 if (uc != 0xFFFF)
return 0;
1691 if ((dir[
LDIR_Ord] &
LLEF) && wc && lfnbuf[i])
return 0;
1697 #if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 || _USE_LABEL || _FS_EXFAT 1714 i = ((dir[
LDIR_Ord] & 0x3F) - 1) * 13;
1716 for (wc = 1, s = 0; s < 13; s++) {
1717 uc =
ld_word(dir + LfnOfs[s]);
1720 lfnbuf[i++] = wc = uc;
1722 if (uc != 0xFFFF)
return 0;
1761 if (wc != 0xFFFF) wc = lfn[i++];
1763 if (wc == 0) wc = 0xFFFF;
1765 if (wc == 0xFFFF || !lfn[i]) ord |=
LLEF;
1774 #if _USE_LFN != 0 && !_FS_READONLY 1800 for (i = 0; i < 16; i++) {
1801 sr = (sr << 1) + (wc & 1);
1803 if (sr & 0x10000) sr ^= 0x11021;
1812 c = (
BYTE)((seq % 16) +
'0');
1813 if (c >
'9') c += 7;
1820 for (j = 0; j < i && dst[j] !=
' '; j++) {
1822 if (j == i - 1)
break;
1827 dst[j++] = (i < 8) ? ns[i++] :
' ';
1848 do sum = (sum >> 1) + (sum << 7) + *dir++;
while (--n);
1872 for (i = sum = 0; i < szblk; i++) {
1876 sum = ((sum & 1) ? 0x8000 : 0) + (sum >> 1) + dir[i];
1894 while ((chr = *name++) != 0) {
1896 sum = ((sum & 1) ? 0x8000 : 0) + (sum >> 1) + (chr & 0xFF);
1897 sum = ((sum & 1) ? 0x8000 : 0) + (sum >> 1) + (chr >> 8);
1903 #if !_FS_READONLY && _USE_MKFS 1911 sum = ((sum & 1) ? 0x80000000 : 0) + (sum >> 1) + dat;
1917 #if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 1924 void get_xdir_info (
1939 if ((si %
SZDIRE) == 0) si += 2;
1948 if ((si %
SZDIRE) == 0) si += 2;
1951 if (w == 0) { di = 0;
break; }
1952 if (
_DF1S && w >= 0x100) {
1953 fno->
fname[di++] = (char)(w >> 8);
1955 if (di >=
_MAX_LFN) { di = 0;
break; }
1956 fno->
fname[di++] = (char)w;
1959 if (di == 0) fno->
fname[di++] =
'?';
1989 if (res !=
FR_OK)
return res;
1996 if (res !=
FR_OK)
return res;
1998 if (res !=
FR_OK)
return res;
2003 if (nent < 3 || nent > 19)
return FR_NO_FILE;
2007 if (res !=
FR_OK)
return res;
2009 if (res !=
FR_OK)
return res;
2022 #if !_FS_READONLY || _FS_RPATH != 0 2045 res = load_xdir(dp);
2072 while (res ==
FR_OK) {
2074 if (res !=
FR_OK)
break;
2077 if (--nent == 0)
break;
2108 nc = 0; nb = 1; chr = 1;
2110 dirb[i++] = 0xC1; dirb[i++] = 0;
2112 if (chr && (chr = lfn[nc]) != 0) nc++;
2113 st_word(dirb + i, chr); i += 2;
2127 #if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 || _USE_LABEL || _FS_EXFAT 2143 BYTE ord = 0xFF, sum = 0xFF;
2148 if (res !=
FR_OK)
break;
2154 if (c == 0x83)
break;
2158 res = load_xdir(dp);
2176 c &= (
BYTE)~LLEF; ord = c;
2195 if (res !=
FR_OK)
break;
2224 if (res !=
FR_OK)
return res;
2233 for (nc = fs->dirbuf[
XDIR_NumName], di =
SZDIRE * 2, ni = 0; nc; nc--, di += 2, ni++) {
2234 if ((di %
SZDIRE) == 0) di += 2;
2237 if (nc == 0 && !fs->
lfnbuf[ni])
break;
2244 ord = sum = 0xFF; dp->
blk_ofs = 0xFFFFFFFF;
2248 if (res !=
FR_OK)
break;
2254 ord = 0xFF; dp->
blk_ofs = 0xFFFFFFFF;
2260 c &= (
BYTE)~LLEF; ord = c;
2269 ord = 0xFF; dp->
blk_ofs = 0xFFFFFFFF;
2277 }
while (res ==
FR_OK);
2304 for (nlen = 0; fs->
lfnbuf[nlen]; nlen++) ;
2310 nent = (nlen + 14) / 15 + 2;
2312 if (res !=
FR_OK)
return res;
2318 res = fill_fat_chain(&dp->
obj);
2319 if (res !=
FR_OK)
return res;
2320 res = load_obj_dir(&dj, &dp->
obj);
2321 if (res !=
FR_OK)
return res;
2325 res = store_xdir(&dj);
2326 if (res !=
FR_OK)
return res;
2329 create_xdir(fs->dirbuf, fs->
lfnbuf);
2337 for (n = 1; n < 100; n++) {
2340 if (res !=
FR_OK)
break;
2348 nent = (sn[
NSFLAG] &
NS_LFN) ? (nlen + 12) / 13 + 1 : 1;
2350 if (res ==
FR_OK && --nent) {
2356 if (res !=
FR_OK)
break;
2360 }
while (res ==
FR_OK && --nent);
2389 #if !_FS_READONLY && _FS_MINIMIZE == 0 2409 if (res !=
FR_OK)
break;
2417 if (dp->
dptr >= last)
break;
2419 }
while (res ==
FR_OK);
2438 #if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 2460 if (!dp->
sect)
return;
2465 get_xdir_info(fs->dirbuf, fno);
2470 if (dp->
blk_ofs != 0xFFFFFFFF) {
2472 while ((w = fs->
lfnbuf[j++]) != 0) {
2475 if (w == 0) { i = 0;
break; }
2476 if (
_DF1S && w >= 0x100) {
2477 fno->
fname[i++] = (char)(w >> 8);
2480 if (i >=
_MAX_LFN) { i = 0;
break; }
2488 lfv = fno->
fname[i];
2491 if (c ==
' ')
continue;
2494 if (!lfv) fno->
fname[j] =
'.';
2499 c = c << 8 | dp->
dir[i++];
2523 if (c ==
' ')
continue;
2525 if (i == 9) fno->
fname[j++] =
'.';
2526 fno->
fname[j++] = c;
2541 #if _USE_FIND && _FS_MINIMIZE <= 1 2555 chr = (
BYTE)*(*ptr)++;
2556 if (
IsLower(chr)) chr -= 0x20;
2558 if (chr >= 0x80) chr =
ExCvt[chr - 0x80];
2561 chr = chr << 8 | (
BYTE)*(*ptr)++;
2580 const TCHAR *pp, *np;
2588 if (!*pat && inf)
return 1;
2593 if (*pp ==
'?' || *pp ==
'*') {
2596 if (*pp++ ==
'?') nm++;
else nx = 1;
2597 }
while (*pp ==
'?' || *pp ==
'*');
2603 if (pc != nc)
break;
2604 if (pc == 0)
return 1;
2607 }
while (inf && nc);
2638 if (w ==
'/' || w ==
'\\') {
2639 while (p[si] ==
'/' || p[si] ==
'\\') si++;
2659 if ((di == 1 && lfn[di - 1] ==
'.') ||
2660 (di == 2 && lfn[di - 1] ==
'.' && lfn[di - 2] ==
'.')) {
2662 for (i = 0; i < 11; i++)
2663 dp->
fn[i] = (i < di) ?
'.' :
' ';
2670 if (w !=
' ' && w !=
'.')
break;
2678 for (si = 0; lfn[si] ==
' ' || lfn[si] ==
'.'; si++) ;
2680 while (di && lfn[di - 1] !=
'.') di--;
2686 if (w ==
' ' || (w ==
'.' && si != di)) {
2690 if (i >= ni || si == di) {
2696 si = di; i = 8; ni = 11;
2703 if (w) w =
ExCvt[w - 0x80];
2710 if (
_DF1S && w >= 0x100) {
2714 dp->
fn[i++] = (
BYTE)(w >> 8);
2716 if (!w ||
chk_chr(
"+,;=[]", w)) {
2733 if (ni == 8) b <<= 2;
2734 if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03) cf |=
NS_LFN;
2736 if ((b & 0x03) == 0x01) cf |=
NS_EXT;
2737 if ((b & 0x0C) == 0x04) cf |=
NS_BODY;
2751 p = *path; sfn = dp->
fn;
2758 if (c !=
'.' || si >= 3)
break;
2769 if (c <=
' ')
break;
2770 if (c ==
'/' || c ==
'\\') {
2771 while (p[si] ==
'/' || p[si] ==
'\\') si++;
2774 if (c ==
'.' || i >= ni) {
2781 c =
ExCvt[c - 0x80];
2830 if (*path !=
'/' && *path !=
'\\') {
2835 while (*path ==
'/' || *path ==
'\\') path++;
2838 #if _FS_EXFAT && _FS_RPATH != 0 2842 obj->c_scl = fs->cdc_scl;
2843 obj->c_size = fs->cdc_size;
2844 obj->c_ofs = fs->cdc_ofs;
2845 res = load_obj_dir(&dj, obj);
2846 if (res !=
FR_OK)
return res;
2852 if ((
UINT)*path <
' ') {
2859 if (res !=
FR_OK)
break;
2865 if (!(ns &
NS_LAST))
continue;
2881 obj->c_scl = obj->
sclust;
2911 const TCHAR *tp, *tt;
2923 for (tt = *path; (
UINT)*tt >= (
_USE_LFN ?
' ' :
'!') && *tt !=
':'; tt++) ;
2927 if (i < 10 && tp == tt) {
2937 sp = str[i]; tp = *path;
2939 c = *sp++; tc = *tp++;
2941 }
while (c && (
TCHAR)c == tc);
2942 }
while ((c || tp != tt) && ++i <
_VOLUMES);
2951 #if _FS_RPATH != 0 && _VOLUMES >= 2 3007 DWORD bsect, fasize, tsect, sysect, nclst, szbfat, br[4];
3048 #if _MAX_SS != _MIN_SS 3055 if (fmt == 2 || (fmt < 2 &&
LD2PT(vol) != 0)) {
3056 for (i = 0; i < 4; i++) {
3064 fmt = bsect ?
check_fs(fs, bsect) : 3;
3065 }
while (!
LD2PT(vol) && fmt >= 2 && ++i < 4);
3108 for (i = 0; i <
SS(fs); i +=
SZDIRE) {
3109 if (fs->
win[i] == 0x81 && ld_dword(fs->
win + i + 20) == 2)
break;
3144 nclst = (tsect - sysect) / fs->
csize;
3172 #if (_FS_NOFSINFO & 3) != 3 3182 #if (_FS_NOFSINFO & 1) == 0 3185 #if (_FS_NOFSINFO & 2) == 0 3199 fs->dirbuf = DirBuf;
3264 const TCHAR *rp = path;
3277 if (!ff_del_syncobj(cfs->sobj))
return FR_INT_ERR;
3290 if (!fs || opt != 1)
return FR_OK;
3314 DWORD dw, cl, bcs, clst, sc;
3336 res = chk_lock(&dj, (mode & ~
FA_READ) ? 1 : 0);
3377 res = store_xdir(&dj);
3422 fp->
obj.lockid = inc_lock(&dj, (mode & ~
FA_READ) ? 1 : 0);
3476 if (res ==
FR_OK && ofs %
SS(fs)) {
3517 UINT rcnt, cc, csect;
3526 if (btr > remain) btr = (
UINT)remain;
3529 rbuff += rcnt, fp->
fptr += rcnt, *br += rcnt, btr -= rcnt) {
3530 if (fp->
fptr %
SS(fs) == 0) {
3533 if (fp->
fptr == 0) {
3554 if (csect + cc > fs->
csize) {
3555 cc = fs->
csize - csect;
3558 #if !_FS_READONLY && _FS_MINIMIZE <= 2 3573 if (fp->
sect != sect) {
3586 if (rcnt > btr) rcnt = btr;
3617 UINT wcnt, cc, csect;
3618 const BYTE *wbuff = (
const BYTE*)buff;
3633 if (fp->
fptr %
SS(fs) == 0) {
3636 if (fp->
fptr == 0) {
3651 if (clst == 0)
break;
3670 if (csect + cc > fs->
csize) {
3671 cc = fs->
csize - csect;
3674 #if _FS_MINIMIZE <= 2 3676 if (fs->
winsect - sect < cc) {
3681 if (fp->
sect - sect < cc) {
3696 if (fp->
sect != sect &&
3705 if (wcnt > btw) wcnt = btw;
3753 res = fill_fat_chain(&fp->
obj);
3758 res = load_obj_dir(&dj, &fp->
obj);
3768 res = store_xdir(&dj);
3823 res = dec_lock(fp->
obj.lockid);
3830 unlock_fs(fs,
FR_OK);
3858 CurrVol = (
BYTE)vol;
3886 fs->cdc_scl = dj.
obj.c_scl;
3887 fs->cdc_size = dj.
obj.c_size;
3888 fs->cdc_ofs = dj.
obj.c_ofs;
3945 if (res !=
FR_OK)
break;
3947 if (res !=
FR_OK)
break;
3950 if (res !=
FR_OK)
break;
3953 if (res !=
FR_OK)
break;
3956 }
while (res ==
FR_OK);
3958 if (res !=
FR_OK)
break;
3960 for (n = 0; fno.
fname[n]; n++) ;
3964 while (n) buff[--i] = fno.
fname[--n];
3971 *tp++ =
'0' + CurrVol;
3994 #if _FS_MINIMIZE <= 2 4007 DWORD clst, bcs, nsect;
4010 DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl;
4019 tlen = *tbl++; ulen = 2;
4024 tcl = cl; ncl = 0; ulen += 2;
4030 }
while (cl == pcl + 1);
4032 *tbl++ = ncl; *tbl++ = tcl;
4034 }
while (cl < fs->n_fatent);
4076 fp->
fptr = nsect = 0;
4080 (ofs - 1) / bcs >= (ifptr - 1) / bcs) {
4098 ofs -= bcs; fp->
fptr += bcs;
4122 nsect += (
DWORD)(ofs /
SS(fs));
4130 if (fp->
fptr %
SS(fs) && nsect != fp->
sect) {
4149 #if _FS_MINIMIZE <= 1 4180 obj->c_scl = obj->
sclust;
4201 obj->lockid = inc_lock(dp, 0);
4213 if (res !=
FR_OK) obj->
fs = 0;
4237 if (dp->
obj.lockid) {
4238 res = dec_lock(dp->
obj.lockid);
4246 unlock_fs(fs,
FR_OK);
4307 if (res !=
FR_OK || !fno || !fno->
fname[0])
break;
4309 #if _USE_LFN != 0 && _USE_FIND == 2 4327 const TCHAR* pattern
4345 #if _FS_MINIMIZE == 0 4412 clst = 2; obj.
fs = fs;
4415 if (stat == 0xFFFFFFFF) { res =
FR_DISK_ERR;
break; }
4417 if (stat == 0) nfree++;
4418 }
while (++clst < fs->n_fatent);
4430 for (b = 8, bm = fs->
win[i]; b && clst; b--, clst--) {
4431 if (!(bm & 1)) nfree++;
4434 i = (i + 1) %
SS(fs);
4444 if (res !=
FR_OK)
break;
4452 if ((
ld_dword(p) & 0x0FFFFFFF) == 0) nfree++;
4489 if (fp->
fptr == 0) {
4497 if (res ==
FR_OK && ncl < fs->n_fatent) {
4550 if (res ==
FR_OK) res = chk_lock(&dj, 2);
4574 if (dclst == fs->
cdir) {
4598 if (res ==
FR_OK && dclst) {
4669 for (n = fs->
csize; n; n--) {
4673 if (res !=
FR_OK)
break;
4687 res = store_xdir(&dj);
4717 const TCHAR* path_old,
4718 const TCHAR* path_new
4737 if (res ==
FR_OK) res = chk_lock(&djo, 2);
4746 mem_cpy(&djn, &djo,
sizeof djo);
4760 res = store_xdir(&djn);
4776 mem_cpy(dir + 13, buf + 2, 19);
4787 if (res ==
FR_OK && dir[1] ==
'.') {
4817 #if _USE_CHMOD && !_FS_READONLY 4846 res = store_xdir(&dj);
4890 res = store_xdir(&dj);
4925 #if _LFN_UNICODE || _FS_EXFAT 4933 if (res ==
FR_OK && label) {
4947 if (w == 0) w =
'?';
4948 if (
_DF1S && w >= 0x100) label[di++] = (char)(w >> 8);
4949 label[di++] = (char)w;
4959 w = (si < 11) ? dj.
dir[si++] :
' ';
4961 w = w << 8 | dj.
dir[si++];
4965 label[di++] = dj.
dir[si++];
4971 }
while (label[--di] ==
' ');
4982 if (res ==
FR_OK && vsn) {
5015 static const char badchr[] =
"\"*+,.:;<=>\?[]|\x7F";
5024 for (slen = 0; (
UINT)label[slen] >=
' '; slen++) ;
5028 for (i = j = 0; i < slen; ) {
5032 w = (i < slen &&
IsDBCS2(label[i])) ? w << 8 | (
BYTE)label[i++] : 0;
5036 if (w == 0 ||
chk_chr(badchr, w) || j == 22) {
5039 st_word(dirvn + j, w); j += 2;
5045 for ( ; slen && label[slen - 1] ==
' '; slen--) ;
5047 dirvn[0] = 0; i = j = 0;
5052 w = (
BYTE)label[i++];
5054 w = (j < 10 && i < slen &&
IsDBCS2(label[i])) ? w << 8 | (
BYTE)label[i++] : 0;
5061 if (w >= 0x80) w =
ExCvt[w - 0x80];
5063 if (!
_DF1S && w >= 0x80) w = 0;
5067 if (w == 0 ||
chk_chr(badchr, w) || j >= (
UINT)((w >= 0x100) ? 10 : 11)) {
5070 if (w >= 0x100) dirvn[j++] = (
BYTE)(w >> 8);
5071 dirvn[j++] = (
BYTE)w;
5073 while (j < 11) dirvn[j++] =
' ';
5127 #if _USE_EXPAND && !_FS_READONLY 5141 DWORD n, clst, stcl, scl, ncl, tcl, lclst;
5151 tcl = (
DWORD)(fsz / n) + ((fsz & (n - 1)) ? 1 : 0);
5153 if (stcl < 2 || stcl >= fs->
n_fatent) stcl = 2;
5157 scl = find_bitmap(fs, stcl, tcl);
5162 res = change_bitmap(fs, scl, tcl, 1);
5163 lclst = scl + tcl - 1;
5171 scl = clst = stcl; ncl = 0;
5174 if (++clst >= fs->
n_fatent) clst = 2;
5176 if (n == 0xFFFFFFFF) { res =
FR_DISK_ERR;
break; }
5178 if (++ncl == tcl)
break;
5180 scl = clst; ncl = 0;
5182 if (clst == stcl) { res =
FR_DENIED;
break; }
5186 for (clst = scl, n = tcl; n; clst++, n--) {
5187 res =
put_fat(fs, clst, (n == 1) ? 0xFFFFFFFF : clst + 1);
5188 if (res !=
FR_OK)
break;
5245 if (btf > remain) btf = (
UINT)remain;
5247 for ( ; btf && (*func)(0, 0);
5248 fp->
fptr += rcnt, *bf += rcnt, btf -= rcnt) {
5250 if (fp->
fptr %
SS(fs) == 0) {
5252 clst = (fp->
fptr == 0) ?
5266 if (fp->
sect != sect) {
5279 if (rcnt > btf) rcnt = btf;
5280 rcnt = (*func)(dbuf + ((
UINT)fp->
fptr %
SS(fs)), rcnt);
5290 #if _USE_MKFS && !_FS_READONLY 5304 const UINT n_fats = 1;
5305 const UINT n_rootdir = 512;
5306 static const WORD cst[] = {1, 4, 16, 64, 256, 512, 0};
5307 static const WORD cst32[] = {1, 2, 4, 8, 16, 32, 0};
5308 BYTE fmt, sys, *buf, *pte, pdrv, part;
5310 DWORD szb_buf, sz_buf, sz_blk, n_clst, pau, sect, nsect, n;
5311 DWORD b_vol, b_fat, b_data;
5312 DWORD sz_vol, sz_rsv, sz_fat, sz_dir;
5316 #if _USE_TRIM || _FS_EXFAT 5324 if (FatFs[vol]) FatFs[vol]->
fs_type = 0;
5333 #if _MAX_SS != _MIN_SS 5345 szb_buf = sz_buf * ss;
5360 b_vol = (opt &
FM_SFD) ? 0 : 63;
5369 if ((opt &
FM_ANY) == FM_EXFAT || sz_vol >= 0x4000000 || au > 128) {
5385 DWORD szb_bit, szb_case,
sum, nb, cl;
5392 tbl[0] = b_vol; tbl[1] = b_vol + sz_vol - 1;
5398 if (sz_vol >= 0x80000) au = 64;
5399 if (sz_vol >= 0x4000000) au = 256;
5402 sz_fat = ((sz_vol / au + 2) * 4 + ss - 1) / ss;
5403 b_data = (b_fat + sz_fat + sz_blk - 1) & ~(sz_blk - 1);
5405 n_clst = (sz_vol - (b_data - b_vol)) / au;
5409 szb_bit = (n_clst + 7) / 8;
5410 tbl[0] = (szb_bit + au * ss - 1) / (au * ss);
5413 sect = b_data + au * tbl[0];
5415 st = si = i = j = szb_case = 0;
5425 ch = 0xFFFF; st = 2;
break;
5431 if (--j == 0) st = 0;
5434 ch = (
WCHAR)j; si += j;
5437 sum = xsum32(buf[i + 0] = (
BYTE)ch, sum);
5438 sum = xsum32(buf[i + 1] = (
BYTE)(ch >> 8), sum);
5439 i += 2; szb_case += 2;
5440 if (!si || i == szb_buf) {
5441 n = (i + ss - 1) / ss;
5446 tbl[1] = (szb_case + au * ss - 1) / (au * ss);
5450 sect = b_data; nsect = (szb_bit + ss - 1) / ss;
5451 nb = tbl[0] + tbl[1] + tbl[2];
5454 for (i = 0; nb >= 8 && i < szb_buf; buf[i++] = 0xFF, nb -= 8) ;
5455 for (b = 1; nb && i < szb_buf; buf[i] |= b, b <<= 1, nb--) ;
5456 n = (nsect > sz_buf) ? sz_buf : nsect;
5458 sect += n; nsect -= n;
5462 sect = b_fat; nsect = sz_fat;
5465 mem_set(buf, 0, szb_buf); i = 0;
5467 st_dword(buf + i, 0xFFFFFFF8); i += 4; cl++;
5468 st_dword(buf + i, 0xFFFFFFFF); i += 4; cl++;
5471 while (nb && i < szb_buf) {
5472 st_dword(buf + i, (nb > 1) ? cl + 1 : 0xFFFFFFFF);
5475 if (!nb && j < 3) nb = tbl[j++];
5476 }
while (nb && i < szb_buf);
5477 n = (nsect > sz_buf) ? sz_buf : nsect;
5479 sect += n; nsect -= n;
5484 buf[
SZDIRE * 0 + 0] = 0x83;
5485 buf[
SZDIRE * 1 + 0] = 0x81;
5488 buf[
SZDIRE * 2 + 0] = 0x82;
5492 sect = b_data + au * (tbl[0] + tbl[1]); nsect = au;
5494 n = (nsect > sz_buf) ? sz_buf : nsect;
5497 sect += n; nsect -= n;
5502 for (n = 0; n < 2; n++) {
5521 for (i = sum = 0; i < ss; i++) {
5527 st_word(buf + ss - 2, 0xAA55);
5528 for (j = 1; j < 9; j++) {
5529 for (i = 0; i < ss; sum = xsum32(buf[i++], sum)) ;
5534 for ( ; j < 11; j++) {
5535 for (i = 0; i < ss; sum = xsum32(buf[i++], sum)) ;
5539 for (i = 0; i < ss; i += 4)
st_dword(buf + i, sum);
5551 n = sz_vol / 0x20000;
5552 for (i = 0, pau = 1; cst32[i] && cst32[i] <= n; i++, pau <<= 1) ;
5554 n_clst = sz_vol / pau;
5555 sz_fat = (n_clst * 4 + 8 + ss - 1) / ss;
5561 n = sz_vol / 0x1000;
5562 for (i = 0, pau = 1; cst[i] && cst[i] <= n; i++, pau <<= 1) ;
5564 n_clst = sz_vol / pau;
5569 n = (n_clst * 3 + 1) / 2 + 3;
5571 sz_fat = (n + ss - 1) / ss;
5575 b_fat = b_vol + sz_rsv;
5576 b_data = b_fat + sz_fat * n_fats + sz_dir;
5579 n = ((b_data + sz_blk - 1) & ~(sz_blk - 1)) - b_data;
5581 sz_rsv += n; b_fat += n;
5583 sz_fat += n / n_fats;
5588 n_clst = (sz_vol - sz_rsv - sz_fat * n_fats - sz_dir) / pau;
5591 if (!au && (au = pau / 2) != 0)
continue;
5597 if (!au && (pau * 2) <= 64) {
5598 au = pau * 2;
continue;
5603 if (!au && (au = pau * 2) <= 128)
continue;
5607 if (!au && (au = pau * 2) <= 128)
continue;
5618 tbl[0] = b_vol; tbl[1] = b_vol + sz_vol - 1;
5629 if (sz_vol < 0x10000) {
5673 for (i = 0; i < n_fats; i++) {
5683 n = (nsect > sz_buf) ? sz_buf : nsect;
5686 sect += n; nsect -= n;
5691 nsect = (fmt ==
FS_FAT32) ? pau : sz_dir;
5693 n = (nsect > sz_buf) ? sz_buf : nsect;
5695 sect += n; nsect -= n;
5706 if (sz_vol >= 0x10000) {
5709 sys = (fmt ==
FS_FAT16) ? 0x04 : 0x01;
5730 n = (b_vol + sz_vol) / (63 * 255);
5747 #if _MULTI_PARTITION 5759 UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl;
5760 BYTE s_hd, e_hd, *p, *buf = (
BYTE*)work;
5762 DWORD sz_disk, sz_part, s_part;
5771 for (n = 16; n < 256 && sz_disk / n / 63 > 1024; n *= 2) ;
5775 tot_cyl = sz_disk / sz_cyl;
5780 for (i = 0; i < 4; i++, p +=
SZ_PTE) {
5781 p_cyl = (szt[i] <= 100U) ? (
DWORD)tot_cyl * szt[i] / 100 : szt[i] / sz_cyl;
5782 if (!p_cyl)
continue;
5783 s_part = (
DWORD)sz_cyl * b_cyl;
5784 sz_part = (
DWORD)sz_cyl * p_cyl;
5787 s_part += 63; sz_part -= 63;
5791 e_cyl = b_cyl + p_cyl - 1;
5796 p[2] = (
BYTE)((b_cyl >> 2) + 1);
5800 p[6] = (
BYTE)((e_cyl >> 2) + 63);
5838 while (n < len - 1) {
5840 #if _STRF_ENCODE == 3 5845 if (c < 0xC0)
continue;
5849 c = (c & 0x1F) << 6 | (s[0] & 0x3F);
5850 if (c < 0x80) c =
'?';
5855 c = c << 12 | (s[0] & 0x3F) << 6 | (s[1] & 0x3F);
5856 if (c < 0x800) c =
'?';
5862 #elif _STRF_ENCODE == 2 5865 c = s[1] + (s[0] << 8);
5866 #elif _STRF_ENCODE == 1 5869 c = s[0] + (s[1] << 8);
5877 c = (c << 8) + s[0];
5890 if (c ==
'\n')
break;
5893 return n ? buff : 0;
5931 #if _STRF_ENCODE == 3 5936 pb->
buf[i++] = (
BYTE)(0xC0 | c >> 6);
5938 pb->
buf[i++] = (
BYTE)(0xE0 | c >> 12);
5939 pb->
buf[i++] = (
BYTE)(0x80 | (c >> 6 & 0x3F));
5941 pb->
buf[i++] = (
BYTE)(0x80 | (c & 0x3F));
5943 #elif _STRF_ENCODE == 2 5944 pb->
buf[i++] = (
BYTE)(c >> 8);
5946 #elif _STRF_ENCODE == 1 5948 pb->
buf[i++] = (
BYTE)(c >> 8);
5953 pb->
buf[i++] = (
BYTE)(c >> 8);
5960 if (i >= (
int)(
sizeof pb->
buf) - 3) {
5962 i = (bw == (
UINT)i) ? 0 : -1;
6028 while (*str)
putc_bfd(&pb, *str++);
6051 TCHAR c, d, str[32], *p;
6075 w = w * 10 + c -
'0';
6078 if (c ==
'l' || c ==
'L') {
6086 p = va_arg(arp,
TCHAR*);
6087 for (j = 0; p[j]; j++) ;
6089 while (j++ < w)
putc_bfd(&pb,
' ');
6092 while (j++ < w)
putc_bfd(&pb,
' ');
6110 v = (f & 4) ? (
DWORD)va_arg(arp,
long) : ((d ==
'D') ? (
DWORD)(long)va_arg(arp,
int) : (
DWORD)va_arg(arp,
unsigned int));
6111 if (d ==
'D' && (v & 0x80000000)) {
6117 d = (
TCHAR)(v % r); v /= r;
6118 if (d > 9) d += (c ==
'x') ? 0x27 : 0x07;
6120 }
while (v && i <
sizeof str /
sizeof str[0]);
6121 if (f & 8) str[i++] =
'-';
6122 j = i; d = (f & 1) ?
'0' :
' ';
6123 while (!(f & 2) && j++ < w)
putc_bfd(&pb, d);
6124 do putc_bfd(&pb, str[--i]);
while (i);
MEMSPACE FRESULT f_findnext(DIR *dp, FILINFO *fno)
FRESULT f_chdrive(const TCHAR *path)
static MEMSPACE WCHAR get_achar(const TCHAR **ptr)
MEMSPACE FRESULT f_closedir(DIR *dp)
static MEMSPACE void mem_set(void *dst, int val, UINT cnt)
static MEMSPACE FRESULT dir_remove(DIR *dp)
dst_t dst
DST start and stop in GMT epoch.
static MEMSPACE DWORD create_chain(_FDID *obj, DWORD clst)
MEMSPACE int f_puts(const TCHAR *str, FIL *fp)
MEMSPACE FRESULT f_write(FIL *fp, const void *buff, UINT btw, UINT *bw)
Master include file for project Includes all project includes and defines here.
static FATFS * FatFs[_VOLUMES]
static MEMSPACE FRESULT dir_sdi(DIR *dp, DWORD ofs)
MEMSPACE FRESULT f_chmod(const TCHAR *path, BYTE attr, BYTE mask)
FRESULT f_fdisk(BYTE pdrv, const DWORD *szt, void *work)
static MEMSPACE FRESULT dir_read(DIR *dp, int vol)
static MEMSPACE int cmp_lfn(const WCHAR *lfnbuf, BYTE *dir)
MEMSPACE TCHAR * f_gets(TCHAR *buff, int len, FIL *fp)
MEMSPACE FRESULT f_readdir(DIR *dp, FILINFO *fno)
MEMSPACE FRESULT f_rename(const TCHAR *path_old, const TCHAR *path_new)
#define XDIR_ValidFileSize
static DWORD ld_dword(const BYTE *ptr)
static MEMSPACE void mem_cpy(void *dst, const void *src, UINT cnt)
MEMSPACE FRESULT f_getfree(const TCHAR *path, DWORD *nclst, FATFS **fatfs)
#define LEAVE_FF(fs, res)
static MEMSPACE DWORD get_fat(_FDID *obj, DWORD clst)
static MEMSPACE int putc_flush(putbuff *pb)
static MEMSPACE DWORD clmt_clust(FIL *fp, FSIZE_t ofs)
MEMSPACE FRESULT f_read(FIL *fp, void *buff, UINT btr, UINT *br)
MEMSPACE FRESULT f_close(FIL *fp)
WCHAR ff_wtoupper(WCHAR chr)
MEMSPACE FRESULT f_open(FIL *fp, const TCHAR *path, BYTE mode)
static void st_word(BYTE *ptr, WORD val)
static MEMSPACE FRESULT sync_fs(FATFS *fs)
WCHAR ff_convert(WCHAR chr, UINT dir)
MEMSPACE int f_printf(FIL *fp, const TCHAR *fmt,...)
MEMSPACE FRESULT f_opendir(DIR *dp, const TCHAR *path)
MEMSPACE FRESULT f_mkdir(const TCHAR *path)
#define EOF
End of file or device read.
DRESULT disk_write(BYTE pdrv, const BYTE *buff, DWORD sector, UINT count)
MEMSPACE FRESULT f_findfirst(DIR *dp, FILINFO *fno, const TCHAR *path, const TCHAR *pattern)
MEMSPACE FRESULT f_lseek(FIL *fp, FSIZE_t ofs)
static MEMSPACE BYTE check_fs(FATFS *fs, DWORD sect)
MEMSPACE uint16_t sum(char *name)
sum of a file with 16bit hex and integer results
static MEMSPACE int chk_chr(const char *str, int chr)
FRESULT f_forward(FIL *fp, UINT(*func)(const BYTE *, UINT), UINT btf, UINT *bf)
static MEMSPACE FRESULT put_fat(FATFS *fs, DWORD clst, DWORD val)
DSTATUS disk_status(BYTE pdrv)
static MEMSPACE void put_lfn(const WCHAR *lfn, BYTE *dir, BYTE ord, BYTE sum)
static MEMSPACE BYTE sum_sfn(const BYTE *dir)
DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void *buff)
MEMSPACE FRESULT f_setlabel(const TCHAR *label)
static MEMSPACE void get_fileinfo(DIR *dp, FILINFO *fno)
static MEMSPACE FRESULT find_volume(const TCHAR **path, FATFS **rfs, BYTE mode)
static const BYTE LfnOfs[]
static MEMSPACE void st_clust(FATFS *fs, BYTE *dir, DWORD cl)
static MEMSPACE FRESULT create_name(DIR *dp, const TCHAR **path)
static MEMSPACE FRESULT dir_find(DIR *dp)
static MEMSPACE FRESULT move_window(FATFS *fs, DWORD sector)
static MEMSPACE FRESULT remove_chain(_FDID *obj, DWORD clst, DWORD pclst)
static MEMSPACE FRESULT sync_window(FATFS *fs)
DSTATUS disk_initialize(BYTE pdrv)
static MEMSPACE DWORD clust2sect(FATFS *fs, DWORD clst)
static MEMSPACE void gen_numname(BYTE *dst, const BYTE *src, const WCHAR *lfn, UINT seq)
MEMSPACE FRESULT f_unlink(const TCHAR *path)
static MEMSPACE void putc_bfd(putbuff *pb, TCHAR c)
static MEMSPACE FRESULT dir_alloc(DIR *dp, UINT nent)
static MEMSPACE FRESULT validate(_FDID *obj, FATFS **fs)
static MEMSPACE int pattern_matching(const TCHAR *pat, const TCHAR *nam, int skip, int inf)
MEMSPACE FRESULT f_stat(const TCHAR *path, FILINFO *fno)
MEMSPACE FRESULT f_expand(FIL *fp, FSIZE_t fsz, BYTE opt)
MEMSPACE FRESULT f_getcwd(TCHAR *buff, UINT len)
static MEMSPACE FRESULT dir_register(DIR *dp)
static const BYTE ExCvt[]
static MEMSPACE FRESULT follow_path(DIR *dp, const TCHAR *path)
MEMSPACE int stat(char *name, struct stat *buf)
POSIX stat - get file status of named file.
static MEMSPACE FRESULT dir_next(DIR *dp, int stretch)
MEMSPACE FRESULT f_sync(FIL *fp)
static WORD ld_word(const BYTE *ptr)
MEMSPACE FRESULT f_chdir(const TCHAR *path)
static MEMSPACE DWORD ld_clust(FATFS *fs, const BYTE *dir)
MEMSPACE int f_putc(TCHAR c, FIL *fp)
MEMSPACE FRESULT f_truncate(FIL *fp)
static void st_dword(BYTE *ptr, DWORD val)
static MEMSPACE int pick_lfn(WCHAR *lfnbuf, BYTE *dir)
MEMSPACE FRESULT f_mount(FATFS *fs, const TCHAR *path, BYTE opt)
static MEMSPACE void putc_init(putbuff *pb, FIL *fp)
static MEMSPACE int mem_cmp(const void *dst, const void *src, UINT cnt)
MEMSPACE FRESULT f_utime(const TCHAR *path, const FILINFO *fno)
static MEMSPACE int get_ldnumber(const TCHAR **path)
DRESULT disk_read(BYTE pdrv, BYTE *buff, DWORD sector, UINT count)
MEMSPACE FRESULT f_mkfs(const TCHAR *path, BYTE opt, DWORD au, void *work, UINT len)
MEMSPACE FRESULT f_getlabel(const TCHAR *path, TCHAR *label, DWORD *vsn)