FATFS

The FATFS structure (file system 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 is done on first file access after f_mount or media change. There is no member that can be changed from the application program.

typedef struct {
    BYTE    fs_type;      /* FAT sub-type (0:Not mounted) */
    BYTE    drv;          /* Physical drive number */
    BYTE    csize;        /* Sectors per cluster (1,2,4...128) */
    BYTE    n_fats;       /* Number of FAT copies (1,2) */
    BYTE    wflag;        /* win[] dirty flag */
    BYTE    fsi_flag;     /* fsinfo dirty flag */
    WORD    id;           /* File system mount ID */
    WORD    n_rootdir;    /* Number of root directory entries (FAT12/16) */
#if _MAX_SS != 512
    WORD    ssize;        /* Sector size (512,1024,2048 or 4096) */
#endif
#if _FS_REENTRANT
    _SYNC_t sobj;         /* Identifier of sync object */
#endif
#if !_FS_READONLY
    DWORD   last_clust;   /* Last allocated cluster */
    DWORD   free_clust;   /* Number of free clusters */
    DWORD   fsi_sector;   /* fsinfo sector (FAT32) */
#endif
#if _FS_RPATH
    DWORD   cdir;         /* Current directory cluster (0:root) */
#endif
    DWORD   n_fatent;     /* Number of FAT entries (== Number of clusters + 2) */
    DWORD   fsize;        /* Sectors per FAT */
    DWORD   fatbase;      /* FAT area start sector */
    DWORD   dirbase;      /* Root directory area start sector (FAT32: Cluster#) */
    DWORD   database;     /* Data area start sector */
    DWORD   winsect;      /* Current sector appearing in the win[] */
    BYTE    win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data on tiny cfg) */
} FATFS;

Return