File System Component  
MDK Middleware for Devices with Flash File System
 
Loading...
Searching...
No Matches
rl_fs.h File Reference
#include <stdint.h>
#include <stdbool.h>

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...
 

Macros

#define MW_FS_VERSION_MAJOR   8
 
#define MW_FS_VERSION_MINOR   0
 
#define MW_FS_VERSION_PATCH   0
 
#define FS_FAT_ATTR_READ_ONLY   0x01
 FAT File Attribute bit masks.
 
#define FS_FAT_ATTR_HIDDEN   0x02
 Hidden file attribute.
 
#define FS_FAT_ATTR_SYSTEM   0x04
 System file attribute.
 
#define FS_FAT_ATTR_VOLUME_ID   0x08
 Volume ID attribute.
 
#define FS_FAT_ATTR_DIRECTORY   0x10
 Directory file attribute.
 
#define FS_FAT_ATTR_ARCHIVE   0x20
 Archive file attribute.
 
#define FS_MEDIA_INSERTED   0x01
 IOC control code fsDevCtrlCodeCheckMedia return bit masks.
 
#define FS_MEDIA_PROTECTED   0x02
 Media Write Protected.
 
#define FS_MEDIA_INITIALIZED   0x04
 Media Initialized.
 
#define FS_MEDIA_NOCHKMEDIA   0x80
 Check Media Not implemented.
 
#define FS_CONTROL_MEDIA_INIT   0x00
 IOC control code fsDevCtrlCodeControlMedia argument values.
 
#define FS_CONTROL_EMMC_SLEEP   0x01
 Switch eMMC device to Sleep State.
 
#define FS_CONTROL_EMMC_AWAKE   0x02
 Wake-up eMMC device from Sleep State.
 
#define FS_DEVICE_SET_PASSWORD   0x01
 IOC control code fsDevCtrlCodeLockUnlock argument flags bit masks.
 
#define FS_DEVICE_CLR_PASSWORD   0x02
 Clear password.
 
#define FS_DEVICE_LOCK_UNLOCK   0x04
 Lock the device.
 
#define FS_DEVICE_ERASE   0x08
 Force erase operation.
 
#define FS_FOPEN_RD   0x0000
 File Open Mode bit masks.
 
#define FS_FOPEN_WR   0x0001
 Open file for writing only.
 
#define FS_FOPEN_RDWR   0x0002
 Open file for reading and writing.
 
#define FS_FOPEN_APPEND   0x0008
 Open file in append mode.
 
#define FS_FOPEN_CREATE   0x0100
 Create file if it does not exist.
 
#define FS_FOPEN_TRUNCATE   0x0200
 Truncate existing file.
 
#define FS_FSEEK_SET   0
 File Seek Operation values.
 
#define FS_FSEEK_CUR   1
 Seek from the current location.
 
#define FS_FSEEK_END   2
 Seek from the end of the file.
 

Enumerations

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...
 

Functions

fsStatus finit (const char *drive)
 Initialize File System and drive related driver.
 
fsStatus funinit (const char *drive)
 Uninitialize File System.
 
fsStatus fmount (const char *drive)
 Mount drive.
 
fsStatus funmount (const char *drive)
 Unmount drive.
 
uint32_t fversion (void)
 Retrieve the File System component version.
 
fsStatus fdelete (const char *path, const char *options)
 Delete one or multiple files.
 
fsStatus ffind (const char *pattern, fsFileInfo *info)
 Find a file or directory matching search pattern.
 
fsStatus frename (const char *path, const char *newname)
 Rename a file or directory with given path name to a new name.
 
fsStatus fattrib (const char *path, const char *attr)
 Change file attributes.
 
fsStatus fpwd (const char *drive, char *buf, uint32_t len)
 Print working directory.
 
fsStatus fchdir (const char *path)
 Change working directory.
 
fsStatus fmkdir (const char *path)
 Create a directory.
 
fsStatus frmdir (const char *path, const char *options)
 Remove a directory.
 
fsStatus fchdrive (const char *drive)
 Change current drive.
 
int64_t ffree (const char *drive)
 Find free space on drive.
 
fsStatus fformat (const char *drive, const char *options)
 Format drive.
 
int32_t fanalyse (const char *drive)
 Analyse volume and check for file fragmentation.
 
fsStatus fcheck (const char *drive)
 Analyse volume and check for allocation errors.
 
fsStatus fdefrag (const char *drive)
 Defragment Embedded Flash drive.
 
fsStatus fmedia (const char *drive)
 Check if media present on removable drive.
 
