#include "conf_explorer.h"
#include "fs_com.h"
#include "fat.h"
#include <string.h>
#include "ctrl_access.h"
Data Structures | |
struct | st_fs_format_table |
Functions | |
bool | fat_allocfreespace (void) |
This function allocs a cluster list. More... | |
bool | fat_clean_zone (bool b_MBR) |
This function cleans the reserved zone, FAT zone, and root dir zone. More... | |
bool | fat_clear_cluster (void) |
This function clears one cluster. More... | |
void | fat_clear_info_fat_mod (void) |
This function clears the cache information about FAT modifications. More... | |
bool | fat_create_entry_file_name (FS_STRING sz_name) |
This function creates the short and the long name of a new entry. More... | |
bool | fat_delete_file (bool b_cluster_list) |
This function deletes the file entries and cluster list. More... | |
bool | fat_entry_label (bool b_action, FS_STRING sz_label) |
This function reads or writes a label in the partition. More... | |
void | fat_get_date (FS_STRING sz_date, bool type_date) |
This function reads the information about a date. More... | |
uint32_t | fat_getfreespace (void) |
This function returns the space free in the partition. More... | |
uint8_t | fat_getfreespace_percent (void) |
This function returns the space free in percent. More... | |
bool | fat_initialize_dir (void) |
This function writes the directory information. More... | |
bool | fat_initialize_fat (void) |
This function initializes the fat one and two. More... | |
bool | fat_mount (void) |
This function mounts a partition file system (FAT12, FAT16 or FAT32) of selected drive. More... | |
uint32_t | fat_read_fat32_FSInfo (void) |
This function returns the space free in the selected FAT32 partition. More... | |
bool | fat_serialnumber (bool b_action, uint8_t _MEM_TYPE_SLOW_ *a_u8_sn) |
This function reads or writes a serial number in the drive. More... | |
void | fat_set_date (const FS_STRING sz_date, bool type_date) |
This function changes the date information. More... | |
bool | fat_update_fat2 (void) |
This function copies the modifications of the first FAT to the second FAT. More... | |
bool | fat_write_fat32_FSInfo (uint32_t u32_nb_free_cluster) |
This function writes the space free number in selected FAT32 partition. More... | |
bool | fat_write_PBR (bool b_MBR) |
This function writes the PBR. More... | |
Sub routines used by format routine | |
bool | fat_select_filesystem (uint8_t u8_fat_type, bool b_MBR) |
This function computes the FAT type to use. More... | |
bool | fat_write_MBR (void) |
This function writes the MBR. More... | |
Sub routines used by date read-write routines | |
void | fat_translatedate_number_to_ascii (FS_STRING sz_date, PTR_CACHE ptr_date, bool enable_ms) |
This function translates a date FAT value to ascii string. More... | |
void | fat_translate_number_to_ascii (FS_STRING sz_ascii_number, uint8_t u8_size_number_ascii, uint8_t u8_nb_increment) |
This function translates a digital number to a ASCII number. More... | |
void | fat_translatedate_ascii_to_number (const FS_STRING sz_date, PTR_CACHE ptr_date, bool enable_ms) |
This function translates a date ascii string to date FAT value. More... | |
uint16_t | fat_translate_ascii_to_number (const FS_STRING sz_ascii_number, uint8_t u8_size_number_ascii) |
This function translates a ASCII number to a digital number. More... | |
Sub routine used to create a entry file | |
void | fat_create_long_name_entry (FS_STRING sz_name, uint8_t u8_crc, uint8_t u8_id) |
This function creates a long name entry. More... | |
uint8_t | fat_create_short_entry_name (FS_STRING sz_name, FS_STRING short_name, uint8_t nb, bool mode) |
This function creates a short name in the internal cache sector OR in a string. More... | |
uint8_t | fat_find_short_entry_name (FS_STRING sz_name) |
This function searches an unique short name. More... | |
bool | fat_entry_shortname_compare (FS_STRING short_name) |
This function compares a short name with the current entry. More... | |
uint8_t | fat_check_name (FS_STRING sz_name) |
This function checks the character in name AND computes the number of entry file to store the name. More... | |
uint8_t | fat_translate_char_shortname (uint8_t character) |
This function translates the character to authorized short name character. More... | |
bool | fat_alloc_entry_free (uint8_t u8_nb_entry) |
This function allocs a number of entry in a current directory. More... | |
bool | fat_garbage_collector_entry (void) |
This function remove the entry selected in the directory to clean it. More... | |
Variables | |
_CONST_TYPE_ uint8_t | fs_s_execption_char [] ={'+',',','.',';','=','[',']'} |
Characters table no supported in a short name. More... | |
_CONST_TYPE_ uint8_t | fs_s_tab_incorrect_char [] ={':','*','?','"','<','>','|'} |
Characters table no supported in a file name. More... | |
Constants for fat_write_PBR() routine | |
_CONST_TYPE_ uint8_t | const_header_pbr [] |
_CONST_TYPE_ uint8_t | const_tail_pbr [] |
Constants of "FAT32 FSInfo Sector" | |
_CONST_TYPE_ uint8_t | const_FSI_LeadSig [] |
_CONST_TYPE_ uint8_t | const_FSI_StrucSig [] |
Constants for fat_initialize_fat() function | |
_CONST_TYPE_ uint8_t | const_header_fat12 [] |
_CONST_TYPE_ uint8_t | const_header_fat16 [] |
_CONST_TYPE_ uint8_t | const_header_fat32 [] |
Global variable to optimize the footprint of format routines | |
_MEM_TYPE_SLOW_ uint32_t | fs_s_u32_size_partition |
bool | fat_format (uint8_t u8_fat_type) |
This function formats the current drive. More... | |
Structure for the tables format | |
typedef struct st_fs_format_table | Fs_format_table |
_CONST_TYPE_ Fs_format_table | TableFAT12 [] |
Table format for FAT12. More... | |
_CONST_TYPE_ Fs_format_table | TableFAT16 [] |
Table format for FAT16. More... | |
_CONST_TYPE_ Fs_format_table | TableFAT32 [] |
Table format for FAT32. More... | |
typedef struct st_fs_format_table Fs_format_table |
bool fat_alloc_entry_free | ( | uint8_t | u8_nb_entry | ) |
This function allocs a number of entry in a current directory.
@param u8_nb_entry number of entry to alloc @return false in case of error, see global value "fs_g_status" for more detail @return true otherwise
//! OUT: Initialize the system on the last alloced free entry //!
References fat_allocfreespace(), fat_clear_cluster(), fat_garbage_collector_entry(), fat_get_ptr_entry(), fat_read_dir(), FS_ENTRY_END, FS_ERR_NO_FREE_SPACE, FS_ERR_OUT_LIST, fs_g_nav_fast, fs_g_seg, fs_g_status, Fs_management_fast::u16_entry_pos_sel_file, and Fs_segment::u32_size_or_pos.
uint8_t fat_check_name | ( | FS_STRING | sz_name | ) |
This function checks the character in name AND computes the number of entry file to store the name.
sz_name | original name to create |
References fat_check_eof_name(), FS_ERR_INCORRECT_NAME, FS_ERR_NAME_TOO_LARGE, fs_g_status, fs_s_tab_incorrect_char, FS_SIZE_LFN_ENTRY, and Is_unicode.
This function cleans the reserved zone, FAT zone, and root dir zone.
b_MBR | true, include a MBR on disk |
References _MEM_TYPE_SLOW_, fat_cache_clear(), fat_cache_flush(), fat_cache_mark_sector_as_dirty(), fat_cache_read_sector(), FS_CACHE_SIZE, fs_g_nav, fs_g_sector, fs_gu32_addrsector, Is_fat32, Fs_management::u32_fat_size, and Fs_management::u8_BPB_SecPerClus.
Referenced by fat_format().
This function creates a long name entry.
@param sz_name name to create (ASCII or UNICODE) @param u8_crc crc corresponding at short name @param u8_id long entry number (1 to n + FS_ENTRY_LFN_LAST)
//! OUT: Update the entry in internal cache sector with a new long name entry //!
References fat_cache_mark_sector_as_dirty(), fat_get_ptr_entry(), FS_ATTR_LFN_ENTRY, FS_SIZE_FILE_ENTRY, Is_unicode, LSB, and MSB.
uint8_t fat_create_short_entry_name | ( | FS_STRING | sz_name, |
FS_STRING | short_name, | ||
uint8_t | nb, | ||
bool | mode | ||
) |
This function creates a short name in the internal cache sector OR in a string.
sz_name | name to create (ASCII or UNICODE) |
short_name | short name in 8.3 format ( = 8+3 Bytes) (used only if mode = true) |
nb | number to add at short name (ex: name~nb) |
mode | true to write in a string false to write in internal cache |
References fat_cache_mark_sector_as_dirty(), fat_check_eof_name(), fat_get_ptr_entry(), fat_translate_char_shortname(), FS_SIZE_SFNAME, FS_SIZE_SFNAME_WITHOUT_EXT, and Is_unicode.
Referenced by fat_find_short_entry_name().
This function compares a short name with the current entry.
short_name | short name to compare (format entry = 8+3 Bytes) |
References fat_get_ptr_entry(), FS_ATTR_LFN_ENTRY, FS_ENTRY_DEL, FS_ENTRY_END, FS_ERR_ENTRY_BAD, FS_ERR_ENTRY_EMPTY, fs_g_status, and memcmp_ram2ram.
Referenced by fat_find_short_entry_name().
uint8_t fat_find_short_entry_name | ( | FS_STRING | sz_name | ) |
This function searches an unique short name.
sz_name | original name |
References _MEM_TYPE_SLOW_, fat_create_short_entry_name(), fat_entry_shortname_compare(), fat_read_dir(), FS_ERR_ENTRY_EMPTY, FS_ERR_OUT_LIST, fs_g_nav_fast, fs_g_status, and Fs_management_fast::u16_entry_pos_sel_file.
This function remove the entry selected in the directory to clean it.
References _MEM_TYPE_SLOW_, fat_cache_mark_sector_as_dirty(), fat_get_ptr_entry(), fat_read_dir(), FS_ENTRY_DEL, FS_ENTRY_END, FS_ERR_OUT_LIST, fs_g_nav_fast, fs_g_status, FS_SIZE_FILE_ENTRY, memcpy_ram2ram, and Fs_management_fast::u16_entry_pos_sel_file.
Referenced by fat_alloc_entry_free().
This function initializes the fat one and two.
References fat_cache_mark_sector_as_dirty(), fat_cache_read_sector(), fs_g_nav, fs_g_sector, fs_gu32_addrsector, Is_fat12, Is_fat16, Is_fat32, memcpy_code2ram, Fs_management::u32_fat_size, and Fs_management::u32_ptr_fat.
Referenced by fat_format().
This function computes the FAT type to use.
@param u8_fat_type Select the type of format <br> FS_FORMAT_DEFAULT, The file system module chooses the better FAT format for the drive space <br> FS_FORMAT_FAT, The FAT12 or FAT16 is used to format the drive, if possible (disk space <2GB) <br> FS_FORMAT_FAT32, The FAT32 is used to format the drive, if possible (disk space >32MB) <br> @param b_MBR true, include a MBR on disk @return false in case of error, see global value "fs_g_status" for more detail @return true otherwise
//! Compute the fat type, fat position and fat size. //!
References _CONST_TYPE_, FS_512B, FS_ERR_BAD_SIZE_FAT, FS_ERR_DEVICE_TOO_SMALL, FS_FORMAT_FAT, FS_FORMAT_FAT32, fs_g_nav, fs_g_nav_fast, fs_g_status, fs_s_u32_size_partition, FS_TYPE_FAT_12, FS_TYPE_FAT_16, FS_TYPE_FAT_32, Is_fat12, Is_fat16, Is_fat32, LSB, MSB, TableFAT12, TableFAT16, TableFAT32, Fs_management::u32_fat_size, Fs_management::u32_ptr_fat, Fs_management::u8_BPB_SecPerClus, and Fs_management_fast::u8_type_fat.
Referenced by fat_format().
uint16_t fat_translate_ascii_to_number | ( | const FS_STRING | sz_ascii_number, |
uint8_t | u8_size_number_ascii | ||
) |
This function translates a ASCII number to a digital number.
@param sz_ascii_number ascii number (ex:"1907") @param u8_size_number_ascii number of digit (ex:4) @return the digital number
//! OUT, update sz_ascii_number //!
References _MEM_TYPE_FAST_.
Referenced by fat_translatedate_ascii_to_number().
uint8_t fat_translate_char_shortname | ( | uint8_t | character | ) |
This function translates the character to authorized short name character.
character | character to translate |
References fs_s_execption_char.
Referenced by fat_create_short_entry_name().
void fat_translate_number_to_ascii | ( | FS_STRING | sz_ascii_number, |
uint8_t | u8_size_number_ascii, | ||
uint8_t | u8_nb_increment | ||
) |
This function translates a digital number to a ASCII number.
@param sz_ascii_number ascii string to increment (ex:"1907") @param u8_size_number_ascii number of digit (ex:4) @param u8_nb_increment number to add (ex:"102")
//! OUT, Update sz_ascii_number (ex:"2009") //!
Referenced by fat_translatedate_number_to_ascii().
void fat_translatedate_ascii_to_number | ( | const FS_STRING | sz_date, |
PTR_CACHE | ptr_date, | ||
bool | enable_ms | ||
) |
This function translates a date ascii string to date FAT value.
@param sz_date table with date information <br> storage format (ASCII) = "YYYYMMDDHHMMSSMS" = year, month, day, hour, minute, second, millisecond @param ptr_date pointer on date in internal cache @param enable_ms true, translate the millisecond field
//! OUT, write the date field at ptr_date //!
References fat_translate_ascii_to_number().
This function translates a date FAT value to ascii string.
sz_date | table to store the date information storage format (ASCII) = "YYYYMMDDHHMMSSMS" = year, month, day, hour, minute, second, millisecond |
ptr_date | pointer on date in internal cache |
enable_ms | true, translate the millisecond field |
References fat_translate_number_to_ascii().
Referenced by fat_get_date().
This function writes the MBR.
References fat_cache_clear(), fat_cache_mark_sector_as_dirty(), fat_cache_read_sector(), FS_512B, FS_BR_SIGNATURE_HIGH, FS_BR_SIGNATURE_LOW, fs_g_sector, fs_gu32_addrsector, FS_MBR_OFFSET_PART_ENTRY, FS_PART_NO_BOOTABLE, FS_PART_TYPE_FAT12, FS_PART_TYPE_FAT16_INF32M, FS_PART_TYPE_FAT16_SUP32M, FS_PART_TYPE_FAT32, fs_s_u32_size_partition, Is_fat12, Is_fat16, Is_fat32, LSB0, LSB1, LSB2, and LSB3.
Referenced by fat_format().
This function writes the PBR.
b_MBR | true, include a MBR on disk |
References const_header_pbr, const_tail_pbr, fat_cache_clear(), fat_cache_mark_sector_as_dirty(), fat_cache_read_sector(), fat_write_fat32_FSInfo(), FS_BR_SIGNATURE_HIGH, FS_BR_SIGNATURE_LOW, fs_g_nav, fs_g_sector, fs_gu32_addrsector, fs_s_u32_size_partition, HIGH_16_BPB_FATSz16, Is_fat12, Is_fat32, LOW0_32_BPB_FATSz32, LOW1_32_BPB_FATSz32, LOW_16_BPB_FATSz16, LSB, LSB0, LSB1, LSB2, LSB3, memcpy_code2ram, MSB, Fs_management::u16_offset_FSInfo, Fs_management::u32_fat_size, and Fs_management::u8_BPB_SecPerClus.
Referenced by fat_format().
_CONST_TYPE_ uint8_t const_FSI_LeadSig[] |
Referenced by fat_read_fat32_FSInfo().
_CONST_TYPE_ uint8_t const_FSI_StrucSig[] |
Referenced by fat_read_fat32_FSInfo().
_CONST_TYPE_ uint8_t const_header_fat12[] |
_CONST_TYPE_ uint8_t const_header_fat16[] |
_CONST_TYPE_ uint8_t const_header_fat32[] |
_CONST_TYPE_ uint8_t const_header_pbr[] |
Referenced by fat_write_PBR().
_CONST_TYPE_ uint8_t const_tail_pbr[] |
Referenced by fat_write_PBR().
_CONST_TYPE_ uint8_t fs_s_execption_char[] ={'+',',','.',';','=','[',']'} |
Characters table no supported in a short name.
Referenced by fat_translate_char_shortname().
_CONST_TYPE_ uint8_t fs_s_tab_incorrect_char[] ={':','*','?','"','<','>','|'} |
Characters table no supported in a file name.
Referenced by fat_check_name().
_MEM_TYPE_SLOW_ uint32_t fs_s_u32_size_partition |
Referenced by fat_format(), fat_select_filesystem(), fat_write_MBR(), and fat_write_PBR().
_CONST_TYPE_ Fs_format_table TableFAT12[] |
Table format for FAT12.
Referenced by fat_select_filesystem().
_CONST_TYPE_ Fs_format_table TableFAT16[] |
Table format for FAT16.
Referenced by fat_select_filesystem().
_CONST_TYPE_ Fs_format_table TableFAT32[] |
Table format for FAT32.
Referenced by fat_select_filesystem().