The FATFS structure (filesystem object) holds dynamic work area of individual logical drives. It is given by application program and registerd/unregisterd to the FatFs module with f_mount function. Initialization of the structure is done by volume mount process whenever necessary. Application program must not modify any member in this structure, or the FAT volume will be collapsed.
typedef struct { BYTE fs_type; /* FAT type (0, FS_FAT12, FS_FAT16, FS_FAT32 or FS_EXFAT) */ BYTE pdrv; /* Physical drive that holds this volume */ BYTE ldrv; /* Logical drive number (used only when FF_FS_REENTRANT) */ BYTE n_fats; /* Number of FAT copies (1,2) */ BYTE wflag; /* win[] flag (b0:win[] is dirty) */ BYTE fsi_flag; /* FSINFO flags (b7:Disabled, b0:Dirty) */ WORD id; /* Volume mount ID */ WORD n_rootdir; /* Number of root directory entries (FAT12/16) */ WORD csize; /* Sectors per cluster */ #if FF_MAX_SS != FF_MIN_SS WORD ssize; /* Sector size (512,1024,2048 or 4096) */ #endif #if FF_USE_LFN WCHAR* lfnbuf; /* Pointer to LFN working buffer */ #endif #if !FF_FS_READONLY DWORD last_clust; /* FSINFO: Last allocated cluster (invalid if >=n_fatent) */ DWORD free_clust; /* FSINFO: Number of free clusters (invalid if >=fs->n_fatent-2) */ #endif #if FF_FS_RPATH DWORD cdir; /* Cluster number of current directory (0:root) */ #endif DWORD n_fatent; /* Number of FAT entries (Number of clusters + 2) */ DWORD fsize; /* Sectors per FAT */ LBA_t winsect; /* Sector LBA appearing in the win[] */ LBA_t volbase; /* Volume base LBA */ LBA_t fatbase; /* FAT base LBA */ LBA_t dirbase; /* Root directory base (LBA|Cluster) */ LBA_t database; /* Data base LBA */ #if FF_FS_EXFAT LBA_t bitbase; /* Allocation bitmap base sector */ BYTE* dirbuf; /* Directory entry block scratchpad buffer */ #if FF_FS_RPATH FFXCWDS xcwds; /* Current working directory structure */ FFXCWDS xcwds2; /* Working buffer to follow the path */ #endif #endif BYTE win[FF_MAX_SS]; /* Disk access window for directory, FAT (and file data at tiny cfg) */ } FATFS;