FAT file system driver that provides an interface for accessing a FAT file system located on a memory device.
Supports FAT12, FAT16 and FAT32.
Data Structures | |
struct | Fs_clusterlist_cache |
Structure to store the cluster list cache. More... | |
struct | Fs_management |
Structure to save the variables frequently used by file system mounted. More... | |
struct | Fs_management_entry |
Structure to save the frequently variables of file system mounted. More... | |
struct | Fs_management_fast |
Structure to save the variables very frequently used by file system mounted. More... | |
union | Fs_rootdir |
Union to define a root directory. More... | |
struct | Fs_sector_cache |
Structure to store the information about sector cache (=last sector read or write on disk) More... | |
struct | Fs_segment |
Structure to define a segment. More... | |
struct | st_fs_cluster |
Structure to store cluster information. More... | |
Macros | |
#define | _GLOBEXT_ extern |
#define | FS_BUF_SECTOR_EMPTY 0xFF |
Signal that sector cache is not valid. More... | |
#define | FS_MBR_OFFSET_PART_ENTRY(num) ((uint16_t)((uint16_t)(0x1BE)+(0x10 * num))) |
Position (unit byte) in the MBR of a partition entry. More... | |
#define | Is_fat12 (FS_TYPE_FAT_12 == fs_g_nav_fast.u8_type_fat) |
#define | Is_fat16 (FS_TYPE_FAT_16 == fs_g_nav_fast.u8_type_fat) |
#define | Is_fat32 (FS_TYPE_FAT_32 == fs_g_nav_fast.u8_type_fat) |
#define | Is_unicode (0) |
Functions | |
bool | fat_format (uint8_t u8_fat_type) |
This function formats the drive. More... | |
uint8_t | fat_get_nbpartition (void) |
This function returns the number of partition present on selected drive. More... | |
bool | fat_mount (void) |
This function mounts a partition. More... | |
bool | fat_serialnumber (bool b_action, uint8_t _MEM_TYPE_SLOW_ *a_u8_sn) |
This function reads or writes a serial number. More... | |
Variables | |
_GLOBEXT_ _MEM_TYPE_FAST_ Fs_cluster | fs_g_cluster |
To take time in functions: fat_getfreespace, fat_cluster_list, fat_cluster_val, fat_checkcluster. More... | |
_GLOBEXT_ _MEM_TYPE_FAST_ Fs_segment | fs_g_seg |
Variable frequently used by many function (optimization, no parameter in function) More... | |
_GLOBEXT_ bool | g_b_no_check_disk |
Variables to enable/disable the disk check before each action on disk. More... | |
_GLOBEXT_ bool | g_b_string_length |
Variables to select LENGTH string mode (initialised in nav_reset()) More... | |
_GLOBEXT_ bool | g_b_unicode |
Variables to select string format (initialised in nav_reset()) More... | |
Constants used to sign a MBR or PBR sectors | |
#define | FS_BR_SIGNATURE_LOW 0x55 |
#define | FS_BR_SIGNATURE_HIGH 0xAA |
Constants used in MBR sector | |
#define | FS_PART_BOOTABLE 0x80 |
#define | FS_PART_NO_BOOTABLE 0x00 |
#define | FS_PART_TYPE_FAT12 0x01 |
#define | FS_PART_TYPE_FAT16_INF32M 0x04 |
#define | FS_PART_TYPE_FAT16_SUP32M 0x06 |
#define | FS_PART_TYPE_FAT16_SUP32M_BIS 0x0E |
#define | FS_PART_TYPE_FAT32 0x0B |
#define | FS_PART_TYPE_FAT32_BIS 0x0C |
#define | FS_PART_REMOVE_MEDIA 0xF0 |
#define | FS_PART_NO_REMOVE_MEDIA 0xF8 |
#define | FS_PART_HARD_DISK 0x81 |
#define | FS_BOOT_SIGN 0x29 |
Maximum of FAT cluster | |
#define | FS_FAT12_MAX_CLUSTERS 4085 |
#define | FS_FAT16_MAX_CLUSTERS 65525 |
Constants used in the first byte of file entry | |
#define | FS_ENTRY_END 0x00 |
#define | FS_ENTRY_DEL 0xE5 |
#define | FS_ENTRY_LFN_LAST 0x40 |
Constantes used to manage the file entry | |
#define | FS_SIZE_FILE_ENTRY 32 |
#define | FS_SHIFT_B_TO_FILE_ENTRY 5 |
#define | FS_SIZE_LFN_ENTRY 13 |
#define | FS_SIZE_SFNAME 11 |
#define | FS_SIZE_SFNAME_WITHOUT_EXT 8 |
#define | FS_SIZE_SFNAME_EXT_ONLY 3 |
LIMITATIONS OF FILE SYSTEM | |
#define | FS_NB_FAT 2 |
The unit sector of 512B is many used in file System stack | |
#define | FS_512B 512 |
#define | FS_512B_MASK (512-1) |
#define | FS_512B_SHIFT_BIT 9 |
#define | FS_SIZE_OF_SECTOR FS_512B |
#define | FS_MASK_SIZE_OF_SECTOR FS_512B_MASK |
#define | FS_SHIFT_B_TO_SECTOR FS_512B_SHIFT_BIT |
#define | FS_CACHE_SIZE 512 |
Status of the fat_checkcluster() function | |
#define | FS_CLUS_OK 0 |
#define | FS_CLUS_BAD 1 |
#define | FS_CLUS_END 2 |
Options of the fat_cluster_list() function | |
#define | FS_CLUST_ACT_SEG 0x01 |
#define | FS_CLUST_ACT_ONE 0x02 |
#define | FS_CLUST_ACT_CLR 0x03 |
Options of the fat_cluster_val() function | |
#define | FS_CLUST_VAL_READ false |
#define | FS_CLUST_VAL_WRITE true |
#define | FS_CLUST_VAL_EOL 0x0FFFFFFF |
Main structures | |
typedef struct st_fs_cluster | Fs_cluster |
Structure to store cluster information. More... | |
FAT type ID, used in "Fs_management_fast.u8_type_fat" | |
#define | FS_TYPE_FAT_UNM 0 |
Partition not mounted. More... | |
#define | FS_TYPE_FAT_12 1 |
#define | FS_TYPE_FAT_16 2 |
#define | FS_TYPE_FAT_32 3 |
Value used in "Fs_management_fast.u16_entry_pos_sel_file" | |
#define | FS_NO_SEL 0xFFFF |
Signal that a file entry isn't selected. More... | |
#define | FS_END_FIND 0xFFFE |
Signal that a file entry is the last file entry accessible by system. More... | |
Macro to check the file open mode | |
#define | Fat_file_is_open() (fs_g_nav_entry.u8_open_mode !=0 ) |
#define | Fat_file_isnot_open() (fs_g_nav_entry.u8_open_mode ==0 ) |
#define | Fat_file_close() (fs_g_nav_entry.u8_open_mode =0 ) |
Variables initialized in drive_mount() | |
_GLOBEXT_ _MEM_TYPE_SLOW_ Fs_management | fs_g_nav |
_GLOBEXT_ _MEM_TYPE_FAST_ Fs_management_fast | fs_g_nav_fast |
_GLOBEXT_ _MEM_TYPE_SLOW_ Fs_management_entry | fs_g_nav_entry |
Variables used to update the second FAT zone | |
_GLOBEXT_ _MEM_TYPE_SLOW_ uint32_t | fs_g_u32_first_mod_fat |
Offset (unit 512B) in fat of the first sector (unit 512B) More... | |
_GLOBEXT_ _MEM_TYPE_SLOW_ uint32_t | fs_g_u32_last_mod_fat |
Offset (unit 512B) in fat of the last sector (unit 512B) More... | |
Variables used to manage the sector cache | |
typedef uint8_t _MEM_TYPE_SLOW_ * | PTR_CACHE |
_GLOBEXT_ _MEM_TYPE_SLOW_ uint8_t | fs_g_sector [FS_CACHE_SIZE] |
Use "FAT sector cache" to store a sector from a file (see file_putc(), file_getc(), file_read_buf(), file_write_buf()) More... | |
_GLOBEXT_ _MEM_TYPE_SLOW_ Fs_sector_cache | fs_g_sectorcache |
_GLOBEXT_ _MEM_TYPE_SLOW_ uint32_t | fs_gu32_addrsector |
Store the address of future cache (unit 512B) More... | |
Functions to verify navigator state | |
bool | fat_check_device (void) |
This function checks device state. More... | |
bool | fat_check_mount (void) |
This function checks if the partition is mounted. More... | |
bool | fat_check_noopen (void) |
This function checks if a file is not opened on current navigator. More... | |
bool | fat_check_open (void) |
This function checks if a file is opened on current navigator. More... | |
bool | fat_check_select (void) |
This function checks if a file is selected on current navigator. More... | |
bool | fat_check_mount_noopen (void) |
This function checks if the partition is mounted and no file is opened. More... | |
bool | fat_check_mount_select_noopen (void) |
This function checks if the partition is mounted and if no file is opened and a file is selected. More... | |
bool | fat_check_mount_select_open (void) |
This function checks if the partition is mounted and if a file is opened. More... | |
bool | fat_check_mount_select (void) |
This function checks if the partition is mounted and if a file is selected. More... | |
bool | fat_check_is_file (void) |
This function checks if the selected file entry is a file and not a directory. More... | |
Functions to compute free space on a partition | |
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_write_fat32_FSInfo (uint32_t u32_nb_free_cluster) |
This function writes the space free number in selected FAT32 partition. More... | |
uint32_t | fat_read_fat32_FSInfo (void) |
This function returns the space free in the selected FAT32 partition. More... | |
Functions to manage the cluster list | |
bool | fat_cluster_list (uint8_t opt_action, bool b_for_file) |
This function gets or clears a cluster list. More... | |
void | fat_cache_clusterlist_reset (void) |
This function resets the cluster list caches. More... | |
bool | fat_cluster_val (bool b_mode) |
This function returns or modifies a cluster value in FAT. More... | |
bool | fat_cluster_readnext (void) |
This function is optimized to read a continue cluster list on FAT16 and FAT32. More... | |
uint8_t | fat_checkcluster (void) |
This function checks the cluster value. More... | |
bool | fat_allocfreespace (void) |
This function allocs a cluster list. More... | |
void | fat_clear_info_fat_mod (void) |
This function clears the cache information about FAT modifications. More... | |
bool | fat_clear_cluster (void) |
This function clears one cluster. More... | |
bool | fat_update_fat2 (void) |
This function copies the modifications of the first FAT to the second FAT. More... | |
Functions to read or to write a file or a directory | |
bool | fat_read_file (uint8_t mode) |
This function gets or clears a cluster list at the current position in the selected file. More... | |
bool | fat_write_file (uint8_t mode, uint32_t u32_nb_sector_write) |
This function gets and eventually allocs a cluster list at the current position in the selected file. More... | |
bool | fat_read_dir (void) |
This function fill the internal cache with a sector from current directory. More... | |
bool | fat_initialize_dir (void) |
This function writes the directory information. More... | |
Functions to manage the entry field (fat.c) | |
bool | fat_entry_check (bool b_type) |
This function checks the entry. More... | |
bool | fat_entry_checkext (FS_STRING sz_filter) |
This function checks the file extension. More... | |
void | fat_get_entry_info (void) |
This function reads information about selected file. More... | |
bool | fat_entry_is_dir (void) |
This function checks if the entry file is a directory. More... | |
void | fat_clear_entry_info_and_ptr (void) |
This function resets the selection pointers. More... | |
void | fat_write_entry_file (void) |
This function writes the information about selected file. More... | |
bool | fat_entry_shortname (FS_STRING sz_name, uint8_t u8_size_max, bool b_mode) |
This function returns or compares the short name entry. More... | |
bool | fat_entry_longname (FS_STRING sz_name, uint8_t u8_size_max, bool b_mode, bool b_match_case) |
This function returns or compares the long name entry. More... | |
bool | fat_check_eof_name (uint16_t character) |
Check end of name. More... | |
PTR_CACHE | fat_get_ptr_entry (void) |
This function returns a cache pointer on the current entry. More... | |
Functions to manage the entry field (fat_unusual.c) | |
bool | fat_create_entry_file_name (FS_STRING sz_name) |
This function creates the short and the long name of a new entry. More... | |
void | fat_get_date (FS_STRING sz_date, bool type_date) |
This function reads the information about a date. More... | |
void | fat_set_date (const FS_STRING sz_date, bool type_date) |
This function changes the date information. 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... | |
Functions to manage the cache | |
bool | fat_cache_read_sector (bool b_load) |
This function loads a memory sector in internal cache sector. More... | |
void | fat_cache_reset (void) |
This function resets the sector cache. More... | |
void | fat_cache_clear (void) |
This function clears the sector cache. More... | |
void | fat_cache_mark_sector_as_dirty (void) |
This function sets a flag to signal that sector cache is modified. More... | |
bool | fat_cache_flush (void) |
This function flushes the sector cache on the memory if necessary. More... | |
Functions to control access disk | |
bool | fat_check_nav_access_disk (void) |
This function checks write access. More... | |
bool | fat_check_nav_access_file (bool mode) |
This function checks all access at current file. More... | |
Functions to manage navigator switch | |
void | fat_invert_nav (uint8_t u8_idnav) |
This function inverts the current navigation with another. More... | |
void | fat_copy_nav (uint8_t u8_idnav) |
This function copies the main navigator to another navigator. More... | |
#define _GLOBEXT_ extern |
//! - File system vocabulary : //! MBR : Master Boot Record (constains four PE) //! PE : Partition Entry (constains a location informations about PBR) //! PBR : Partition Boot Record //! BPB : BIOS Parameter Block (see Hardware White Paper FAT) //! PBR = BPB //! FAT : File Allocation Table //!
#define Fat_file_close | ( | ) | (fs_g_nav_entry.u8_open_mode =0 ) |
Referenced by fat_check_device(), fat_clear_entry_info_and_ptr(), file_close(), and nav_reset().
#define Fat_file_is_open | ( | ) | (fs_g_nav_entry.u8_open_mode !=0 ) |
Referenced by fat_check_noopen().
#define Fat_file_isnot_open | ( | ) | (fs_g_nav_entry.u8_open_mode ==0 ) |
Referenced by fat_check_open().
#define FS_512B 512 |
Referenced by fat_mount(), fat_select_filesystem(), fat_write_MBR(), file_read(), file_read_buf(), file_write_buf(), nav_file_paste_state(), and stream_mem_to_mem().
#define FS_512B_MASK (512-1) |
Referenced by fat_get_ptr_entry(), fat_read_file(), file_getc(), file_putc(), and file_read().
#define FS_512B_SHIFT_BIT 9 |
Referenced by fat_read_dir(), fat_read_file(), file_read(), and nav_file_lgtsector().
#define FS_BOOT_SIGN 0x29 |
#define FS_BR_SIGNATURE_HIGH 0xAA |
Referenced by fat_mount(), fat_read_fat32_FSInfo(), fat_write_MBR(), and fat_write_PBR().
#define FS_BR_SIGNATURE_LOW 0x55 |
Referenced by fat_mount(), fat_read_fat32_FSInfo(), fat_write_MBR(), and fat_write_PBR().
#define FS_BUF_SECTOR_EMPTY 0xFF |
Signal that sector cache is not valid.
Referenced by fat_cache_reset().
#define FS_CACHE_SIZE 512 |
Referenced by fat_clean_zone(), fat_cluster_readnext(), and fat_cluster_val().
#define FS_CLUS_BAD 1 |
Referenced by fat_checkcluster(), and fat_cluster_list().
#define FS_CLUS_END 2 |
Referenced by fat_checkcluster(), and fat_cluster_list().
#define FS_CLUS_OK 0 |
Referenced by fat_checkcluster().
#define FS_CLUST_ACT_CLR 0x03 |
Referenced by fat_cluster_list(), fat_delete_file(), fat_read_file(), and file_set_eof().
#define FS_CLUST_ACT_ONE 0x02 |
Referenced by fat_cluster_list(), fat_read_dir(), fat_read_file(), file_getc(), file_putc(), file_read_buf(), and file_write_buf().
#define FS_CLUST_ACT_SEG 0x01 |
Referenced by fat_cluster_list(), fat_read_file(), file_read(), file_read_buf(), and file_write_buf().
#define FS_CLUST_VAL_EOL 0x0FFFFFFF |
Referenced by fat_cluster_list().
#define FS_CLUST_VAL_READ false |
Referenced by fat_cluster_list(), fat_getfreespace(), and fat_getfreespace_percent().
#define FS_CLUST_VAL_WRITE true |
Referenced by fat_cluster_list().
#define FS_END_FIND 0xFFFE |
Signal that a file entry is the last file entry accessible by system.
Referenced by nav_filelist_set().
#define FS_ENTRY_DEL 0xE5 |
#define FS_ENTRY_END 0x00 |
#define FS_ENTRY_LFN_LAST 0x40 |
Referenced by fat_delete_file(), and fat_entry_longname().
#define FS_FAT12_MAX_CLUSTERS 4085 |
Referenced by fat_mount().
#define FS_FAT16_MAX_CLUSTERS 65525 |
Referenced by fat_mount().
#define FS_MASK_SIZE_OF_SECTOR FS_512B_MASK |
#define FS_MBR_OFFSET_PART_ENTRY | ( | num | ) | ((uint16_t)((uint16_t)(0x1BE)+(0x10 * num))) |
Position (unit byte) in the MBR of a partition entry.
Referenced by fat_mount(), and fat_write_MBR().
#define FS_NB_FAT 2 |
Referenced by fat_mount().
#define FS_NO_SEL 0xFFFF |
Signal that a file entry isn't selected.
Referenced by fat_check_select(), fat_clear_entry_info_and_ptr(), nav_filelist_eol(), nav_filelist_exist(), nav_filelist_goto(), nav_filelist_nb(), and nav_filelist_set().
#define FS_PART_BOOTABLE 0x80 |
Referenced by fat_mount().
#define FS_PART_HARD_DISK 0x81 |
#define FS_PART_NO_BOOTABLE 0x00 |
Referenced by fat_mount(), and fat_write_MBR().
#define FS_PART_NO_REMOVE_MEDIA 0xF8 |
#define FS_PART_REMOVE_MEDIA 0xF0 |
#define FS_PART_TYPE_FAT12 0x01 |
Referenced by fat_mount(), and fat_write_MBR().
#define FS_PART_TYPE_FAT16_INF32M 0x04 |
Referenced by fat_mount(), and fat_write_MBR().
#define FS_PART_TYPE_FAT16_SUP32M 0x06 |
Referenced by fat_mount(), and fat_write_MBR().
#define FS_PART_TYPE_FAT16_SUP32M_BIS 0x0E |
Referenced by fat_mount().
#define FS_PART_TYPE_FAT32 0x0B |
Referenced by fat_mount(), and fat_write_MBR().
#define FS_PART_TYPE_FAT32_BIS 0x0C |
Referenced by fat_mount().
#define FS_SHIFT_B_TO_FILE_ENTRY 5 |
Referenced by fat_read_dir().
#define FS_SHIFT_B_TO_SECTOR FS_512B_SHIFT_BIT |
Referenced by ushell_cmd_free_space().
#define FS_SIZE_FILE_ENTRY 32 |
Referenced by fat_create_long_name_entry(), fat_entry_longname(), fat_garbage_collector_entry(), fat_get_ptr_entry(), and fat_mount().
#define FS_SIZE_LFN_ENTRY 13 |
Referenced by fat_check_name(), and nav_file_name().
#define FS_SIZE_OF_SECTOR FS_512B |
#define FS_SIZE_SFNAME 11 |
Referenced by fat_create_short_entry_name(), and fat_entry_shortname().
#define FS_SIZE_SFNAME_EXT_ONLY 3 |
#define FS_SIZE_SFNAME_WITHOUT_EXT 8 |
Referenced by fat_create_short_entry_name(), and fat_entry_shortname().
#define FS_TYPE_FAT_12 1 |
Referenced by fat_mount(), fat_select_filesystem(), and ushell_cmd_ls().
#define FS_TYPE_FAT_16 2 |
Referenced by fat_mount(), fat_select_filesystem(), and ushell_cmd_ls().
#define FS_TYPE_FAT_32 3 |
Referenced by fat_mount(), fat_select_filesystem(), and ushell_cmd_ls().
#define FS_TYPE_FAT_UNM 0 |
Partition not mounted.
Referenced by fat_check_device(), fat_check_mount(), fat_check_nav_access_file(), fat_check_noopen(), fat_mount(), nav_drive_set(), nav_partition_freespace(), nav_partition_freespace_percent(), nav_partition_mount(), nav_partition_space(), nav_partition_type(), and nav_reset().
#define HIGH_16_BPB_BytsPerSec fs_g_sector[12] |
Referenced by fat_mount().
#define HIGH_16_BPB_FATSz16 fs_g_sector[23] |
Referenced by fat_mount(), and fat_write_PBR().
#define HIGH_16_BPB_FSInfo fs_g_sector[49] |
#define HIGH_16_BPB_ResvSecCnt fs_g_sector[15] |
Referenced by fat_mount().
#define HIGH_16_BPB_RootEntCnt fs_g_sector[18] |
Referenced by fat_mount().
#define HIGH_16_BPB_TotSec16 fs_g_sector[20] |
Referenced by fat_mount().
#define Is_fat12 (FS_TYPE_FAT_12 == fs_g_nav_fast.u8_type_fat) |
#define Is_fat16 (FS_TYPE_FAT_16 == fs_g_nav_fast.u8_type_fat) |
#define Is_fat32 (FS_TYPE_FAT_32 == fs_g_nav_fast.u8_type_fat) |
#define Is_unicode (0) |
#define LOW0_32_BPB_FATSz32 fs_g_sector[36] |
Referenced by fat_mount(), and fat_write_PBR().
#define LOW0_32_BPB_RootClus fs_g_sector[44] |
Referenced by fat_mount().
#define LOW0_32_BPB_TotSec32 fs_g_sector[32] |
Referenced by fat_mount().
#define LOW1_32_BPB_FATSz32 fs_g_sector[37] |
Referenced by fat_mount(), and fat_write_PBR().
#define LOW1_32_BPB_RootClus fs_g_sector[45] |
Referenced by fat_mount().
#define LOW1_32_BPB_TotSec32 fs_g_sector[33] |
Referenced by fat_mount().
#define LOW2_32_BPB_FATSz32 fs_g_sector[38] |
Referenced by fat_mount().
#define LOW2_32_BPB_RootClus fs_g_sector[46] |
Referenced by fat_mount().
#define LOW2_32_BPB_TotSec32 fs_g_sector[34] |
Referenced by fat_mount().
#define LOW3_32_BPB_FATSz32 fs_g_sector[39] |
Referenced by fat_mount().
#define LOW3_32_BPB_RootClus fs_g_sector[47] |
Referenced by fat_mount().
#define LOW3_32_BPB_TotSec32 fs_g_sector[35] |
Referenced by fat_mount().
#define LOW_16_BPB_BytsPerSec fs_g_sector[11] |
#define LOW_16_BPB_FATSz16 fs_g_sector[22] |
Referenced by fat_mount(), and fat_write_PBR().
#define LOW_16_BPB_FSInfo fs_g_sector[48] |
Referenced by fat_mount().
#define LOW_16_BPB_ResvSecCnt fs_g_sector[14] |
Referenced by fat_mount().
#define LOW_16_BPB_RootEntCnt fs_g_sector[17] |
Referenced by fat_mount().
#define LOW_16_BPB_TotSec16 fs_g_sector[19] |
Referenced by fat_mount().
#define U8_BPB_NumFATs fs_g_sector[16] |
#define U8_BPB_SecPerClus fs_g_sector[13] |
Referenced by fat_mount().
typedef struct st_fs_cluster Fs_cluster |
Structure to store cluster information.
typedef uint8_t _MEM_TYPE_SLOW_* PTR_CACHE |
bool fat_allocfreespace | ( | void | ) |
This function allocs a cluster list.
@return false in case of error, see global value "fs_g_status" for more detail @return true otherwise
//! Global variables used //! IN : //! fs_g_seg.u32_addr Last cluster value of a cluster list to link with the new cluster list //! If no cluster list to link then set MSB0(fs_g_seg.u32_addr) to 0xFF //! fs_g_seg.u32_size_or_pos Maximum size of cluster list to alloc (unit sector) //! OUT: //! fs_g_seg.u32_addr Return the first cluster value of the new cluster list //! fs_g_seg.u32_size_or_pos The number of sector remaining (no allocated sectors, because disk fragmented or disk full) //!
Referenced by fat_alloc_entry_free().
void fat_cache_clear | ( | void | ) |
This function clears the sector cache.
Referenced by fat_clean_zone(), fat_write_MBR(), and fat_write_PBR().
void fat_cache_clusterlist_reset | ( | void | ) |
This function resets the cluster list caches.
References Fs_clusterlist_cache::b_cache_file, fs_g_cache_clusterlist, fs_g_u8_current_cache, FS_NB_CACHE_CLUSLIST, Fs_clusterlist_cache::u8_level_use, and Fs_clusterlist_cache::u8_lun.
Referenced by fat_check_device(), fat_cluster_list(), and nav_reset().
bool fat_cache_flush | ( | void | ) |
This function flushes the sector cache on the memory if necessary.
References CTRL_GOOD, FS_ERR_HW, fs_g_sector, fs_g_sectorcache, fs_g_status, FS_LUN_WP, mem_wr_protect(), ram_2_memory(), Fs_sector_cache::u32_addr, Fs_sector_cache::u8_dirty, and Fs_sector_cache::u8_lun.
Referenced by fat_cache_read_sector(), fat_clean_zone(), fat_entry_label(), fat_format(), fat_serialnumber(), file_close(), file_set_eof(), nav_exit(), nav_file_create(), ushell_cmd_perform_access(), and ushell_cmd_perform_extaccess().
void fat_cache_mark_sector_as_dirty | ( | void | ) |
This function sets a flag to signal that sector cache is modified.
References fs_g_sectorcache, and Fs_sector_cache::u8_dirty.
Referenced by fat_clean_zone(), fat_cluster_val(), fat_create_long_name_entry(), fat_create_short_entry_name(), fat_delete_file(), fat_entry_label(), fat_garbage_collector_entry(), fat_initialize_fat(), fat_serialnumber(), fat_write_MBR(), fat_write_PBR(), file_putc(), and file_write_buf().
This function loads a memory sector in internal cache sector.
@param b_load true, load the cache with the memory sector corresponding <br> false, Don't change the sector cache but change the memory address of cache <br> @return false in case of error, see global value "fs_g_status" for more detail @return true otherwise
//! Global variable used //! IN : //! fs_g_nav.u8_lun drive number to read //! fs_gu32_addrsector address to read (unit sector) //!
References CTRL_GOOD, fat_cache_flush(), fat_cache_reset(), FS_ERR_HW, fs_g_nav, fs_g_sector, fs_g_sectorcache, fs_g_status, fs_gu32_addrsector, memory_2_ram(), Fs_sector_cache::u32_addr, Fs_management::u8_lun, and Fs_sector_cache::u8_lun.
Referenced by fat_clean_zone(), fat_cluster_readnext(), fat_cluster_val(), fat_getfreespace_percent(), fat_initialize_fat(), fat_mount(), fat_read_dir(), fat_read_fat32_FSInfo(), fat_read_file(), fat_serialnumber(), fat_write_MBR(), fat_write_PBR(), and file_write_buf().
void fat_cache_reset | ( | void | ) |
This function resets the sector cache.
References FS_BUF_SECTOR_EMPTY, fs_g_sectorcache, Fs_sector_cache::u32_clusterlist_start, Fs_sector_cache::u8_dirty, and Fs_sector_cache::u8_lun.
Referenced by fat_cache_read_sector(), fat_check_device(), nav_reset(), ushell_cmd_perform_access(), and ushell_cmd_perform_extaccess().
bool fat_check_device | ( | void | ) |
This function checks device state.
@return true device ready @return false otherwise
//! This function updates all navigator data when the device state change. //!
References CTRL_BUSY, CTRL_GOOD, CTRL_NO_PRESENT, fat_cache_clusterlist_reset(), fat_cache_reset(), Fat_file_close, FS_ERR_HW, FS_ERR_HW_NO_PRESENT, fs_g_nav, fs_g_nav_fast, fs_g_navext, fs_g_navext_entry, fs_g_navext_fast, fs_g_sectorcache, fs_g_status, FS_NB_NAVIGATOR, FS_TYPE_FAT_UNM, g_b_no_check_disk, mem_test_unit_ready(), Fs_management::u8_lun, Fs_sector_cache::u8_lun, Fs_management_entry::u8_open_mode, and Fs_management_fast::u8_type_fat.
Referenced by fat_check_mount(), fat_check_noopen(), fat_mount(), nav_partition_freespace(), nav_partition_freespace_percent(), nav_partition_space(), and nav_partition_type().
bool fat_check_eof_name | ( | uint16_t | character | ) |
Check end of name.
character | value of character to check |
Referenced by fat_check_name(), fat_create_short_entry_name(), and fat_entry_longname().
bool fat_check_is_file | ( | void | ) |
This function checks if the selected file entry is a file and not a directory.
References Fat_is_not_a_file, FS_ERR_NO_FILE, and fs_g_status.
Referenced by file_ispresent(), and file_open().
bool fat_check_mount | ( | void | ) |
This function checks if the partition is mounted.
References fat_check_device(), fat_mount(), FS_ERR_NO_MOUNT, fs_g_nav_fast, fs_g_status, FS_TYPE_FAT_UNM, and Fs_management_fast::u8_type_fat.
Referenced by fat_check_mount_noopen(), fat_check_mount_select(), fat_check_mount_select_noopen(), fat_check_mount_select_open(), and nav_partition_serialnumber().
bool fat_check_mount_noopen | ( | void | ) |
This function checks if the partition is mounted and no file is opened.
References fat_check_mount(), and fat_check_noopen().
Referenced by nav_dir_gotoparent(), nav_dir_is_root(), nav_dir_name(), nav_filelist_reset(), nav_filelist_set(), and nav_getcwd().
bool fat_check_mount_select | ( | void | ) |
This function checks if the partition is mounted and if a file is selected.
References fat_check_mount(), and fat_check_select().
Referenced by file_ispresent(), nav_file_checkext(), nav_file_dateget(), nav_file_isreadonly(), and nav_file_name().
bool fat_check_mount_select_noopen | ( | void | ) |
This function checks if the partition is mounted and if no file is opened and a file is selected.
References fat_check_mount(), fat_check_noopen(), and fat_check_select().
Referenced by file_open(), nav_dir_cd(), and nav_filelist_validpos().
bool fat_check_mount_select_open | ( | void | ) |
This function checks if the partition is mounted and if a file is opened.
References fat_check_mount(), fat_check_open(), and fat_check_select().
Referenced by file_bof(), file_close(), file_eof(), file_getpos(), file_putc(), file_read(), file_read_buf(), file_seek(), file_set_eof(), and file_write_buf().
bool fat_check_nav_access_disk | ( | void | ) |
This function checks write access.
This function checks all access at current file.
mode | true, check to write access false, check to read access |
References FOPEN_WRITE_ACCESS, FS_ERR_FILE_OPEN, FS_ERR_FILE_OPEN_WR, fs_g_nav, fs_g_nav_fast, fs_g_navext, fs_g_navext_entry, fs_g_navext_fast, fs_g_status, FS_NB_NAVIGATOR, FS_TYPE_FAT_UNM, Fs_management_fast::u16_entry_pos_sel_file, Fs_management::u32_cluster_sel_dir, and Fs_management::u8_lun.
Referenced by file_open().
bool fat_check_noopen | ( | void | ) |
This function checks if a file is not opened on current navigator.
References fat_check_device(), Fat_file_is_open, FS_ERR_TOO_FILE_OPEN, fs_g_nav_fast, fs_g_status, FS_TYPE_FAT_UNM, and Fs_management_fast::u8_type_fat.
Referenced by fat_check_mount_noopen(), fat_check_mount_select_noopen(), nav_drive_set(), nav_filelist_fileisnotopen(), nav_partition_mount(), and nav_setcwd().
bool fat_check_open | ( | void | ) |
This function checks if a file is opened on current navigator.
References Fat_file_isnot_open, FS_ERR_FILE_NO_OPEN, and fs_g_status.
Referenced by fat_check_mount_select_open().
bool fat_check_select | ( | void | ) |
This function checks if a file is selected on current navigator.
References FS_ERR_NO_FILE_SEL, fs_g_nav_fast, fs_g_status, FS_NO_SEL, and Fs_management_fast::u16_entry_pos_sel_file.
Referenced by fat_check_mount_select(), fat_check_mount_select_noopen(), fat_check_mount_select_open(), and nav_getcwd().
uint8_t fat_checkcluster | ( | void | ) |
This function checks the cluster value.
@return value status <br> FS_CLUS_OK Value correct <br> FS_CLUS_BAD Value bad <br> FS_CLUS_END It is a end of list <br>
//! Global variable used //! IN : //! fs_g_cluster.u32_val value to check //!
References FS_CLUS_BAD, FS_CLUS_END, FS_CLUS_OK, fs_g_cluster, Is_fat12, Is_fat16, Is_fat32, and st_fs_cluster::u32_val.
Referenced by fat_cluster_list().
bool fat_clear_cluster | ( | void | ) |
This function clears one cluster.
@return false in case of error, see global value "fs_g_status" for more detail @return true otherwise
//! Global variables used //! IN : //! fs_g_seg.u32_addr Cluster value to clear //!
Referenced by fat_alloc_entry_free().
void fat_clear_entry_info_and_ptr | ( | void | ) |
This function resets the selection pointers.
References Fs_management::b_mode_nav, Fs_management::b_mode_nav_single, Fat_file_close, FS_DIR, fs_g_nav, fs_g_nav_entry, fs_g_nav_fast, FS_NO_SEL, Fs_management_fast::u16_entry_pos_sel_file, Fs_management::u16_pos_sel_file, Fs_management_entry::u32_cluster, Fs_management_entry::u32_size, and Fs_management_entry::u8_attr.
Referenced by fat_mount(), nav_filelist_reset(), and nav_partition_mount().
void fat_clear_info_fat_mod | ( | void | ) |
This function clears the cache information about FAT modifications.
Referenced by fat_cluster_list().
This function gets or clears a cluster list.
@param b_for_file If true then it is a file cluster list else a directory cluster list <br> @param opt_action Choose action on the cluster list <br> FS_CLUST_ACT_SEG Get continue memory segment corresponding at cluster list <br> FS_CLUST_ACT_ONE Get only one memory sector (512B) corresponding at cluster list <br> FS_CLUST_ACT_CLR Clear the cluster list <br> @return false in case of error, see global value "fs_g_status" for more detail @return true otherwise
//! Global variables used //! IN : //! fs_g_seg.u32_addr The first cluster of the cluster list //! fs_g_seg.u32_size_or_pos Start position in the cluster list (unit 512B) //! OUT: //! fs_g_seg.u32_addr The memory segment address corresponding at the beginning of cluster list (only for action FS_CLUST_ACT_SEG & FS_CLUST_ACT_ONE) //! fs_g_seg.u32_size_or_pos The memory segment size corresponding at cluster list read or cleared (unit 512B) //!
References _MEM_TYPE_FAST_, fat_cache_clusterlist_reset(), fat_cache_clusterlist_update_finish(), fat_cache_clusterlist_update_read(), fat_checkcluster(), fat_clear_info_fat_mod(), fat_cluster_readnext(), fat_cluster_val(), fat_update_fat2(), fat_write_fat32_FSInfo(), FS_CLUS_BAD, FS_CLUS_END, FS_CLUST_ACT_CLR, FS_CLUST_ACT_ONE, FS_CLUST_ACT_SEG, FS_CLUST_VAL_EOL, FS_CLUST_VAL_READ, FS_CLUST_VAL_WRITE, FS_ERR_FS, FS_ERR_OUT_LIST, fs_g_cache_clusterlist, fs_g_cluster, fs_g_nav, fs_g_seg, fs_g_status, fs_g_u8_current_cache, Is_fat12, Is_fat16, Is_fat32, LSB0, MSB0, Fs_management::rootdir, Fs_rootdir::seg, Fs_rootdir::u16_pos, Fs_rootdir::u16_size, Fs_segment::u32_addr, Fs_rootdir::u32_cluster, Fs_management::u32_offset_data, st_fs_cluster::u32_pos, Fs_management::u32_ptr_fat, Fs_segment::u32_size_or_pos, Fs_clusterlist_cache::u32_start, st_fs_cluster::u32_val, and Fs_management::u8_BPB_SecPerClus.
Referenced by fat_read_dir(), and fat_read_file().
bool fat_cluster_readnext | ( | void | ) |
This function is optimized to read a continue cluster list on FAT16 and FAT32.
Read global value "fs_g_status" in case of error : FS_ERR_HW Hardware driver error FS_LUN_WP Drive is read only @return false in case of error, see global value "fs_g_status" for more detail @return true otherwise
//! Global variables used //! IN : //! fs_g_u16_pos_fat previous cluster position in FAT //! OUT: //! fs_g_u16_pos_fat read cluster position in FAT //! fs_g_cluster.u32_val value of cluster read //!
References fat_cache_read_sector(), FS_CACHE_SIZE, fs_g_cluster, fs_g_sector, fs_gu32_addrsector, Is_fat32, LSB0, LSB1, LSB2, LSB3, and st_fs_cluster::u32_val.
Referenced by fat_cluster_list(), and fat_getfreespace().
This function returns or modifies a cluster value in FAT.
@param b_mode false, to read a cluster value <br> true, to write a cluster value @return false in case of error, see global value "fs_g_status" for more detail @return true otherwise
//! Global variables used //! IN : //! fs_g_cluster.u32_pos cluster number to read or write //! fs_g_cluster.u32_val value to write //! OUT: //! fs_g_cluster.u32_val value ready //! fs_g_u16_pos_fat position in FAT of the cluster to read or write //! value init in case of the fat_cluster_readnext() routine is used after //!
References _MEM_TYPE_FAST_, fat_cache_mark_sector_as_dirty(), fat_cache_read_sector(), FS_CACHE_SIZE, FS_ERR_COMMAND, fs_g_cluster, fs_g_nav, fs_g_sector, fs_g_status, fs_g_u16_pos_fat, fs_g_u32_first_mod_fat, fs_g_u32_last_mod_fat, fs_gu32_addrsector, Is_fat12, Is_fat16, Is_fat32, LSB0, LSB1, LSB2, LSB3, MSB, st_fs_cluster::u32_pos, Fs_management::u32_ptr_fat, and st_fs_cluster::u32_val.
Referenced by fat_cluster_list(), fat_getfreespace(), and fat_getfreespace_percent().
void fat_copy_nav | ( | uint8_t | u8_idnav | ) |
This function copies the main navigator to another navigator.
u8_idnav | Id navigator to fill |
References fs_g_nav, fs_g_nav_entry, fs_g_nav_fast, fs_g_navext, fs_g_navext_entry, fs_g_navext_fast, memcpy_ram2ram, and Fs_management_entry::u8_open_mode.
Referenced by nav_copy().
This function creates the short and the long name of a new entry.
@param sz_name name to create (ASCII or UNICODE) @return false in case of error, see global value "fs_g_status" for more detail @return true otherwise
//! IN: //! b_unicode is a global flag to select UNICODE or ASCII //! The name must be terminated by NULL and it can't have two dot characters. //!
Referenced by nav_file_create().
This function deletes the file entries and cluster list.
b_cluster_list | true, delete file entries and cluster list false, delete only file entries |
References fat_cache_mark_sector_as_dirty(), fat_get_ptr_entry(), fat_read_dir(), fat_read_file(), FS_ATTR_LFN_ENTRY, FS_CLUST_ACT_CLR, FS_ENTRY_DEL, FS_ENTRY_LFN_LAST, fs_g_nav_entry, fs_g_nav_fast, Fs_management_fast::u16_entry_pos_sel_file, and Fs_management_entry::u32_pos_in_file.
This function checks the entry.
@param b_type entry type to compare (FS_FILE or FS_DIR) @return true, the entry is a short entry and correspond to b_type @return false, otherwise
//! Global variable used //! IN : //! fs_g_sector The directory sector corresponding at the current position //! fs_g_nav_fast.u16_entry_pos_sel_file Position in directory of the entry file (unit entry) //!
References fat_get_ptr_entry(), FS_ATTR_DIRECTORY, FS_ATTR_VOLUME_ID, FS_DIR, FS_ENTRY_DEL, FS_ENTRY_END, FS_ERR_ENTRY_BAD, FS_ERR_ENTRY_EMPTY, FS_FILE, and fs_g_status.
Referenced by nav_filelist_set().
This function checks the file extension.
@param sz_filter extension filter is a ASCII string (ex: "mp3,w*" ) @return true, the file name have a good extension @return false, otherwise
//! Global variable used //! IN : //! fs_g_sector The directory sector corresponding at the current position //! fs_g_nav_fast.u16_entry_pos_sel_file Position in directory of the entry file (unit entry) //!
References fat_get_ptr_entry().
Referenced by nav_file_checkext().
bool fat_entry_is_dir | ( | void | ) |
This function checks if the entry file is a directory.
References FS_ATTR_DIRECTORY, FS_ERR_NO_DIR, fs_g_nav_entry, fs_g_status, and Fs_management_entry::u8_attr.
Referenced by nav_dir_cd(), nav_file_isdir(), and nav_setcwd().
This function reads or writes a label in the partition.
b_action | choose action (FS_LABEL_READ or FS_LABEL_WRITE) |
sz_label | string ASCII to store label (11B min) or to get new label (11B max) |
References fat_cache_flush(), fat_cache_mark_sector_as_dirty(), fat_get_ptr_entry(), FS_ATTR_VOLUME_ID, FS_ENTRY_END, FS_ERR_ENTRY_BAD, FS_ERR_ENTRY_EMPTY, FS_ERR_NAME_INCORRECT, fs_g_status, FS_LABEL_READ, and FS_LABEL_WRITE.
Referenced by nav_partition_label().
This function returns or compares the long name entry.
@param b_mode action mode: <br> FS_NAME_GET to get the long name of selected file <br> FS_NAME_CHECK to compare the long name of selected file <br> @param sz_name if FS_NAME_GET then buffer to store the long name file (ASCII or UNICODE ) <br> if FS_NAME_CHECK then name to compare with long name (ASCII or UNICODE), it must be terminate by NULL or '*' value <br> @param b_match_case false, ignore the case (only used in "FS_NAME_CHECK" action mode) @param u8_size_max buffer size (unit ASCII or UNICODE ) (ignored in "FS_NAME_CHECK" mode) @return false is not the end of long name, or in case of error, see global value "fs_g_status" for more detail @return true, the name is correct or read is finish
//! Global variable used //! IN : //! fs_g_sector The directory sector corresponding at the current position //! fs_g_nav_fast.u16_entry_pos_sel_file Position in directory of the entry file (unit entry) //!
References fat_check_eof_name(), fat_get_ptr_entry(), FS_ATTR_LFN_ENTRY, FS_ENTRY_DEL, FS_ENTRY_END, FS_ENTRY_LFN_LAST, FS_ERR_ENTRY_BAD, FS_ERR_NAME_INCORRECT, fs_g_status, FS_NAME_GET, FS_NO_LAST_LFN_ENTRY, FS_SIZE_FILE_ENTRY, g_b_string_length, Is_unicode, LSB, and MSB.
Referenced by nav_file_name().
This function returns or compares the short name entry.
@param b_mode action mode: <br> FS_NAME_GET to get the short name of selected file <br> FS_NAME_CHECK to compare the short name of selected file <br> @param sz_name if FS_NAME_GET then buffer to store the short name file (ASCII or UNICODE ) <br> if FS_NAME_CHECK then name to compare with short name (ASCII or UNICODE), it must be terminate by NULL or '*' value <br> @param u8_size_max buffer size (unit ASCII or UNICODE ) (ignored in "FS_NAME_CHECK" mode) @return false, in case of error, see global value "fs_g_status" for more detail @return true, the name is correct or read OK
//! Global variable used //! IN : //! fs_g_sector The directory sector corresponding at the current position //! fs_g_nav_fast.u16_entry_pos_sel_file Position in directory of the entry file (unit entry) //!
References fat_get_ptr_entry(), FS_ERR_NAME_INCORRECT, fs_g_status, FS_NAME_GET, FS_SIZE_SFNAME, FS_SIZE_SFNAME_WITHOUT_EXT, g_b_string_length, Is_unicode, and MSB.
Referenced by nav_file_name().
bool fat_format | ( | uint8_t | u8_fat_type | ) |
This function formats the drive.
This function formats the drive.
@param u8_fat_type Select the type of format <br> FS_FORMAT_DEFAULT, The file system module choose 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> FS_FORMAT_NOMBR_FLAG if you don't want a MRB in disk then add this flag (e.g. FAT format on a CD support) @return false in case of error, see global value "fs_g_status" for more detail @return true otherwise
//! Global variables used //! IN : //! fs_g_nav.u8_lun indicate the drive to format //! //! This routine can't format a multi-partiton, if the disk contains a multi-partition area //! then the multi-partition will be erased and replaced by a single partition on all disk space. //!
References fat_cache_flush(), fat_clean_zone(), fat_initialize_fat(), fat_select_filesystem(), fat_write_MBR(), fat_write_PBR(), FS_FORMAT_NOMBR_FLAG, fs_g_nav, fs_s_u32_size_partition, mem_read_capacity(), and Fs_management::u8_lun.
This function reads the information about a date.
type_date | choose the date type (FS_DATE_LAST_WRITE or FS_DATE_CREATION) |
sz_date | table to store the date storage format (ASCII) = "YYYYMMDDHHMMSSMS" = year, month, day, hour, minute, second, millisecond |
References fat_get_ptr_entry(), fat_translatedate_number_to_ascii(), and FS_DATE_LAST_WRITE.
Referenced by nav_file_dateget().
void fat_get_entry_info | ( | void | ) |
This function reads information about selected file.
//! Global variable used //! IN : //! fs_g_sector The directory sector corresponding at the current position //! fs_g_nav_fast.u16_entry_pos_sel_file Position in directory of the entry file (unit entry) //! OUT: //! fs_g_nav_entry. u32_cluster, u8_attr, u32_size //!
References fat_get_ptr_entry(), fs_g_nav_entry, LSB0, LSB1, LSB2, LSB3, Fs_management_entry::u32_cluster, Fs_management_entry::u32_size, and Fs_management_entry::u8_attr.
Referenced by nav_dir_gotoparent(), and nav_filelist_set().
uint8_t fat_get_nbpartition | ( | void | ) |
This function returns the number of partition present on selected drive.
PTR_CACHE fat_get_ptr_entry | ( | void | ) |
This function returns a cache pointer on the current entry.
References FS_512B_MASK, fs_g_nav_fast, fs_g_sector, FS_SIZE_FILE_ENTRY, and Fs_management_fast::u16_entry_pos_sel_file.
Referenced by fat_alloc_entry_free(), fat_create_long_name_entry(), fat_create_short_entry_name(), fat_delete_file(), fat_entry_check(), fat_entry_checkext(), fat_entry_label(), fat_entry_longname(), fat_entry_shortname(), fat_entry_shortname_compare(), fat_garbage_collector_entry(), fat_get_date(), and fat_get_entry_info().
uint32_t fat_getfreespace | ( | void | ) |
This function returns the space free in the partition.
References fat_cluster_readnext(), fat_cluster_val(), fat_read_fat32_FSInfo(), fat_write_fat32_FSInfo(), FS_CLUST_VAL_READ, fs_g_cluster, fs_g_nav, Is_fat12, Is_fat32, Fs_management::u32_CountofCluster, st_fs_cluster::u32_pos, st_fs_cluster::u32_val, and Fs_management::u8_BPB_SecPerClus.
Referenced by fat_getfreespace_percent(), and nav_partition_freespace().
uint8_t fat_getfreespace_percent | ( | void | ) |
This function returns the space free in percent.
@return percent of free space (1 to 100) if 0, then error or full
//! More speed than fat_getfreespace() routine but error delta 1% //!
References fat_cache_read_sector(), fat_cluster_val(), fat_getfreespace(), fat_read_fat32_FSInfo(), FS_CLUST_VAL_READ, fs_g_cluster, fs_g_nav, fs_g_sector, fs_gu32_addrsector, Is_fat12, Is_fat16, Is_fat32, Fs_management::u32_CountofCluster, Fs_management::u32_fat_size, st_fs_cluster::u32_pos, and Fs_management::u8_BPB_SecPerClus.
Referenced by nav_partition_freespace_percent().
bool fat_initialize_dir | ( | void | ) |
This function writes the directory information.
@return false in case of error, see global value "fs_g_status" for more detail @return true otherwise
//! Global variables used //! IN : //! fs_g_seg.u32_addr cluster value of a directory //! OUT: //! update the sector cache with init directory data //!
void fat_invert_nav | ( | uint8_t | u8_idnav | ) |
This function inverts the current navigation with another.
u8_idnav | Id navigator to invert |
References _MEM_TYPE_SLOW_, fs_g_nav, fs_g_nav_entry, fs_g_nav_fast, fs_g_navext, fs_g_navext_entry, fs_g_navext_fast, Max, and memcpy_ram2ram.
Referenced by nav_select().
bool fat_mount | ( | void | ) |
This function mounts a partition.
This function mounts a partition.
@return false in case of error, see global value "fs_g_status" for more detail @return true otherwise
//! Global variables used //! IN : //! fs_g_nav.u8_lun Indicate the drive to mount //! fs_g_nav.u8_partition Indicate the partition to mount (if FS_MULTI_PARTITION = true ) //! OUT: //! fs_g_nav update structure //! If the FS_MULTI_PARTITION option is disabled //! then the mount routine selects the first partition supported by file system. <br> //!
References fat_cache_read_sector(), fat_check_device(), fat_clear_entry_info_and_ptr(), FS_512B, FS_BR_SIGNATURE_HIGH, FS_BR_SIGNATURE_LOW, FS_ERR_NO_FORMAT, FS_ERR_NO_PART, FS_ERR_NO_SUPPORT_PART, FS_FAT12_MAX_CLUSTERS, FS_FAT16_MAX_CLUSTERS, fs_g_nav, fs_g_nav_fast, fs_g_sector, fs_g_status, fs_gu32_addrsector, FS_MBR_OFFSET_PART_ENTRY, FS_NB_FAT, FS_PART_BOOTABLE, FS_PART_NO_BOOTABLE, FS_PART_TYPE_FAT12, FS_PART_TYPE_FAT16_INF32M, FS_PART_TYPE_FAT16_SUP32M, FS_PART_TYPE_FAT16_SUP32M_BIS, FS_PART_TYPE_FAT32, FS_PART_TYPE_FAT32_BIS, FS_SIZE_FILE_ENTRY, FS_TYPE_FAT_12, FS_TYPE_FAT_16, FS_TYPE_FAT_32, FS_TYPE_FAT_UNM, HIGH_16_BPB_BytsPerSec, HIGH_16_BPB_FATSz16, HIGH_16_BPB_ResvSecCnt, HIGH_16_BPB_RootEntCnt, HIGH_16_BPB_TotSec16, LOW0_32_BPB_FATSz32, LOW0_32_BPB_RootClus, LOW0_32_BPB_TotSec32, LOW1_32_BPB_FATSz32, LOW1_32_BPB_RootClus, LOW1_32_BPB_TotSec32, LOW2_32_BPB_FATSz32, LOW2_32_BPB_RootClus, LOW2_32_BPB_TotSec32, LOW3_32_BPB_FATSz32, LOW3_32_BPB_RootClus, LOW3_32_BPB_TotSec32, LOW_16_BPB_FATSz16, LOW_16_BPB_FSInfo, LOW_16_BPB_ResvSecCnt, LOW_16_BPB_RootEntCnt, LOW_16_BPB_TotSec16, LSB, LSB0, LSB1, LSB2, LSB3, mem_sector_size(), MSB, Fs_management::rootdir, Fs_rootdir::seg, Fs_management::u16_offset_FSInfo, Fs_rootdir::u16_pos, Fs_rootdir::u16_size, Fs_rootdir::u32_cluster, Fs_management::u32_cluster_sel_dir, Fs_management::u32_CountofCluster, Fs_management::u32_fat_size, Fs_management::u32_offset_data, Fs_management::u32_ptr_fat, U8_BPB_SecPerClus, Fs_management::u8_BPB_SecPerClus, Fs_management::u8_lun, and Fs_management_fast::u8_type_fat.
Referenced by fat_check_mount(), and nav_partition_mount().
bool fat_read_dir | ( | void | ) |
This function fill the internal cache with a sector from current directory.
@return false in case of error, see global value "fs_g_status" for more detail @return true otherwise
//! Global variable used //! IN : //! fs_g_nav.u32_cluster_sel_dir First cluster of current directory //! fs_g_nav_fast.u16_entry_pos_sel_file Position in directory (unit entry) //!
References fat_cache_read_sector(), fat_cluster_list(), FS_512B_SHIFT_BIT, FS_CLUST_ACT_ONE, fs_g_nav, fs_g_nav_fast, fs_g_sectorcache, fs_g_seg, fs_gu32_addrsector, FS_SHIFT_B_TO_FILE_ENTRY, Fs_management_fast::u16_entry_pos_sel_file, Fs_segment::u32_addr, Fs_management::u32_cluster_sel_dir, Fs_sector_cache::u32_clusterlist_pos, Fs_sector_cache::u32_clusterlist_start, Fs_segment::u32_size_or_pos, Fs_management::u8_lun, and Fs_sector_cache::u8_lun.
Referenced by fat_alloc_entry_free(), fat_delete_file(), fat_find_short_entry_name(), fat_garbage_collector_entry(), file_close(), nav_dir_gotoparent(), nav_file_checkext(), nav_file_dateget(), nav_file_name(), nav_filelist_set(), and nav_partition_label().
uint32_t fat_read_fat32_FSInfo | ( | void | ) |
This function returns the space free in the selected FAT32 partition.
References const_FSI_LeadSig, const_FSI_StrucSig, fat_cache_read_sector(), FS_BR_SIGNATURE_HIGH, FS_BR_SIGNATURE_LOW, fs_g_nav, fs_g_sector, fs_gu32_addrsector, LSB0, LSB1, LSB2, LSB3, memcmp_code2ram, Fs_management::u16_offset_FSInfo, and Fs_management::u32_ptr_fat.
Referenced by fat_getfreespace(), and fat_getfreespace_percent().
bool fat_read_file | ( | uint8_t | mode | ) |
This function gets or clears a cluster list at the current position in the selected file.
@param mode Choose action <br> FS_CLUST_ACT_SEG Get memory segment corresponding at the position in selected file <br> FS_CLUST_ACT_ONE Store in internal cache the sector corresponding at the position in selected file <br> FS_CLUST_ACT_CLR Clear the cluster list corresponding at the position in selected file <br> @return false in case of error, see global value "fs_g_status" for more detail @return true otherwise
//! Global variable used //! IN : //! fs_g_nav_entry.u32_cluster First cluster of selected file //! fs_g_nav_entry.u32_pos_in_file Position in file (unit byte) //!
References fat_cache_read_sector(), fat_cluster_list(), FS_512B_MASK, FS_512B_SHIFT_BIT, FS_CLUST_ACT_CLR, FS_CLUST_ACT_ONE, FS_CLUST_ACT_SEG, FS_ERR_OUT_LIST, fs_g_nav, fs_g_nav_entry, fs_g_sectorcache, fs_g_seg, fs_g_status, fs_gu32_addrsector, Fs_segment::u32_addr, Fs_management_entry::u32_cluster, Fs_sector_cache::u32_clusterlist_pos, Fs_sector_cache::u32_clusterlist_start, Fs_management_entry::u32_pos_in_file, Fs_segment::u32_size_or_pos, Fs_management::u8_lun, and Fs_sector_cache::u8_lun.
Referenced by fat_delete_file(), file_getc(), file_read(), file_read_buf(), and file_set_eof().
bool fat_serialnumber | ( | bool | b_action, |
uint8_t _MEM_TYPE_SLOW_ * | a_u8_sn | ||
) |
This function reads or writes a serial number.
This function reads or writes a serial number.
b_action | choose action (FS_SN_READ or FS_SN_WRITE) |
a_u8_sn | array to store or get the serial number (uint8_t[4]) |
References fat_cache_flush(), fat_cache_mark_sector_as_dirty(), fat_cache_read_sector(), fs_g_nav, fs_g_sector, fs_gu32_addrsector, FS_SN_READ, Is_fat12, Is_fat16, and Fs_management::u32_ptr_fat.
Referenced by nav_partition_serialnumber().
This function changes the date information.
@param type_date choose date field (FS_DATE_LAST_WRITE or FS_DATE_CREATION) @param sz_date table with date information <br> storage format (ASCII) = "YYYYMMDDHHMMSSMS" = year, month, day, hour, minute, second, millisecond
//! OUT, update cache sector with the new date //!
bool fat_update_fat2 | ( | void | ) |
This function copies the modifications of the first FAT to the second FAT.
Referenced by fat_cluster_list().
void fat_write_entry_file | ( | void | ) |
This function writes the information about selected file.
//! Global variable used //! IN : //! fs_g_sector The directory sector corresponding at the current position //! fs_g_nav_fast.u16_entry_pos_sel_file Position in directory of the entry file (unit entry) //! OUT: //! fs_g_sector Updated //!
Write the Attribute
Write the size of file
Referenced by file_close().
bool fat_write_fat32_FSInfo | ( | uint32_t | u32_nb_free_cluster | ) |
This function writes the space free number in selected FAT32 partition.
Read global value "fs_g_status" in case of error : FS_ERR_HW Hardware driver error FS_ERR_HW_NO_PRESENT Device not present FS_LUN_WP Drive is read only
Referenced by fat_cluster_list(), fat_getfreespace(), and fat_write_PBR().
bool fat_write_file | ( | uint8_t | mode, |
uint32_t | u32_nb_sector_write | ||
) |
This function gets and eventually allocs a cluster list at the current position in the selected file.
@param mode Choose action <br> FS_CLUST_ACT_SEG Get and eventually alloc a cluster list <br> FS_CLUST_ACT_ONE Get and eventually alloc a cluster list for one sector, and load this sector in internal cache <br> @param u32_nb_sector_write maximum number of sector to get and eventually to alloc for the selected file (ignored if mode = FS_CLUST_ACT_ONE) @return false in case of error, see global value "fs_g_status" for more detail @return true otherwise
//! Global variable used //! IN : //! fs_g_nav_entry.u32_cluster First cluster of selected file //! fs_g_nav_entry.u32_pos_in_file Position in the file (unit byte) //!
Referenced by file_putc(), and file_write_buf().
_GLOBEXT_ _MEM_TYPE_FAST_ Fs_cluster fs_g_cluster |
To take time in functions: fat_getfreespace, fat_cluster_list, fat_cluster_val, fat_checkcluster.
Referenced by fat_cache_clusterlist_update_read(), fat_cache_clusterlist_update_start(), fat_checkcluster(), fat_cluster_list(), fat_cluster_readnext(), fat_cluster_val(), fat_getfreespace(), and fat_getfreespace_percent().
_GLOBEXT_ _MEM_TYPE_SLOW_ Fs_management fs_g_nav |
Referenced by fat_cache_clusterlist_update_finish(), fat_cache_clusterlist_update_read(), fat_cache_read_sector(), fat_check_device(), fat_check_nav_access_file(), fat_clean_zone(), fat_clear_entry_info_and_ptr(), fat_cluster_list(), fat_cluster_val(), fat_copy_nav(), fat_format(), fat_getfreespace(), fat_getfreespace_percent(), fat_initialize_fat(), fat_invert_nav(), fat_mount(), fat_read_dir(), fat_read_fat32_FSInfo(), fat_read_file(), fat_select_filesystem(), fat_serialnumber(), fat_write_PBR(), file_load_segment_value(), file_open(), file_read(), file_read_buf(), file_write_buf(), nav_dir_cd(), nav_dir_gotoparent(), nav_dir_is_root(), nav_dir_name(), nav_drive_get(), nav_drive_getname(), nav_drive_set(), nav_file_create(), nav_file_isreadonly(), nav_filelist_eol(), nav_filelist_exist(), nav_filelist_first(), nav_filelist_get(), nav_filelist_nb(), nav_filelist_set(), nav_filelist_single_disable(), nav_filelist_single_enable(), nav_getindex(), nav_gotoindex(), nav_partition_cluster_size(), nav_partition_mount(), nav_partition_space(), and nav_reset().
_GLOBEXT_ _MEM_TYPE_SLOW_ Fs_management_entry fs_g_nav_entry |
Referenced by fat_clear_entry_info_and_ptr(), fat_copy_nav(), fat_delete_file(), fat_entry_is_dir(), fat_get_entry_info(), fat_invert_nav(), fat_read_file(), file_bof(), file_close(), file_eof(), file_flush(), file_getc(), file_getpos(), file_open(), file_putc(), file_read(), file_read_buf(), file_seek(), file_set_eof(), file_write_buf(), nav_dir_cd(), nav_dir_gotoparent(), nav_dir_name(), nav_file_attributget(), nav_file_create(), nav_file_isreadonly(), nav_file_lgt(), and nav_file_lgtsector().
_GLOBEXT_ _MEM_TYPE_FAST_ Fs_management_fast fs_g_nav_fast |
Referenced by fat_alloc_entry_free(), fat_check_device(), fat_check_mount(), fat_check_nav_access_file(), fat_check_noopen(), fat_check_select(), fat_clear_entry_info_and_ptr(), fat_copy_nav(), fat_delete_file(), fat_find_short_entry_name(), fat_garbage_collector_entry(), fat_get_ptr_entry(), fat_invert_nav(), fat_mount(), fat_read_dir(), fat_select_filesystem(), nav_dir_cd(), nav_dir_gotoparent(), nav_dir_name(), nav_drive_set(), nav_file_name(), nav_filelist_eol(), nav_filelist_set(), nav_getindex(), nav_gotoindex(), nav_partition_freespace(), nav_partition_freespace_percent(), nav_partition_label(), nav_partition_mount(), nav_partition_space(), nav_partition_type(), and nav_reset().
_GLOBEXT_ _MEM_TYPE_SLOW_ uint8_t fs_g_sector[FS_CACHE_SIZE] |
Use "FAT sector cache" to store a sector from a file (see file_putc(), file_getc(), file_read_buf(), file_write_buf())
Referenced by fat_cache_flush(), fat_cache_read_sector(), fat_clean_zone(), fat_cluster_readnext(), fat_cluster_val(), fat_get_ptr_entry(), fat_getfreespace_percent(), fat_initialize_fat(), fat_mount(), fat_read_fat32_FSInfo(), fat_serialnumber(), fat_write_MBR(), fat_write_PBR(), and ushell_cmd_perform_access().
_GLOBEXT_ _MEM_TYPE_SLOW_ Fs_sector_cache fs_g_sectorcache |
_GLOBEXT_ _MEM_TYPE_FAST_ Fs_segment fs_g_seg |
Variable frequently used by many function (optimization, no parameter in function)
Referenced by fat_alloc_entry_free(), fat_cache_clusterlist_update_finish(), fat_cache_clusterlist_update_read(), fat_cache_clusterlist_update_start(), fat_cluster_list(), fat_read_dir(), fat_read_file(), file_load_segment_value(), file_read(), file_read_buf(), and file_write_buf().
_GLOBEXT_ _MEM_TYPE_SLOW_ uint32_t fs_g_u32_first_mod_fat |
Offset (unit 512B) in fat of the first sector (unit 512B)
Referenced by fat_cluster_val().
_GLOBEXT_ _MEM_TYPE_SLOW_ uint32_t fs_g_u32_last_mod_fat |
Offset (unit 512B) in fat of the last sector (unit 512B)
Referenced by fat_cluster_val().
_GLOBEXT_ _MEM_TYPE_SLOW_ uint32_t fs_gu32_addrsector |
Store the address of future cache (unit 512B)
Referenced by fat_cache_read_sector(), fat_clean_zone(), fat_cluster_readnext(), fat_cluster_val(), fat_getfreespace_percent(), fat_initialize_fat(), fat_mount(), fat_read_dir(), fat_read_fat32_FSInfo(), fat_read_file(), fat_serialnumber(), fat_write_MBR(), fat_write_PBR(), and file_write_buf().
Variables to enable/disable the disk check before each action on disk.
Referenced by fat_check_device(), nav_checkdisk_disable(), nav_checkdisk_enable(), and nav_reset().
Variables to select LENGTH string mode (initialised in nav_reset())
Referenced by fat_entry_longname(), fat_entry_shortname(), nav_dir_name(), nav_file_name(), nav_getcwd(), nav_reset(), nav_string_length_disable(), and nav_string_length_enable().
Variables to select string format (initialised in nav_reset())
Referenced by nav_reset().