File System Component  Version 6.14.1
MDK Middleware for Devices with Flash File System
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
rl_fs.h File Reference
#include <stdint.h>
#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  fsMediaInfo
 Media information. More...
struct  fsIOC_Cache
 IO Control Cache information. More...
struct  fsCID_Register
 Memory card CID register. More...
struct  fsLockUnlock
 Media lock/unlock information structure. More...
struct  fsHealthStatus
 Health status access structure. More...
struct  fsTime
 File System Time structure. More...
struct  fsFileInfo
 File information data. More...
struct  fsDriveInfo
 Drive information. More...


#define FS_FAT_ATTR_READ_ONLY   0x01
 FAT File Attribute bit masks. More...
#define FS_FAT_ATTR_HIDDEN   0x02
 Hidden file attribute. More...
#define FS_FAT_ATTR_SYSTEM   0x04
 System file attribute. More...
#define FS_FAT_ATTR_VOLUME_ID   0x08
 Volume ID attribute. More...
#define FS_FAT_ATTR_DIRECTORY   0x10
 Directory file attribute. More...
#define FS_FAT_ATTR_ARCHIVE   0x20
 Archive file attribute. More...
#define FS_MEDIA_INSERTED   0x01
 IOC control code fsDevCtrlCodeCheckMedia return bit masks. More...
#define FS_MEDIA_PROTECTED   0x02
 Media Write Protected. More...
 Media Initialized. More...
#define FS_MEDIA_NOCHKMEDIA   0x80
 Check Media Not implemented. More...
#define FS_CONTROL_MEDIA_INIT   0x00
 IOC control code fsDevCtrlCodeControlMedia argument values. More...
#define FS_CONTROL_EMMC_SLEEP   0x01
 Switch eMMC device to Sleep State. More...
#define FS_CONTROL_EMMC_AWAKE   0x02
 Wake-up eMMC device from Sleep State. More...
 IOC control code fsDevCtrlCodeLockUnlock argument flags bit masks. More...
 Clear password. More...
#define FS_DEVICE_LOCK_UNLOCK   0x04
 Lock the device. More...
#define FS_DEVICE_ERASE   0x08
 Force erase operation. More...