fsStatus finfo (const char *drive, fsDriveInfo *info)
 Read drive information.
 
fsStatus fvol (const char *drive, char *label, uint32_t *serial)
 Read volume label and serial number.
 
fsStatus ftime_set (const char *path, fsTime *create, fsTime *access, fsTime *write)
 Set file or directory timestamp.
 
fsStatus ftime_get (const char *path, fsTime *create, fsTime *access, fsTime *write)
 Get file or directory timestamp.
 
fsStatus fs_get_time (fsTime *time)
 Callback function used to provide the current date and time to the File System.
 
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.
 
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.
 
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.
 
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.
 
int32_t fs_ioc_get_id (const char *drive)
 Check if valid drive is specified and return its ID.
 
fsStatus fs_ioc_lock (int32_t drv_id)
 Lock drive and block media access to the upper layer.
 
fsStatus fs_ioc_unlock (int32_t drv_id)
 Unlock drive and allow media access to the upper layer.
 
fsStatus fs_ioc_get_cache (int32_t drv_id, fsIOC_Cache *cache_info)
 Return IOC cache buffer information.
 
fsStatus fs_ioc_read_sector (int32_t drv_id, uint32_t sect, uint8_t *buf, uint32_t cnt)
 Read sector from media.
 
fsStatus fs_ioc_write_sector (int32_t drv_id, uint32_t sect, const uint8_t *buf, uint32_t cnt)
 Write sector to media.
 
fsStatus fs_ioc_read_info (int32_t drv_id, fsMediaInfo *info)
 Read media configuration info.
 
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.
 
int32_t fs_fopen (const char *path, int32_t mode)
 Open a file.
 
int32_t fs_fclose (int32_t handle)
 Close a file.
 
int32_t fs_fwrite (int32_t handle, const void *buf, uint32_t cnt)
 Write to a file.
 
int32_t fs_fread (int32_t handle, void *buf, uint32_t cnt)
 Read from a file.
 
int32_t fs_fflush (int32_t handle)
 Flush file buffers.
 
int64_t fs_fseek (int32_t handle, int64_t offset, int32_t whence)
 Move the file position pointer.
 
int64_t fs_fsize (int32_t handle)
 Get file size.
 

Data Structure Documentation

◆ fsMediaInfo

struct fsMediaInfo

Media information.

Data Fields
uint32_t block_cnt Total number of blocks on the volume.
uint16_t read_blen Read block length.
uint16_t write_blen Write block length.

◆ fsIOC_Cache

struct fsIOC_Cache

IO Control Cache information.

Data Fields
uint8_t * buffer Cache Buffer (4 byte aligned)
uint32_t size Cache Buffer size in bytes.

◆ fsCID_Register

struct fsCID_Register

Memory card CID register.

Data Fields
uint16_t MDT Manufacturing date.
uint8_t MID Manufacturer ID.
uint16_t OID OEM/Application ID.
uint8_t PNM[6] Product name.
uint8_t PRV Product revision.
uint32_t PSN Product serial number.

◆ fsLockUnlock

struct fsLockUnlock

Media lock/unlock information structure.

Data Fields
uint8_t flags Operation definition bitmask.
uint8_t length Password length in bytes.
uint8_t const * password Password data buffer.

◆ fsHealthStatus

struct fsHealthStatus

Health status access structure.

Data Fields
uint32_t arg Health status control argument.
uint8_t * buf Data buffer.
uint32_t buf_sz Data buffer size in bytes.

◆ fsTime

struct fsTime

File System Time structure.

Data Fields
uint8_t day Day [1..31].
uint8_t hr Hours [0..23].
uint8_t min Minutes [0..59].
uint8_t mon Month [1..12].
uint8_t sec Seconds [0..59].
uint16_t year Year [1980..2107].

◆ fsFileInfo

struct fsFileInfo

File information data.

Data Fields
uint8_t attrib Attributes.
uint16_t fileID System Identification.
char name[256] Filename path.
uint32_t size File size in bytes.
fsTime time Create/Modify Time.

◆ fsDriveInfo

struct fsDriveInfo

Drive information.

Data Fields
uint64_t capacity Drives capacity in bytes.
fsType fs_type Drives file system type.

Macro Definition Documentation

◆ FS_CONTROL_EMMC_AWAKE

#define FS_CONTROL_EMMC_AWAKE   0x02

Wake-up eMMC device from Sleep State.

◆ FS_CONTROL_EMMC_SLEEP

#define FS_CONTROL_EMMC_SLEEP   0x01

Switch eMMC device to Sleep State.

◆ FS_CONTROL_MEDIA_INIT

