#include <sw_types.h>#include <fat32.h>#include <sw_mem_functions.h>#include <sw_buddy.h>#include <sw_debug.h>#include <sw_string_functions.h>Functions | |
| int | mount_file_system (u8 *dev) |
| Mount the FAT file system and retrieve its basic information. More... | |
| bool | chk_fat32_file_system (u8 *file_sys_type) |
| Verify the type of FAT file system. More... | |
| void | cal_region_offsets (boot_sector *bs, u8 *dev) |
| Function to calculate all the region offsets. More... | |
| int | file_open (const char *file_path, int flags) |
| Function to open a specific file mentioned in the path based on the incoming modes. More... | |
| bool | get_dir_entry (char *fname, dir_entry **entry, u8 *strt, u32 strt_clus, bool is_lfn) |
| Function to check whether a given file name exists in the file system and if so retrieve the corresponding short file name directory entry. More... | |
| int | get_long_file_name (char *fname, u8 **dir_strt, int *count) |
| Function to retrieve the long file name given its end of the long file name entry. More... | |
| int | lfn_entry_to_name (lfn_entry *entry, char *lfname, int *index) |
| Function to get the long file name correspoding to a directory slot. More... | |
| int | retrieve_file_info (file_info *finfo, dir_entry *entry, u8 mode, u8 *dir_offset, const char *path) |
| Function to assign a file descriptor and necessary information to a file structure inorder to pursue subsequent operations. More... | |
| int | file_read (int fd, char *buffer, int bytes_to_read) |
| Function to read the contents of a file. More... | |
| int | file_write (int fd, const char *buffer, int bytes_to_write) |
| Function to write into the given file with the contents given. More... | |
| int | file_close (int fd) |
| Close the opened file based on the file descriptor and free the file structure pointer. More... | |
| int | create_file (char *lfname, char *shrt_name, u32 clus, dir_entry **entry) |
| Function to create a file if the file doesnt exists and the create flag is set. More... | |
| void | fill_lng_fname_entries (char *fname, u8 *entry, u8 chk_sum, int count) |
| Function to put the long file name entries into the respective allocated region. More... | |
| int | file_seek (int fd, int offset, int whence) |
| Function to seek the opened file pointer to the desired location so that subsequent read and write operations are performed from the new value. More... | |
| int | file_rename (const char *old, const char *new) |
| Function to rename a file/directory. More... | |
| int | create_dir (const char *path) |
| Function to create a directory. More... | |
| int | open_dir (const char *path) |
| Function to open a directory. More... | |
| int | list_dir (const char *path) |
| Function to list the directory contents. More... | |
| file_stat * | read_dir (int fd) |
| u32 | allocate_cluster () |
| Function to find an unused cluster from the FAT table. More... | |
| u8 * | cluster_to_memory_addr (u32 cluster) |
| Function to get the corresponding physical address from the given cluster. More... | |
| u32 | get_fat_table_entry (u32 cluster) |
| Function to retrieve the next cluster value in a cluster chain from the FAT table. More... | |
| void | write_fat_table (u32 cluster, u32 value) |
| Function to write into the FAT table after assigning an empty cluster to a file. More... | |
| void | convert_to_uppercase (char *file_name) |
| Function to convert the incoming short file name to its corresponding upper case letters. More... | |
| int | find_depth (const char *file_path) |
| Function to calculate the number of iterations needed to reach the file from the given starting path. More... | |
| int | get_seek_off (file_info *file_ptr, u32 strt_cluster, int offset) |
| Function to move the current cluster and its offset value to the value specified in the offset from the starting cluster provided. More... | |
| void | get_short_file_name (char *lfname, char *sfname, char seq_num) |
| Function to extract the short file name given its long file name. More... | |
| int | chk_file_lock (const char *path) |
| u8 | calc_check_sum (u8 *dir_entry) |
| Function to calculate the checksum for the long file name based on its short name entry. More... | |
| int | cal_req_dir_cnt (int file_name_len) |
| int | file_truncate (const char *tr_pf, int tr_lgh) |
| file_truncate - function cause the regular file named by path to be truncated to a size of precisely length bytes More... | |
| int | file_remove (const char *fl_name) |
| file_remove - Deletes the file whose name is specified in filename More... | |
| int | file_unlink (const char *ul_name) |
| file_unlink - removes the file from the file system More... | |
Variables | |
| u8 * | bs_sector |
| u8 * | fs_infosector |
| u8 * | backup_boot_sector |
| u8 * | first_fat |
| u8 * | second_fat |
| u8 * | root_directory |
| u8 * | data |
| u16 | sec_size |
| u32 | cluster_size |
| u16 | root_dir_size |
| u16 | rt_dir_entry_cnt |
| u32 | rt_dir_strt_clus |
| u32 | nxt_free_cluster |
| u8 * | dir_file_offset |
| int | fdes |
| file_info * | file_head |
| u32 allocate_cluster | ( | ) |
Function to find an unused cluster from the FAT table.
| void cal_region_offsets | ( | boot_sector * | bs, |
| u8 * | dev | ||
| ) |
Function to calculate all the region offsets.
| bs | Pointer to the boot sector structure which holds the information of the boot sector of the file system |
| dev | Pointer to the start of the file system |
| int cal_req_dir_cnt | ( | int | file_name_len | ) |
| file_name_len |
| u8 calc_check_sum | ( | u8 * | dir_entry | ) |
Function to calculate the checksum for the long file name based on its short name entry.
| dir_entry | Pointer to the start of the short file name corresponding to a long file name |
| bool chk_fat32_file_system | ( | u8 * | file_sys_type | ) |
Verify the type of FAT file system.
| file_sys_type | Pointer to the location where the type of file system is stored |
| int chk_file_lock | ( | const char * | path | ) |
| path |
| u8* cluster_to_memory_addr | ( | u32 | cluster | ) |
Function to get the corresponding physical address from the given cluster.
| cluster | Cluster value for which the address is to be obtained |
| void convert_to_uppercase | ( | char * | file_name | ) |
Function to convert the incoming short file name to its corresponding upper case letters.
| file_name | File name whose values are to be converted |
| int create_dir | ( | const char * | path | ) |
Function to create a directory.
| path | Pointer to the start of the path which represents the directory hierarchy |
| int create_file | ( | char * | lfname, |
| char * | shrt_name, | ||
| u32 | clus, | ||
| dir_entry ** | entry | ||
| ) |
Function to create a file if the file doesnt exists and the create flag is set.
| lfname | Pointer to the start of the long file. NULL in case of short file name creation |
| shrt_name | Pointer to the start of the short file name. In case of long file names the corresponding short file name is found out. |
| clus | Starting cluster of the directory in which the file is going to be created |
| entry | Pointer to a pointer of the directory entry structure in which the short file name directory entry content is to be stored |
| int file_close | ( | int | fd | ) |
Close the opened file based on the file descriptor and free the file structure pointer.
| fd | File descriptor of the file which needs to be closed |
| int file_open | ( | const char * | file_path, |
| int | flags | ||
| ) |
Function to open a specific file mentioned in the path based on the incoming modes.
| file_path | Pointer to the location of the file path string |
| flags | Flags indicating the modes in which the file is to be opened |
| int file_read | ( | int | fd, |
| char * | buffer, | ||
| int | bytes_to_read | ||
| ) |
Function to read the contents of a file.
| fd | File descriptor of the file in which read operation needs to be performed |
| buffer | Pointer to the start of the buffer where the contents read are stored |
| bytes_to_read | Number of bytes to be read from the file |
| int file_remove | ( | const char * | fl_name | ) |
file_remove - Deletes the file whose name is specified in filename
| fl_name | - string containing the name of the file to be deleted |
| int file_rename | ( | const char * | old, |
| const char * | new | ||
| ) |
Function to rename a file/directory.
| old | Constant pointer to the start of the path where the file which needs to be renamed is located |
| new | Constant pointer to the start of the path where the new name of the file/directory is situated |
| int file_seek | ( | int | fd, |
| int | offset, | ||
| int | whence | ||
| ) |
Function to seek the opened file pointer to the desired location so that subsequent read and write operations are performed from the new value.
| fd | File descriptor of the file in which the seek operation needs to be performed |
| offset | Offset bytes indicating the number of bytes which needs to be moved |
| whence | Flag denoting the position from which the seek operation needs to be performed |
| int file_truncate | ( | const char * | tr_pf, |
| int | tr_lgh | ||
| ) |
file_truncate - function cause the regular file named by path to be truncated to a size of precisely length bytes
| tr_pf | - truncates the file whose name is specified in filename |
| tr_lgh | - The desired truncate size of the file in bytes |
| int file_unlink | ( | const char * | ul_name | ) |
file_unlink - removes the file from the file system
file_remove - Deletes the file whose name is specified in filename
| ul_name | - string containing the name of the file to be deleted |
| int file_write | ( | int | fd, |
| const char * | buffer, | ||
| int | bytes_to_write | ||
| ) |
Function to write into the given file with the contents given.
| fd | File descriptor of the file |
| buffer | Pointer to the start of the contents which needs to be written into the file |
| bytes_to_write | Indicates the number of bytes which needs to be written into the file |
| void fill_lng_fname_entries | ( | char * | fname, |
| u8 * | entry, | ||
| u8 | chk_sum, | ||
| int | count | ||
| ) |
Function to put the long file name entries into the respective allocated region.
| fname | Pointer to the start of the long file name |
| entry | Starting memory location to the short file name directory entry |
| chk_sum | Calculated check sum of the short file name corresponding to the long file name |
| count | Counter indicating the number of 32 byte entries needed for the whole file name to get accommodated |
| int find_depth | ( | const char * | file_path | ) |
Function to calculate the number of iterations needed to reach the file from the given starting path.
| file_path | Pointer to the starting of the file path |
| bool get_dir_entry | ( | char * | fname, |
| dir_entry ** | entry, | ||
| u8 * | strt, | ||
| u32 | strt_clus, | ||
| bool | is_lfn | ||
| ) |
Function to check whether a given file name exists in the file system and if so retrieve the corresponding short file name directory entry.
| fname | Pointer to the start of the file name which needs to be searched |
| entry | Pointer to a pointer of the directory entry structure in which the short file name directory entry content is to be stored |
| strt | Pointer to the start of the region where the file/directory needs to be searched |
| strt_clus | Starting cluster of the directory in which the file is assumed to be present |
| is_lfn | Boolean value which indicates whether the file is short or long file |
| u32 get_fat_table_entry | ( | u32 | cluster | ) |
Function to retrieve the next cluster value in a cluster chain from the FAT table.
| cluster | Cluster whose next cluster value is to be obtained |
| int get_long_file_name | ( | char * | fname, |
| u8 ** | dir_strt, | ||
| int * | count | ||
| ) |
Function to retrieve the long file name given its end of the long file name entry.
| fname | Pointer to a location where the retrieved long file name starts |
| dir_strt | Pointer to the memory location where the last component of the long file name resides |
| count | Count representing the number of directory entries needed for the long file name |
| int get_seek_off | ( | file_info * | file_ptr, |
| u32 | strt_cluster, | ||
| int | offset | ||
| ) |
Function to move the current cluster and its offset value to the value specified in the offset from the starting cluster provided.
| file_ptr | File structure pointer pointing to the opened file |
| strt_cluster | Starting cluster value from which the seek operation has to be performed |
| offset | Offset bytes for the seek operation |
| void get_short_file_name | ( | char * | lfname, |
| char * | sfname, | ||
| char | seq_num | ||
| ) |
Function to extract the short file name given its long file name.
| lfname | : Pointer to the start of the long file name string |
| sfname | : Pointer to the start of the short file name in which this function extracts and stored the short file name value |
| seq_num | : sequence number |
| int lfn_entry_to_name | ( | lfn_entry * | entry, |
| char * | lfname, | ||
| int * | index | ||
| ) |
Function to get the long file name correspoding to a directory slot.
| entry | Pointer to the slot where a long file component resides |
| lfname | Pointer to the start of the long file name |
| index | Pointer to the offset of the long file name where the retrieved name from the given slot is going to be stored |
| int list_dir | ( | const char * | path | ) |
Function to list the directory contents.
| path | Pointer to the start of the path representing the directory hierarchy |
| int mount_file_system | ( | u8 * | dev | ) |
Mount the FAT file system and retrieve its basic information.
| dev | Pointer to the start of the file system image |
| int open_dir | ( | const char * | path | ) |
Function to open a directory.
| path | Pointer to the start of the path representing the directory hierarchy |
| file_stat* read_dir | ( | int | fd | ) |
| fd |
| int retrieve_file_info | ( | file_info * | finfo, |
| dir_entry * | entry, | ||
| u8 | mode, | ||
| u8 * | dir_offset, | ||
| const char * | path | ||
| ) |
Function to assign a file descriptor and necessary information to a file structure inorder to pursue subsequent operations.
| finfo | : Pointer to a file structure where the file information is stored |
| entry | : Pointer to the directory entry of the file/directory |
| mode | : Mode in which the file is requested to be opened |
| dir_offset | : directory offset |
| path | : path |
| void write_fat_table | ( | u32 | cluster, |
| u32 | value | ||
| ) |
Function to write into the FAT table after assigning an empty cluster to a file.
| cluster | Cluster number for which the entry has to be made |
| value | Next cluster value of the cluster number provided |
| u8* backup_boot_sector |
| u8* bs_sector |
| u32 cluster_size |
| u8* data |
| u8* dir_file_offset |
| int fdes |
| file_info* file_head |
| u8* first_fat |
| u8* fs_infosector |
| u32 nxt_free_cluster |
| u16 root_dir_size |
| u8* root_directory |
| u16 rt_dir_entry_cnt |
| u32 rt_dir_strt_clus |
| u16 sec_size |
| u8* second_fat |
1.8.6