Changes between Version 36 and Version 37 of file_system


Ignore:
Timestamp:
Jan 14, 2016, 4:46:32 PM (9 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • file_system

    v36 v37  
    324324The <string> argument is only used for debug.  It returns 0 on success. It returns 1 on error.
    325325
    326 
    327 
    328 //////////////////////////////////////////////////////////////////////////////////
    329 // The following function accesses directly the FS_INFO block on the block device,
    330 // to update the "first_free_cluster" and "free_clusters_number" values,
    331 // using only the Fat-Descriptor single block buffer.
    332 // It return 0 on success.
    333 // It return 1 on error.
    334 //////////////////////////////////////////////////////////////////////////////////
    335 
    336 static unsigned int _update_fs_info();
    337 
    338 //////////////////////////////////////////////////////////////////////////////
    339 // The following function read a data field (from one to four bytes)
    340 // from an unsigned char[] buffer, taking endianness into account.
    341 // The analysed field is defined by the <offset> and <size> arguments.
    342 //////////////////////////////////////////////////////////////////////////////
    343 
    344 static unsigned int _read_entry( unsigned int    offset,
    345                                  unsigned int    size,
    346                                  unsigned char*  buffer,
    347                                  unsigned int    little_indian );
    348 
    349 //////////////////////////////////////////////////////////////////////////////////
    350 // The following function returns the lba of first sector in DATA region
    351 // from the cluster index. The cluster index must be larger than 2.
    352 //////////////////////////////////////////////////////////////////////////////////
    353 
    354 static unsigned int _cluster_to_lba( unsigned int cluster );
    355 
    356 //////////////////////////////////////////////////////////////////////////////////
    357 // The following function returns in the "nb_entries" argument the number of files
    358 // (or directories) contained in a directory identified by the "inode " pointer.
    359 // It returns 0 on success.
    360 // It returns 1 on error.
    361 //////////////////////////////////////////////////////////////////////////////////
    362 
    363 static unsigned int _get_nb_entries( fat_inode_t*   inode,
    364                                      unsigned int*  nb_entries );
    365 
    366 //////////////////////////////////////////////////////////////////////////////////
    367 // The following function search in the directory identified by the <parent>
    368 // inode pointer a child (file or directory) identified by its <name>.
    369 // It returns in the <inode> argument the searched child inode pointer.
    370 // If the searched name is not found in the Inode-Tree, the function accesses
    371 // the File-cache associated to the parent directory.
    372 // If the child exists on block device, the Inode-Tree is updated, and
    373 // a success code is returned.
    374 // If the file/dir does not exist on block device, a error code is returned.
    375 // It returns 0 if inode found.
    376 // It returns 1 if inode not found.
    377 // It returns 2 on error in cache access.
    378 //////////////////////////////////////////////////////////////////////////////////
    379 
    380 static unsigned int _get_child_from_parent( fat_inode_t*   parent,
    381                                             char*          name,
    382                                             fat_inode_t**  inode );
    383 
    384 /////////////////////////////////////////////////////////////////////////////////
    385 // For a file (or a directory) identified by the "pathname" argument, the
    386 // following function returns in the "inode" argument the inode pointer
    387 // associated to the searched file (or directory), with code (0).
    388 // If the searched file (or directory) is not found, but the parent directory
    389 // is found, it returns in the "inode" argument the pointer on the parent inode,
    390 // with code (1).  Finally, code (2) and code (3) are error codes.
    391 // Both the Inode-Tree and the involved Cache-Files are updated from the block
    392 // device in case of miss on one inode during the search in path.
    393 // Neither the Fat-Cache, nor the block device are updated.
    394 // It returns 0 if searched inode found
    395 // It returns 1 if searched inode not found but parent directory found
    396 // It returns 2 if searched inode not found and parent directory not found
    397 // It returns 3 if one name too long
    398 /////////////////////////////////////////////////////////////////////////////////
    399 
    400 static unsigned int _get_inode_from_path( char*          pathname,
    401                                           fat_inode_t**  inode );
    402 
    403 //////////////////////////////////////////////////////////////////////////////////
    404 // The following function checks if node "a" is an ancestor of inode "b".
    405 // It returns 0 on failure.
    406 // It returns 1 otherwise.
    407 //////////////////////////////////////////////////////////////////////////////////
    408 
    409 static unsigned int _is_ancestor( fat_inode_t* a,
    410                                   fat_inode_t* b);
     326=== __unsigned int '''_update_fs_info()'''__ ===
     327This 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.
     328It return 0 on success. It return 1 on error.
     329
     330=== __unsigned int '''_read_entry'''( unsigned int offset , unsigned int size , unsigned char*  buffer , unsigned int little_indian )__ ===
     331This function read a data field (one to four bytes) from an unsigned char[] <buffer>, taking endianness into account.
     332The analysed field is defined by the <offset> and <size> arguments.
     333
     334=== __unsigned int '''_cluster_to_lba'''( unsigned int cluster )__ ===
     335This function returns the lba (logic block address in DATA region)  from the <cluster> index. Exit if the cluster value is smaller than 2.
     336
     337=== __unsigned int '''_get_nb_entries'''( fat_inode_t* inode , unsigned int* nb_entries )__ ===
     338This 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.
     339
     340=== __unsigned int '''_get_child_from_parent'''( fat_inode_t* parent , char* name , fat_inode_t**  inode )__ ===
     341This function search in the directory identified by the <parent> inode pointer a child (file or directory) identified by its <name>.
     342It returns in the <inode> argument the searched child inode pointer.
     343If the searched name is not found in the Inode-Tree, the function accesses the File-cache associated to the parent directory.
     344If the child exists on block device, the Inode-Tree is updated, and a success code is returned.
     345If the file/dir does not exist on block device, a error code is returned.
     346It returns 0 if inode found. It returns 1 if inode not found. It returns 2 in case of error in cache access.
     347
     348=== __unsigned int '''_get_inode_from_path'''( char* pathname , fat_inode_t**  inode )__ ===
     349For 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).
     350If 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.
     351It 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
     352
     353=== __unsigned int '''_is_ancestor'''( fat_inode_t* a , fat_inode_t* b )__ ===;
     354The following function checks if inode <a> is an ancestor of inode <b>.
     355It returns 0 on failure. It returns 1 otherwise.
     356
     357
     358
    411359
    412360//////////////////////////////////////////////////////////////////////////////////