File System Component
Version 6.16.6
MDK Middleware for Devices with Flash File System
|
Utility Routines provide analytical and utility operations on drives. More...
Functions | |
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... | |
Utility Routines provide analytical and utility operations on drives.
You can change current drive, print working directory, analyse, format, and defragment drives. Also, reading drive and volume information data is supported.
int32_t fanalyse | ( | const char * | drive | ) |
Analyse volume and check for file fragmentation.
[in] | drive | a string specifying the memory or storage device. |
The function fanalyse examines the Embedded File System and checks for file fragmentation.
The argument drive specifies the Drives, Memory Devices and Drivers to be analysed. The Current Drive is used if an empty string is provided. A NULL pointer is not allowed and will be rejected.
Code Example
fsStatus fchdrive | ( | const char * | drive | ) |
Change current drive.
[in] | drive | a string specifying the memory or storage device. |
The function fchdrive changes the Current Drive.
The argument drive specifies the Drives, Memory Devices and Drivers to be selected as the Current Drive. A NULL pointer is not allowed and will be rejected.
fsStatus fcheck | ( | const char * | drive | ) |
Analyse volume and check for allocation errors.
[in] | drive | a string specifying the memory or storage device. |
The function fcheck analyses the consistency of the Embedded File System and determines if it has been initialized.
The argument drive specifies the Drives, Memory Devices and Drivers to be checked. The Current Drive is used if an empty string is provided. A NULL pointer is not allowed and will be rejected.
Code Example
fsStatus fdefrag | ( | const char * | drive | ) |
Defragment Embedded Flash drive.
[in] | drive | a string specifying the memory or storage device. |
The function fdefrag de-fragments the Embedded File System. Drive is examined for used blocks which are without valid file allocation records. Such blocks are erased and marked as empty. Fragmented files are consolidated. The result of file consolidation is faster file access and increased overall performance.
The argument drive specifies the Drives, Memory Devices and Drivers to be de-fragmented. The Current Drive is used if an empty string is provided. A NULL pointer is not allowed and will be rejected.
Code Example
fsStatus fformat | ( | const char * | drive, |
const char * | options | ||
) |
Format drive.
[in] | drive | a string specifying the memory or storage device. |
[in] | options | string specifying formatting options. |
The function fformat formats an EFS or FAT storage media for using a file system. The function closes all open files on the specified drive. Existing file handles become invalid.
The argument drive specifies the Drives, Memory Devices and Drivers. The Current Drive is used if an empty string is provided. A NULL pointer is not allowed and will be rejected.
The argument options can be pointer to a string or NULL when formatting options are not used.
FAT drive formatting options:
Option | Description |
---|---|
/L label | Specifies volume label. If /L option is not specified or if label is not given, then volume label will not be written. Terminating character for label can be slash (/) or NUL character. Trailing spaces will be ignored. |
/FAT32 | Formats the media for using the FAT32 file system. FAT32 can be used on media devices with size >= 256MB. |
/W | Clears all data. Erases all available data sectors. |
/LL | Clears all data. Performs low-level formatting first (NAND drive only). |
/LLEB | Clears all data. Performs low-level formatting and erases bad blocks first (NAND drive only). /LLEB has higher priority than /LL in case if both options are specified. |
/<other> | Unknown options are ignored. |
When formatting option /FAT32 is not used, the media device will be formatted using default, predefined settings. The file system type depends then on media device size and will be chosen as follows:
EFS drive formatting options:
There are no special formatting options available for the Embedded File System. Argument options is ignored.
Code Example
int64_t ffree | ( | const char * | drive | ) |
Find free space on drive.
[in] | drive | a string specifying the memory or storage device. |
The function ffree calculates the free space on a device.
The argument drive specifies the Drives, Memory Devices and Drivers. The Current Drive is used if an empty string is provided. A NULL pointer is not allowed and will be rejected.
Code Example
fsStatus finfo | ( | const char * | drive, |
fsDriveInfo * | info | ||
) |
Read drive information.
[in] | drive | a string specifying the memory or storage device. |
[out] | info | drive information structure. |
The function finfo reads general drive informations from the volume and puts them into the info structure.
The argument drive specifies the Drives, Memory Devices and Drivers. The Current Drive is used if an empty string is provided. A NULL pointer is not allowed and will be rejected.
fsStatus fmedia | ( | const char * | drive | ) |
Check if media present on removable drive.
[in] | drive | a string specifying the memory or storage device. |
The function fmedia uses media device interface driver to detect the presence of a removable drive in the system (such as SD/MMC cards or USB Flash drives). In case of SD/MMC cards, it can be used even when card socket does not provide card detection pin, but only after a successful device initialization (i.e. after a successful call of fmount or fs_ioc_device_ctrl using fsDevCtrlCodeControlMedia). In such case, device presence is determined using internal register states.
The argument drive specifies the Drives, Memory Devices and Drivers. The Current Drive is used if an empty string is provided. A NULL pointer is not allowed and will be rejected.
fsStatus fvol | ( | const char * | drive, |
char * | label, | ||
uint32_t * | serial | ||
) |
Read volume label and serial number.
[in] | drive | a string specifying the memory or storage device. |
[out] | label | buffer for storing label as a null terminated string. When volume has no label an empty string is returned. This parameter can be NULL meaning label will not be read. |
[out] | serial | pointer to variable where serial number will be stored. This parameter can be NULL meaning serial number will not be read. |
The function fvol reads the volume label.
The argument drive specifies the Drives, Memory Devices and Drivers. The Current Drive is used if an empty string is provided. A NULL pointer is not allowed and will be rejected.
The argument label specifies a buffer where the volume label will be stored as a null terminated string. Its size must be at least 12 bytes to prevent buffer overflow. If volume has no label an empty string is returned.
The argument serial specifies a pointer to a 32-bit variable where the volume serial number will be stored. The serial number is usually written when the volume is formatted and can be used to distinguish between volumes on removable devices.
Code Example