#define FS_CONTROL_MEDIA_INIT   0x00

IOC control code fsDevCtrlCodeControlMedia argument values.

Initialize media device

◆ FS_DEVICE_CLR_PASSWORD

#define FS_DEVICE_CLR_PASSWORD   0x02

Clear password.

◆ FS_DEVICE_ERASE

#define FS_DEVICE_ERASE   0x08

Force erase operation.

◆ FS_DEVICE_LOCK_UNLOCK

#define FS_DEVICE_LOCK_UNLOCK   0x04

Lock the device.

◆ FS_DEVICE_SET_PASSWORD

#define FS_DEVICE_SET_PASSWORD   0x01

IOC control code fsDevCtrlCodeLockUnlock argument flags bit masks.

Set password

◆ FS_FAT_ATTR_ARCHIVE

#define FS_FAT_ATTR_ARCHIVE   0x20

Archive file attribute.

◆ FS_FAT_ATTR_DIRECTORY

#define FS_FAT_ATTR_DIRECTORY   0x10

Directory file attribute.

◆ FS_FAT_ATTR_HIDDEN

#define FS_FAT_ATTR_HIDDEN   0x02

Hidden file attribute.

◆ FS_FAT_ATTR_READ_ONLY

#define FS_FAT_ATTR_READ_ONLY   0x01

FAT File Attribute bit masks.

Read-only file attribute

◆ FS_FAT_ATTR_SYSTEM

#define FS_FAT_ATTR_SYSTEM   0x04

System file attribute.

◆ FS_FAT_ATTR_VOLUME_ID

#define FS_FAT_ATTR_VOLUME_ID   0x08

Volume ID attribute.

◆ FS_FOPEN_APPEND

#define FS_FOPEN_APPEND   0x0008

Open file in append mode.

◆ FS_FOPEN_CREATE

#define FS_FOPEN_CREATE   0x0100

Create file if it does not exist.

◆ FS_FOPEN_RD

#define FS_FOPEN_RD   0x0000

File Open Mode bit masks.

Open file for reading only

◆ FS_FOPEN_RDWR

#define FS_FOPEN_RDWR   0x0002

Open file for reading and writing.

◆ FS_FOPEN_TRUNCATE

#define FS_FOPEN_TRUNCATE   0x0200

Truncate existing file.

◆ FS_FOPEN_WR

#define FS_FOPEN_WR   0x0001

Open file for writing only.

◆ FS_FSEEK_CUR

#define FS_FSEEK_CUR   1

Seek from the current location.

◆ FS_FSEEK_END

#define FS_FSEEK_END   2

Seek from the end of the file.

◆ FS_FSEEK_SET

#define FS_FSEEK_SET   0

File Seek Operation values.

Seek from the start of the file

◆ FS_MEDIA_INITIALIZED

#define FS_MEDIA_INITIALIZED   0x04

Media Initialized.

◆ FS_MEDIA_INSERTED

#define FS_MEDIA_INSERTED   0x01

IOC control code fsDevCtrlCodeCheckMedia return bit masks.

Media Detected

◆ FS_MEDIA_NOCHKMEDIA

#define FS_MEDIA_NOCHKMEDIA   0x80

Check Media Not implemented.

◆ FS_MEDIA_PROTECTED

#define FS_MEDIA_PROTECTED   0x02

Media Write Protected.

◆ MW_FS_VERSION_MAJOR

#define MW_FS_VERSION_MAJOR   8

◆ MW_FS_VERSION_MINOR

#define MW_FS_VERSION_MINOR   0

◆ MW_FS_VERSION_PATCH

#define MW_FS_VERSION_PATCH   0

Enumeration Type Documentation

◆ fsDevCtrlCode

Driver DeviceCtrl parameter code.

Enumerator
fsDevCtrlCodeCheckMedia 

Check Media Status.

fsDevCtrlCodeControlMedia 

Control Media Device.

fsDevCtrlCodeFormat 

Format Media at low level.

fsDevCtrlCodeSerial 

Return device serial number.

fsDevCtrlCodeGetCID 

Read Memory Card CID Register.

fsDevCtrlCodeLockUnlock 

Manage device password protection.

fsDevCtrlCodeHealthStatus 

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

◆ fsType

enum fsType

File System Type.

Enumerator
fsTypeNone 

No file system (volume unformatted)

fsTypeUnknown 

File system type is unknown.

fsTypeFAT12 

File system type is FAT12.

fsTypeFAT16 

File system type is FAT16.

fsTypeFAT32 

File system type is FAT32.

fsTypeEFS 

File system type is EFS.