FatFs is a generic FAT file system module for small embedded systems.
The FatFs module is written in compliance with ANSI C (C89) and completely separated from the disk I/O layer. Therefore it is independent of the platform. It can be incorporated into small microcontrollers with limited resource, such as 8051, PIC, AVR, ARM, Z80, 78K and etc.
Features
- Windows compatible FAT file system.
- Platform independent. Easy to port.
- Very small footprint for code and work area.
Various configuration options:
- Multiple volumes (physical drives and partitions).
- Multiple ANSI/OEM code pages including DBCS.
- Long file name support in ANSI/OEM or Unicode.
- RTOS support for multi-task operation.
- Multiple sector size support upto 4KB.
- Read-only, minimized API, I/O buffer and etc...
Application Interface layer
File Access
f_open
- Open/Create a filef_close
- Close an open filef_read
- Read dataf_write
- Write dataf_lseek
- Move read/write pointer, Expand sizef_truncate
- Truncate sizef_sync
- Flush cached dataf_forward
- Forward data to the streamf_gets
- Read a stringf_putc
- Write a characterf_puts
- Write a stringf_printf
- Write a formatted stringf_tell
- Get current read/write pointerf_eof
- Test for end-of-filef_size
- Get sizef_error
- Test for an error
Directory Access
f_opendir
- Open a directoryf_closedir
- Close an open directoryf_readdir
- Read an itemf_findfirst
- Open a directory and read first item foundf_findnext
- Read a next item found
File/Directory Management
f_stat
- Check existance of a file or sub-directoryf_unlink
- Remove a file or sub-directoryf_rename
- Rename or move a file or sub-directoryf_chmod
- Change attribute of a file or sub-directoryf_utime
- Change timestamp of a file or sub-directoryf_mkdir
- Create a sub-directoryf_chdir
- Change current directoryf_chdrive
- Change current drivef_getcwd
- Retrieve the current directory and drive
Volume Management
f_mount
- Register/Unregister a work area of a volumef_mkfs
- Create an FAT volume on the logical drivef_fdisk
- Create logical drives on the physical drivef_getfree
- Get total size and free size on the volumef_getlabel
- Get volume labelf_setlabel
- Set volume label
Device Control Interface layer
Since the FatFs module is a file system layer, it is completely separated from the physical devices, such as memory card, harddisk and any type of storage devices. FatFs accesses the storage devices via a simple interface shown below. The low level device control module is not a part of FatFs module. It is provided by implementer. Also sample implementations for some platforms are available in the downloads.
disk_status
- Get device statusdisk_initialize
- Initialize devicedisk_read
- Read sector(s)disk_write
- Write sector(s)disk_ioctl
- Control device dependent featuresget_fattime
- Get current time.