Changes between Version 43 and Version 44 of file_system


Ignore:
Timestamp:
Feb 2, 2016, 11:45:42 PM (8 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • file_system

    v43 v44  
    2929To support various block device peripheral, this FAT32 implementation defines a generic function to transparently access various physical block devices, using the driver specified in the ''hard_config.h'' file. Five drivers are presently supported ( IOC_BDV / IOC_HBA / IOC_SDC / IOC_SPI / IOC_RDK ).
    3030
    31 WARNING 1: A node name (file or directory) cannot be larger than 31 characters.
    32 
    33 WARNING 2: There is no rescue mechanism (at the moment) in case of heap overflow: The system crash with a nice error message on the kernel terminal if the heap defined in the mapping is too small...
     31'''WARNING 1''': A node name (file or directory) cannot be larger than 31 characters.
     32
     33'''WARNING 2''': There is no rescue mechanism (at the moment) in case of heap overflow: The system crash with a nice error message on the kernel terminal if the heap defined in the mapping is too small for the File-Caches...
    3434
    3535== 2) Cache Structure & Write Policy ==
     
    198198== 5) Internal functions ==
    199199
    200 The following functions can be used to implement new system calls if required.
    201 
    202 === __int '''_fat_ioc_access'''( unsigned int use_irq ,  unsigned int to_mem ,  unsigned int lba , unsigned int buf_vaddr , unsigned int count )__ ===
    203 This function transfers one or several blocks between the block device and a memory buffer by calling the relevant driver. The <use_irq>  boolean argument forces the descheduling mode if supported by the IOC driver.
    204 The <to_mem> boolean argument defines the transfer direction (from block device to memory if non zero). The
    205 <lba> argument is the logical block address on the block device. The <buf_vaddr> argument is the memory buffer virtual address. The <count> argument is the number of blocks to be transferred.
    206 It returns 0 on success, or -1 on failure.
    207 
    208 === __void '''_display_one_block'''( unsigned char* buf , char* string , unsigned int block_id )__ ===
    209 This debug function displays the content of a 512 bytes buffer <buf>, with an identifier defined by the <string> and <block_id> arguments.
     200=== __void '''_display_cluster_list'''()__ ===
     201This debug function displays the list of clusters allocated to one file or directory.
    210202
    211203=== __void '''_display_fat_descriptor'''()__ ===
    212204This debug function displays the FAT descriptor content.
    213205
    214 === __unsigned int '''_get_fat_cache_buffer'''( unsigned int cluster_id , fat_cache_desc_t**  desc )__ ===
    215 This function returns in the <desc> argument a pointer on a buffer descriptor contained in the Fat_Cache.
    216 The <cluster_id> argument is the buffer index in the FAT_Cache.
    217 In case of miss, a 4 Kbytesbuffer and a buffer descriptor are allocated from the local heap, and the missing cluster is loaded in the Fat_Cache.
    218 It returns 0 on success. It returns 1 on error.=== __void '''_get_name_from_long'''( unsigned char* buffer , char* name )__ ===
     206=== __void '''_get_name_from_long'''( unsigned char* buffer , char* name )__ ===
    219207This function extract a (partial) name from a LFN directory entry.
    220208
    221209=== __void '''_get_name_from_short'''( unsigned char* buffer , char* name )__ ===
    222 This function extract a name from a NORMAL directory entry.
     210This function extract a <name> from a NORMAL directory entry.
    223211
    224212=== __unsigned int '''_get_levels_from_size'''( unsigned int size )__ ===
    225 This function returns the number of levels of a File-Cache from the size of the file.
     213This function returns the number of levels of a File-Cache from the <size> of the file.
    226214
    227215=== __unsigned int '''_get_name_from_path'''( char* pathname , char* name , unsigned int*  nb_read )__ ===
    228216This function analyses the <pathname> argument, from the character defined by the <nb_read> argument.
    229217It copies the found name in the <name> buffer (without '/'), and updates the <nb_read"> argument.
     218
    230219It returns 0 on success. It returns 1 if one name length > NAME_MAX_SIZE characters.
    231220
    232221=== __unsigned int '''_get_last_name'''( char* pathname , char* name )__ ===
    233 This function scan the "pathname" argument, and copies in the <name> buffer the last name in <pathname>.
     222This function scan the <pathname> argument, and copies in the <name> buffer the last name in the <pathname>.
     223
    234224It returns 0 on success.It returns 1 if one name length > NAME_MAX_SIZE characters.
    235225
    236226=== __unsigned int '''_get_fat_entry'''( unsigned int  cluster , unsigned int* value )__ ===
    237 This function accesses the Fat-Cache and returns in the <value> argument the content of the FAT slot identified by the <cluster> argument. It loads the missing cluster from block device in the Fat-Cache in case of miss. It returns 0 on success. It returns 1 on error.
     227This function accesses the Fat-Cache and returns in the <value> argument the content of the FAT slot identified by the <cluster> argument. It loads the missing cluster from block device in the Fat-Cache in case of miss.
     228
     229It returns 0 on success. It returns 1 on error.
    238230
    239231=== __unsigned int '''_set_fat_entry'''( unsigned int  cluster , unsigned int  value )__ ===
    240232This function writes a new <value> in the Fat-Cache, in the slot identified by the <cluster> argument. 
    241233It loads the missing cluster from block device in the Fat-Cache in case of miss.
     234
    242235It returns 0 on success, It returns 1 on error.
    243236
    244237=== __void '''_add_inode_in_tree'''( fat_inode_t*  child , fat_inode_t*  parent )__ ===
    245 This function introduces the inode identified by the <child> argument as a new child for the <parent> inode in the Inode-Tree.
    246 All checking are supposed to be done by the caller. Nor the File-Cache, neither the block device are modified.
     238This function introduces the inode identified by the <child> argument as a new child for the <parent> inode in the Inode-Tree. All checking are supposed to be done by the caller. Nor the File-Cache, neither the block device are modified.
    247239
    248240=== __void '''_remove_inode_from_tree'''( fat_inode_t* inode )__ ===
     
    251243=== __unsigned int '''_update_device_from_cache'''( unsigned int levels , fat_cache_node_t* root , char* string )__ ===
    252244This recursive function scan one File-Cache (or the Fat-Cache) from root to leaves, to writes all dirty clusters to block device, and reset the dirty bits. The cache is identified by the <root> an <levels> arguments.
    253 The <string> argument is only used for debug.  It returns 0 on success. It returns 1 on error.
     245The <string> argument is only used for debug. 
     246
     247It returns 0 on success. It returns 1 on error.
    254248
    255249=== __unsigned int '''_update_fs_info()'''__ ===
    256250This function accesses directly the FS_INFO block on the block device, to update the "first_free_cluster" and "free_clusters_number" values, using only the Fat-Descriptor single block buffer.
     251
    257252It return 0 on success. It return 1 on error.
    258253
     
    265260
    266261=== __unsigned int '''_get_nb_entries'''( fat_inode_t* inode , unsigned int* nb_entries )__ ===
    267 This function returns in the <nb_entries> argument the number of entries  contained in a directory identified by the <inode> pointer. It returns 0 on success. It returns 1 on error.
     262This function returns in the <nb_entries> argument the number of entries  contained in a directory identified by the <inode> pointer.
     263
     264It returns 0 on success. It returns 1 on error.
    268265
    269266=== __unsigned int '''_get_child_from_parent'''( fat_inode_t* parent , char* name , fat_inode_t**  inode )__ ===
    270 This function search in the directory identified by the <parent> inode pointer a child (file or directory) identified by its <name>.
    271 It returns in the <inode> argument the searched child inode pointer.
     267This function search in the directory identified by the <parent> inode pointer a child (file or directory) identified by its <name>. It returns in the <inode> argument the searched child inode pointer.
    272268If the searched name is not found in the Inode-Tree, the function accesses the File-cache associated to the parent directory.
    273269If the child exists on block device, the Inode-Tree is updated, and a success code is returned.
    274270If the file/dir does not exist on block device, a error code is returned.
     271
    275272It returns 0 if inode found. It returns 1 if inode not found. It returns 2 in case of error in cache access.
    276273
     
    278275For a file (or a directory) identified by the <pathname> argument, this function returns in the <inode> argument the inode pointer associated to the searched file (or directory), with code (0).
    279276If the searched file (or directory) is not found, but the parent directory is found, it returns in the <inode> argument the pointer on the parent inode, with code (1).  Code (2) and code (3) are error codes. Both the Inode-Tree and the involved Cache-Files are updated from the block device in case of miss on one inode during the search. Neither the Fat-Cache, nor the block device are updated.
     277
    280278It returns 0 if searched inode found  It returns 1 if searched inode not found but parent directory found. It returns 2 if searched inode not found and parent directory not found. It returns 3 if one name too long
    281279
    282280=== __unsigned int '''_is_ancestor'''( fat_inode_t* a , fat_inode_t* b )__ ===
    283281This function checks if inode <a> is an ancestor of inode <b>.
    284 It returns 0 on failure. It returns 1 otherwise.
    285 
    286 === __unsigned int '''_check_name_length'''( char* name , unsigned int* length , unsigned int* nb_lfn )__ ===
    287 This function computes the length and the number of LFN entries required to store a node name, and return the values in the <length> and <nb_lfn> arguments.
     282
     283It returns 1 if it is true.
     284
     285=== __unsigned int '''_get_sfn_name'''( char* name , unsigned int* length , unsigned int* nb_lfn, char* sfn , unsigned char* checksum )__ ===
     286This function returns  in the <length> and <nb_lfn> arguments the name length and the number of LFN entries required to store the <name> string. It returns in the <sfn> argument a legal SFN name extracted from the <name> string (upper case and 8-3 format). It returns in the <checksum> argument the SFN checksum.
    288287 * Short name (less than 13 characters) require 1 LFN entry.
    289288 * Medium names (from 14 to 26 characters require 2 LFN entries.
    290289 * Large names (up to 31 characters) require 3 LFN entries.
    291 It returns 0 on success. It returns 1 if length larger than 31 characters.
    292 
    293 === __unsigned int '''_update_dir_entry'''( fat_inode_t*  inode )__ ===
    294 For a node identified by the <inode> argument, this function updates the "size" and "cluster" values in the parent directory entry File-Cache.
    295 It set the dirty bit in the modified buffer of the parent directory File-Cache.
     290
     291It returns 0 on success. It returns 1 if the name length is larger than 31 characters.
     292
     293=== __void '''_update_dir_entry'''( fat_inode_t*  inode )__ ===
     294For a node identified by the <inode> argument, this function updates the "size" and "cluster" values in the parent directory entry File-Cache. It set the dirty bit in the modified buffer of the parent directory File-Cache.
    296295
    297296=== __unsigned int '''_add_dir_entry'''( fat_inode_t* child , fat_inode_t* parent )__ ===
    298 The following function add new <child> entry in the Cache-File of the <parent> directory. It accesses the File_Cache associated to the parent directory,
    299 and scan the clusters allocated to this directory to find the NO_MORE entry, that will be the first modified entry in the directory.
    300 Regarding the name storage, it uses LFN entries for all names, but computes a legal (upper case / 8.3) SFN name that will be stored in the NORMAL entry.
     297This function add a new <child> entry in the Cache-File of the <parent> directory. It accesses the File_Cache associated to the parent directory, and scan the clusters allocated to this directory to find the NO_MORE entry, that will be the first modified entry in the directory.
     298Regarding the name storage, it uses LFN entries for all names, but computes a legal (upper case / 8-3) SFN name that will be stored in the NORMAL entry.
    301299It writes 1, 2, or 3 LFN entries (depending on the child name actual length), writes one NORMAL entry, and writes the new NO_MORE entry.
    302300It updates the dentry field in the child inode. It set the dirty bit for all modified File-Cache buffers.
    303301The block device is not modified by this function.
     302
     303It returns 0 on success. It returns 1 in case of error.
    304304
    305305=== __unsigned int '''_remove_dir_entry'''( fat_inode_t*  inode )__ ===
     
    309309The block device is not modified by this function.
    310310
     311It returns 0 on success. It returns 1 in case of error.
     312
    311313=== __void '''_add_special_directories'''( fat_inode_t* child , fat_inode_t* parent )__ ===
    312314This function adds the special entries "." and ".." in the File-Cache of the directory identified by the <child> argument.