enum  fsStatus {
  fsOK = 0, fsError, fsUnsupported, fsAccessDenied,
  fsInvalidParameter, fsInvalidDrive, fsInvalidPath, fsUninitializedDrive,
  fsDriverError, fsMediaError, fsNoMedia, fsNoFileSystem,
  fsNoFreeSpace, fsFileNotFound, fsDirNotEmpty, fsTooManyOpenFiles,
  fsAlreadyExists, fsNotDirectory
 File System return codes. More...
enum  fsType {
  fsTypeNone = 0, fsTypeUnknown, fsTypeFAT12, fsTypeFAT16,
  fsTypeFAT32, fsTypeEFS
 File System Type. More...
enum  fsDevCtrlCode {
  fsDevCtrlCodeCheckMedia = 0, fsDevCtrlCodeControlMedia, fsDevCtrlCodeFormat, fsDevCtrlCodeSerial,
  fsDevCtrlCodeGetCID, fsDevCtrlCodeLockUnlock, fsDevCtrlCodeHealthStatus
 Driver DeviceCtrl parameter code. More...


fsStatus finit (const char *drive)
 Initialize File System and drive related driver. More...
fsStatus funinit (const char *drive)
 Uninitialize File System. More...
fsStatus fmount (const char *drive)
 Mount drive. More...
fsStatus funmount (const char *drive)
 Unmount drive. More...
uint32_t fversion (void)
 Retrieve the File System component version. More...
fsStatus fdelete (const char *path, const char *options)
 Delete one or multiple files. More...
fsStatus ffind (const char *pattern, fsFileInfo *info)
 Find a file or directory matching search pattern. More...
fsStatus frename (const char *path, const char *newname)
 Rename a file or directory with given path name to a new name. More...
fsStatus fattrib (const char *path, const char *attr)
 Change file attributes. More...
fsStatus fpwd (const char *drive, char *buf, uint32_t len)
 Print working directory. More...
fsStatus fchdir (const char *path)
 Change working directory. More...
fsStatus fmkdir (const char *path)
 Create a directory. More...
fsStatus frmdir (const char *path, const char *options)
 Remove a directory. More...
fsStatus fchdrive (const char *drive)
 Change current drive. More...
int64_t ffree (const char *drive)
 Find free space on drive. More...
fsStatus fformat (const char *drive, const char *options)
 Format drive. More...
int32_t fanalyse (const char *drive)
 Analyse volume and check for file fragmentation. More...
fsStatus fcheck (const char *drive)
 Analyse volume and check for allocation errors. More...
fsStatus fdefrag (const char *drive)
 Defragment Embedded Flash drive. More...
fsStatus fmedia (const char *drive)
 Check if media present on removable drive. More...
fsStatus finfo (const char *drive, fsDriveInfo *info)
 Read drive information. More...
fsStatus fvol (const char *drive, char *label, uint32_t *serial)
 Read volume label and serial number. More...
fsStatus ftime_set (const char *path, fsTime *create, fsTime *access, fsTime *write)
 Set file or directory timestamp. More...
fsStatus ftime_get (const char *path, fsTime *create, fsTime *access, fsTime *write)
 Get file or directory timestamp. More...
fsStatus fs_get_time (fsTime *time)
 Callback function used to provide the current date and time to the File System. More...
int32_t fs_mc_read_cd (uint32_t drive_num)
 Callback function used to read Card Detect (CD) pin state when Memory Card is used in SPI mode. More...
int32_t fs_mc_read_wp (uint32_t drive_num)
 Callback function used to read Write Protect (WP) pin state when Memory Card is used in SPI mode. More...
int32_t fs_mc_spi_control_ss (uint32_t drive_num, uint32_t ss)
 Callback function used to control Slave Select signal when Memory Card is used in SPI mode. More...
fsLockUnlockfs_mc_lock_unlock (uint32_t drive_num)
 Callback function used to retrieve password management information in order to manage locked memory card device during initialization. More...
int32_t fs_ioc_get_id (const char *drive)
 Check if valid drive is specified and return its ID. More...
fsStatus fs_ioc_lock (int32_t drv_id)
 Lock drive and block media access to the upper layer. More...
fsStatus fs_ioc_unlock (int32_t drv_id)
 Unlock drive and allow media access to the upper layer. More...
fsStatus fs_ioc_get_cache (int32_t drv_id, fsIOC_Cache *cache_info)
 Return IOC cache buffer information. More...
fsStatus fs_ioc_read_sector (int32_t drv_id, uint32_t sect, uint8_t *buf, uint32_t cnt)
 Read sector from media. More...
fsStatus fs_ioc_write_sector (int32_t drv_id, uint32_t sect, const uint8_t *buf, uint32_t cnt)
 Write sector to media. More...
fsStatus fs_ioc_read_info (int32_t drv_id, fsMediaInfo *info)
 Read media configuration info. More...
fsStatus fs_ioc_device_ctrl (int32_t drv_id, fsDevCtrlCode code, void *p)
 IOC device control access; control code is sent directly to device driver. More...

Macro Definition Documentation

#define FS_CONTROL_EMMC_AWAKE   0x02

Wake-up eMMC device from Sleep State.

#define FS_CONTROL_EMMC_SLEEP   0x01

Switch eMMC device to Sleep State.

#define FS_CONTROL_MEDIA_INIT   0x00

IOC control code fsDevCtrlCodeControlMedia argument values.

Initialize media device


Clear password.

#define FS_DEVICE_ERASE   0x08

Force erase operation.

#define FS_DEVICE_LOCK_UNLOCK   0x04

Lock the device.


IOC control code fsDevCtrlCodeLockUnlock argument flags bit masks.

Set password

#define FS_FAT_ATTR_ARCHIVE   0x20

Archive file attribute.

#define FS_FAT_ATTR_DIRECTORY   0x10

Directory file attribute.

#define FS_FAT_ATTR_HIDDEN   0x02

Hidden file attribute.

#define FS_FAT_ATTR_READ_ONLY   0x01

FAT File Attribute bit masks.

Read-only file attribute

#define FS_FAT_ATTR_SYSTEM   0x04

System file attribute.

#define FS_FAT_ATTR_VOLUME_ID   0x08

Volume ID attribute.


Media Initialized.

#define FS_MEDIA_INSERTED   0x01

IOC control code fsDevCtrlCodeCheckMedia return bit masks.

Media Detected

#define FS_MEDIA_NOCHKMEDIA   0x80

Check Media Not implemented.

#define FS_MEDIA_PROTECTED   0x02

Media Write Protected.

Enumeration Type Documentation

Driver DeviceCtrl parameter code.


Check Media Status.


Control Media Device.


Format Media at low level.


Return device serial number.


Read Memory Card CID Register.


Manage device password protection.


Access device health status (S.M.A.R.T)

enum fsStatus

File System return codes.


Operation succeeded.


Unspecified error.


Operation not supported.


Resource access denied.


Invalid parameter specified.


Nonexistent drive.


Invalid path specified.


Drive is uninitialized.


Read/write error.


Media error.


No media, or not initialized.


File system is not formatted.


No free space available.


Requested file not found.


The directory is not empty.


Too many open files.


File or directory already exists.


Path is not a directory.

enum fsType

File System Type.


No file system (volume unformatted)


File system type is unknown.


File system type is FAT12.


File system type is FAT16.


File system type is FAT32.


File system type is EFS.