|
#define | MAX_DIR 0x200000 /* Max size of FAT directory */ |
|
#define | MAX_DIR_EX 0x10000000 /* Max size of exFAT directory */ |
|
#define | MAX_FAT12 0xFF5 /* Max FAT12 clusters (differs from specs, but right for real DOS/Windows behavior) */ |
|
#define | MAX_FAT16 0xFFF5 /* Max FAT16 clusters (differs from specs, but right for real DOS/Windows behavior) */ |
|
#define | MAX_FAT32 0x0FFFFFF5 /* Max FAT32 clusters (not specified, practical limit) */ |
|
#define | MAX_EXFAT 0x7FFFFFFD /* Max exFAT clusters (differs from specs, implementation limit) */ |
|
#define | IsUpper(c) ((c) >= 'A' && (c) <= 'Z') |
|
#define | IsLower(c) ((c) >= 'a' && (c) <= 'z') |
|
#define | IsDigit(c) ((c) >= '0' && (c) <= '9') |
|
#define | IsSeparator(c) ((c) == '/' || (c) == '\\') |
|
#define | IsTerminator(c) ((UINT)(c) < (FF_USE_LFN ? ' ' : '!')) |
|
#define | IsSurrogate(c) ((c) >= 0xD800 && (c) <= 0xDFFF) |
|
#define | IsSurrogateH(c) ((c) >= 0xD800 && (c) <= 0xDBFF) |
|
#define | IsSurrogateL(c) ((c) >= 0xDC00 && (c) <= 0xDFFF) |
|
#define | FA_SEEKEND 0x20 /* Seek to end of the file on file open */ |
|
#define | FA_MODIFIED 0x40 /* File has been modified */ |
|
#define | FA_DIRTY 0x80 /* FIL.buf[] needs to be written-back */ |
|
#define | AM_VOL 0x08 /* Volume label */ |
|
#define | AM_LFN 0x0F /* LFN entry */ |
|
#define | AM_MASK 0x3F /* Mask of defined bits in FAT */ |
|
#define | AM_MASKX 0x37 /* Mask of defined bits in exFAT */ |
|
#define | NSFLAG 11 /* Index of the name status byte */ |
|
#define | NS_LOSS 0x01 /* Out of 8.3 format */ |
|
#define | NS_LFN 0x02 /* Force to create LFN entry */ |
|
#define | NS_LAST 0x04 /* Last segment */ |
|
#define | NS_BODY 0x08 /* Lower case flag (body) */ |
|
#define | NS_EXT 0x10 /* Lower case flag (ext) */ |
|
#define | NS_DOT 0x20 /* Dot entry */ |
|
#define | NS_NOLFN 0x40 /* Do not find LFN */ |
|
#define | NS_NONAME 0x80 /* Not followed */ |
|
#define | ET_BITMAP 0x81 /* Allocation bitmap */ |
|
#define | ET_UPCASE 0x82 /* Up-case table */ |
|
#define | ET_VLABEL 0x83 /* Volume label */ |
|
#define | ET_FILEDIR 0x85 /* File and directory */ |
|
#define | ET_STREAM 0xC0 /* Stream extension */ |
|
#define | ET_FILENAME 0xC1 /* Name extension */ |
|
#define | BS_JmpBoot 0 /* x86 jump instruction (3-byte) */ |
|
#define | BS_OEMName 3 /* OEM name (8-byte) */ |
|
#define | BPB_BytsPerSec 11 /* Sector size [byte] (WORD) */ |
|
#define | BPB_SecPerClus 13 /* Cluster size [sector] (BYTE) */ |
|
#define | BPB_RsvdSecCnt 14 /* Size of reserved area [sector] (WORD) */ |
|
#define | BPB_NumFATs 16 /* Number of FATs (BYTE) */ |
|
#define | BPB_RootEntCnt 17 /* Size of root directory area for FAT [entry] (WORD) */ |
|
#define | BPB_TotSec16 19 /* Volume size (16-bit) [sector] (WORD) */ |
|
#define | BPB_Media 21 /* Media descriptor byte (BYTE) */ |
|
#define | BPB_FATSz16 22 /* FAT size (16-bit) [sector] (WORD) */ |
|
#define | BPB_SecPerTrk 24 /* Number of sectors per track for int13h [sector] (WORD) */ |
|
#define | BPB_NumHeads 26 /* Number of heads for int13h (WORD) */ |
|
#define | BPB_HiddSec 28 /* Volume offset from top of the drive (DWORD) */ |
|
#define | BPB_TotSec32 32 /* Volume size (32-bit) [sector] (DWORD) */ |
|
#define | BS_DrvNum 36 /* Physical drive number for int13h (BYTE) */ |
|
#define | BS_NTres 37 /* WindowsNT error flag (BYTE) */ |
|
#define | BS_BootSig 38 /* Extended boot signature (BYTE) */ |
|
#define | BS_VolID 39 /* Volume serial number (DWORD) */ |
|
#define | BS_VolLab 43 /* Volume label string (8-byte) */ |
|
#define | BS_FilSysType 54 /* Filesystem type string (8-byte) */ |
|
#define | BS_BootCode 62 /* Boot code (448-byte) */ |
|
#define | BS_55AA 510 /* Signature word (WORD) */ |
|
#define | BPB_FATSz32 36 /* FAT32: FAT size [sector] (DWORD) */ |
|
#define | BPB_ExtFlags32 40 /* FAT32: Extended flags (WORD) */ |
|
#define | BPB_FSVer32 42 /* FAT32: Filesystem version (WORD) */ |
|
#define | BPB_RootClus32 44 /* FAT32: Root directory cluster (DWORD) */ |
|
#define | BPB_FSInfo32 48 /* FAT32: Offset of FSINFO sector (WORD) */ |
|
#define | BPB_BkBootSec32 50 /* FAT32: Offset of backup boot sector (WORD) */ |
|
#define | BS_DrvNum32 64 /* FAT32: Physical drive number for int13h (BYTE) */ |
|
#define | BS_NTres32 65 /* FAT32: Error flag (BYTE) */ |
|
#define | BS_BootSig32 66 /* FAT32: Extended boot signature (BYTE) */ |
|
#define | BS_VolID32 67 /* FAT32: Volume serial number (DWORD) */ |
|
#define | BS_VolLab32 71 /* FAT32: Volume label string (8-byte) */ |
|
#define | BS_FilSysType32 82 /* FAT32: Filesystem type string (8-byte) */ |
|
#define | BS_BootCode32 90 /* FAT32: Boot code (420-byte) */ |
|
#define | BPB_ZeroedEx 11 /* exFAT: MBZ field (53-byte) */ |
|
#define | BPB_VolOfsEx 64 /* exFAT: Volume offset from top of the drive [sector] (QWORD) */ |
|
#define | BPB_TotSecEx 72 /* exFAT: Volume size [sector] (QWORD) */ |
|
#define | BPB_FatOfsEx 80 /* exFAT: FAT offset from top of the volume [sector] (DWORD) */ |
|
#define | BPB_FatSzEx 84 /* exFAT: FAT size [sector] (DWORD) */ |
|
#define | BPB_DataOfsEx 88 /* exFAT: Data offset from top of the volume [sector] (DWORD) */ |
|
#define | BPB_NumClusEx 92 /* exFAT: Number of clusters (DWORD) */ |
|
#define | BPB_RootClusEx 96 /* exFAT: Root directory start cluster (DWORD) */ |
|
#define | BPB_VolIDEx 100 /* exFAT: Volume serial number (DWORD) */ |
|
#define | BPB_FSVerEx 104 /* exFAT: Filesystem version (WORD) */ |
|
#define | BPB_VolFlagEx 106 /* exFAT: Volume flags (WORD) */ |
|
#define | BPB_BytsPerSecEx 108 /* exFAT: Log2 of sector size in unit of byte (BYTE) */ |
|
#define | BPB_SecPerClusEx 109 /* exFAT: Log2 of cluster size in unit of sector (BYTE) */ |
|
#define | BPB_NumFATsEx 110 /* exFAT: Number of FATs (BYTE) */ |
|
#define | BPB_DrvNumEx 111 /* exFAT: Physical drive number for int13h (BYTE) */ |
|
#define | BPB_PercInUseEx 112 /* exFAT: Percent in use (BYTE) */ |
|
#define | BPB_RsvdEx 113 /* exFAT: Reserved (7-byte) */ |
|
#define | BS_BootCodeEx 120 /* exFAT: Boot code (390-byte) */ |
|
#define | DIR_Name 0 /* Short file name (11-byte) */ |
|
#define | DIR_Attr 11 /* Attribute (BYTE) */ |
|
#define | DIR_NTres 12 /* Lower case flag (BYTE) */ |
|
#define | DIR_CrtTime10 13 /* Created time sub-second (BYTE) */ |
|
#define | DIR_CrtTime 14 /* Created time (DWORD) */ |
|
#define | DIR_LstAccDate 18 /* Last accessed date (WORD) */ |
|
#define | DIR_FstClusHI 20 /* Higher 16-bit of first cluster (WORD) */ |
|
#define | DIR_ModTime 22 /* Modified time (DWORD) */ |
|
#define | DIR_FstClusLO 26 /* Lower 16-bit of first cluster (WORD) */ |
|
#define | DIR_FileSize 28 /* File size (DWORD) */ |
|
#define | LDIR_Ord 0 /* LFN: LFN order and LLE flag (BYTE) */ |
|
#define | LDIR_Attr 11 /* LFN: LFN attribute (BYTE) */ |
|
#define | LDIR_Type 12 /* LFN: Entry type (BYTE) */ |
|
#define | LDIR_Chksum 13 /* LFN: Checksum of the SFN (BYTE) */ |
|
#define | LDIR_FstClusLO 26 /* LFN: MBZ field (WORD) */ |
|
#define | XDIR_Type 0 /* exFAT: Type of exFAT directory entry (BYTE) */ |
|
#define | XDIR_NumLabel 1 /* exFAT: Number of volume label characters (BYTE) */ |
|
#define | XDIR_Label 2 /* exFAT: Volume label (11-WORD) */ |
|
#define | XDIR_CaseSum 4 /* exFAT: Sum of case conversion table (DWORD) */ |
|
#define | XDIR_NumSec 1 /* exFAT: Number of secondary entries (BYTE) */ |
|
#define | XDIR_SetSum 2 /* exFAT: Sum of the set of directory entries (WORD) */ |
|
#define | XDIR_Attr 4 /* exFAT: File attribute (WORD) */ |
|
#define | XDIR_CrtTime 8 /* exFAT: Created time (DWORD) */ |
|
#define | XDIR_ModTime 12 /* exFAT: Modified time (DWORD) */ |
|
#define | XDIR_AccTime 16 /* exFAT: Last accessed time (DWORD) */ |
|
#define | XDIR_CrtTime10 20 /* exFAT: Created time subsecond (BYTE) */ |
|
#define | XDIR_ModTime10 21 /* exFAT: Modified time subsecond (BYTE) */ |
|
#define | XDIR_CrtTZ 22 /* exFAT: Created timezone (BYTE) */ |
|
#define | XDIR_ModTZ 23 /* exFAT: Modified timezone (BYTE) */ |
|
#define | XDIR_AccTZ 24 /* exFAT: Last accessed timezone (BYTE) */ |
|
#define | XDIR_GenFlags 33 /* exFAT: General secondary flags (BYTE) */ |
|
#define | XDIR_NumName 35 /* exFAT: Number of file name characters (BYTE) */ |
|
#define | XDIR_NameHash 36 /* exFAT: Hash of file name (WORD) */ |
|
#define | XDIR_ValidFileSize 40 /* exFAT: Valid file size (QWORD) */ |
|
#define | XDIR_FstClus 52 /* exFAT: First cluster of the file data (DWORD) */ |
|
#define | XDIR_FileSize 56 /* exFAT: File/Directory size (QWORD) */ |
|
#define | SZDIRE 32 /* Size of a directory entry */ |
|
#define | DDEM 0xE5 /* Deleted directory entry mark set to DIR_Name[0] */ |
|
#define | RDDEM 0x05 /* Replacement of the character collides with DDEM */ |
|
#define | LLEF 0x40 /* Last long entry flag in LDIR_Ord */ |
|
#define | FSI_LeadSig 0 /* FAT32 FSI: Leading signature (DWORD) */ |
|
#define | FSI_StrucSig 484 /* FAT32 FSI: Structure signature (DWORD) */ |
|
#define | FSI_Free_Count 488 /* FAT32 FSI: Number of free clusters (DWORD) */ |
|
#define | FSI_Nxt_Free 492 /* FAT32 FSI: Last allocated cluster (DWORD) */ |
|
#define | MBR_Table 446 /* MBR: Offset of partition table in the MBR */ |
|
#define | SZ_PTE 16 /* MBR: Size of a partition table entry */ |
|
#define | PTE_Boot 0 /* MBR PTE: Boot indicator */ |
|
#define | PTE_StHead 1 /* MBR PTE: Start head */ |
|
#define | PTE_StSec 2 /* MBR PTE: Start sector */ |
|
#define | PTE_StCyl 3 /* MBR PTE: Start cylinder */ |
|
#define | PTE_System 4 /* MBR PTE: System ID */ |
|
#define | PTE_EdHead 5 /* MBR PTE: End head */ |
|
#define | PTE_EdSec 6 /* MBR PTE: End sector */ |
|
#define | PTE_EdCyl 7 /* MBR PTE: End cylinder */ |
|
#define | PTE_StLba 8 /* MBR PTE: Start in LBA */ |
|
#define | PTE_SizLba 12 /* MBR PTE: Size in LBA */ |
|
#define | GPTH_Sign 0 /* GPT: Header signature (8-byte) */ |
|
#define | GPTH_Rev 8 /* GPT: Revision (DWORD) */ |
|
#define | GPTH_Size 12 /* GPT: Header size (DWORD) */ |
|
#define | GPTH_Bcc 16 /* GPT: Header BCC (DWORD) */ |
|
#define | GPTH_CurLba 24 /* GPT: Main header LBA (QWORD) */ |
|
#define | GPTH_BakLba 32 /* GPT: Backup header LBA (QWORD) */ |
|
#define | GPTH_FstLba 40 /* GPT: First LBA for partitions (QWORD) */ |
|
#define | GPTH_LstLba 48 /* GPT: Last LBA for partitions (QWORD) */ |
|
#define | GPTH_DskGuid 56 /* GPT: Disk GUID (16-byte) */ |
|
#define | GPTH_PtOfs 72 /* GPT: Partation table LBA (QWORD) */ |
|
#define | GPTH_PtNum 80 /* GPT: Number of table entries (DWORD) */ |
|
#define | GPTH_PteSize 84 /* GPT: Size of table entry (DWORD) */ |
|
#define | GPTH_PtBcc 88 /* GPT: Partation table BCC (DWORD) */ |
|
#define | SZ_GPTE 128 /* GPT: Size of partition table entry */ |
|
#define | GPTE_PtGuid 0 /* GPT PTE: Partition type GUID (16-byte) */ |
|
#define | GPTE_UpGuid 16 /* GPT PTE: Partition unique GUID (16-byte) */ |
|
#define | GPTE_FstLba 32 /* GPT PTE: First LBA (QWORD) */ |
|
#define | GPTE_LstLba 40 /* GPT PTE: Last LBA inclusive (QWORD) */ |
|
#define | GPTE_Flags 48 /* GPT PTE: Flags (QWORD) */ |
|
#define | GPTE_Name 56 /* GPT PTE: Name */ |
|
#define | ABORT(fs, res) { fp->err = (BYTE)(res); LEAVE_FF(fs, res); } |
|
#define | LEAVE_FF(fs, res) return res |
|
#define | LD2PD(vol) (BYTE)(vol) /* Each logical drive is associated with the same physical drive number */ |
|
#define | LD2PT(vol) 0 /* Auto partition search */ |
|
#define | SS(fs) ((UINT)FF_MAX_SS) /* Fixed sector size */ |
|
#define | GET_FATTIME() ((DWORD)(FF_NORTC_YEAR - 1980) << 25 | (DWORD)FF_NORTC_MON << 21 | (DWORD)FF_NORTC_MDAY << 16) |
|
#define | TBL_CT437 |
|
#define | TBL_CT720 |
|
#define | TBL_CT737 |
|
#define | TBL_CT771 |
|
#define | TBL_CT775 |
|
#define | TBL_CT850 |
|
#define | TBL_CT852 |
|
#define | TBL_CT855 |
|
#define | TBL_CT857 |
|
#define | TBL_CT860 |
|
#define | TBL_CT861 |
|
#define | TBL_CT862 |
|
#define | TBL_CT863 |
|
#define | TBL_CT864 |
|
#define | TBL_CT865 |
|
#define | TBL_CT866 |
|
#define | TBL_CT869 |
|
#define | TBL_DC932 {0x81, 0x9F, 0xE0, 0xFC, 0x40, 0x7E, 0x80, 0xFC, 0x00, 0x00} |
|
#define | TBL_DC936 {0x81, 0xFE, 0x00, 0x00, 0x40, 0x7E, 0x80, 0xFE, 0x00, 0x00} |
|
#define | TBL_DC949 {0x81, 0xFE, 0x00, 0x00, 0x41, 0x5A, 0x61, 0x7A, 0x81, 0xFE} |
|
#define | TBL_DC950 {0x81, 0xFE, 0x00, 0x00, 0x40, 0x7E, 0xA1, 0xFE, 0x00, 0x00} |
|
#define | MERGE_2STR(a, b) a ## b |
|
#define | MKCVTBL(hd, cp) MERGE_2STR(hd, cp) |
|
#define | MAXDIRB(nc) ((nc + 44U) / 15 * SZDIRE) /* exFAT: Size of directory entry block scratchpad buffer needed for the name length */ |
|
#define | DEF_NAMBUF WCHAR *lfn; /* Pointer to LFN working buffer */ |
|
#define | INIT_NAMBUF(fs) { lfn = ff_memalloc((FF_MAX_LFN+1)*2); if (!lfn) LEAVE_FF(fs, FR_NOT_ENOUGH_CORE); (fs)->lfnbuf = lfn; } |
|
#define | FREE_NAMBUF() ff_memfree(lfn) |
|
#define | LEAVE_MKFS(res) { if (!work) ff_memfree(buf); return res; } |
|
#define | MAX_MALLOC 0x8000 /* Must be >=FF_MAX_SS */ |
|
#define | CODEPAGE FF_CODE_PAGE |
|
#define | DIR_READ_FILE(dp) dir_read(dp, 0) |
|
#define | DIR_READ_LABEL(dp) dir_read(dp, 1) |
|
#define | SZ_PUTC_BUF 64 |
|
#define | SZ_NUM_BUF 32 |
|
|
static WORD | ld_word (const BYTE *ptr) |
|
static DWORD | ld_dword (const BYTE *ptr) |
|
static void | st_word (BYTE *ptr, WORD val) |
|
static void | st_dword (BYTE *ptr, DWORD val) |
|
static int | dbc_1st (BYTE c) |
|
static int | dbc_2nd (BYTE c) |
|
static DWORD | tchar2uni (const TCHAR **str) |
|
static UINT | put_utf (DWORD chr, TCHAR *buf, UINT szb) |
|
static FRESULT | chk_lock (DIR *dp, int acc) |
|
static int | enq_lock (void) |
|
static UINT | inc_lock (DIR *dp, int acc) |
|
static FRESULT | dec_lock (UINT i) |
|
static void | clear_lock (FATFS *fs) |
|
static FRESULT | sync_window (FATFS *fs) |
|
static FRESULT | move_window (FATFS *fs, LBA_t sect) |
|
static FRESULT | sync_fs (FATFS *fs) |
|
static LBA_t | clst2sect (FATFS *fs, DWORD clst) |
|
static DWORD | get_fat (FFOBJID *obj, DWORD clst) |
|
static FRESULT | put_fat (FATFS *fs, DWORD clst, DWORD val) |
|
static FRESULT | remove_chain (FFOBJID *obj, DWORD clst, DWORD pclst) |
|
static DWORD | create_chain (FFOBJID *obj, DWORD clst) |
|
static FRESULT | dir_clear (FATFS *fs, DWORD clst) |
|
static FRESULT | dir_sdi (DIR *dp, DWORD ofs) |
|
static FRESULT | dir_next (DIR *dp, int stretch) |
|
static FRESULT | dir_alloc (DIR *dp, UINT n_ent) |
|
static DWORD | ld_clust (FATFS *fs, const BYTE *dir) |
|
static void | st_clust (FATFS *fs, BYTE *dir, DWORD cl) |
|
static int | cmp_lfn (const WCHAR *lfnbuf, BYTE *dir) |
|
static int | pick_lfn (WCHAR *lfnbuf, BYTE *dir) |
|
static void | put_lfn (const WCHAR *lfn, BYTE *dir, BYTE ord, BYTE sum) |
|
static void | gen_numname (BYTE *dst, const BYTE *src, const WCHAR *lfn, UINT seq) |
|
static BYTE | sum_sfn (const BYTE *dir) |
|
static FRESULT | dir_read (DIR *dp, int vol) |
|
static FRESULT | dir_find (DIR *dp) |
|
static FRESULT | dir_register (DIR *dp) |
|
static FRESULT | dir_remove (DIR *dp) |
|
static void | get_fileinfo (DIR *dp, FILINFO *fno) |
|
static FRESULT | create_name (DIR *dp, const TCHAR **path) |
|
static FRESULT | follow_path (DIR *dp, const TCHAR *path) |
|
static int | get_ldnumber (const TCHAR **path) |
|
static UINT | check_fs (FATFS *fs, LBA_t sect) |
|
static UINT | find_volume (FATFS *fs, UINT part) |
|
static FRESULT | mount_volume (const TCHAR **path, FATFS **rfs, BYTE mode) |
|
static FRESULT | validate (FFOBJID *obj, FATFS **rfs) |
|
FRESULT | f_mount (FATFS *fs, const TCHAR *path, BYTE opt) |
|
FRESULT | f_open (FIL *fp, const TCHAR *path, BYTE mode) |
|
FRESULT | f_read (FIL *fp, void *buff, UINT btr, UINT *br) |
|
FRESULT | f_write (FIL *fp, const void *buff, UINT btw, UINT *bw) |
|
FRESULT | f_sync (FIL *fp) |
|
FRESULT | f_close (FIL *fp) |
|
FRESULT | f_chdrive (const TCHAR *path) |
|
FRESULT | f_chdir (const TCHAR *path) |
|
FRESULT | f_lseek (FIL *fp, FSIZE_t ofs) |
|
FRESULT | f_opendir (DIR *dp, const TCHAR *path) |
|
FRESULT | f_closedir (DIR *dp) |
|
FRESULT | f_readdir (DIR *dp, FILINFO *fno) |
|
FRESULT | f_stat (const TCHAR *path, FILINFO *fno) |
|
FRESULT | f_getfree (const TCHAR *path, DWORD *nclst, FATFS **fatfs) |
|
FRESULT | f_truncate (FIL *fp) |
|
FRESULT | f_unlink (const TCHAR *path) |
|
FRESULT | f_mkdir (const TCHAR *path) |
|
FRESULT | f_rename (const TCHAR *path_old, const TCHAR *path_new) |
|
TCHAR * | f_gets (TCHAR *buff, int len, FIL *fp) |
|
static void | putc_bfd (putbuff *pb, TCHAR c) |
|
static int | putc_flush (putbuff *pb) |
|
static void | putc_init (putbuff *pb, FIL *fp) |
|
int | f_putc (TCHAR c, FIL *fp) |
|
int | f_puts (const TCHAR *str, FIL *fp) |
|
int | f_printf (FIL *fp, const TCHAR *fmt,...) |
|