Changes between Version 38 and Version 39 of file_system


Ignore:
Timestamp:
Jan 19, 2016, 2:58:06 PM (8 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • file_system

    v38 v39  
    399399It returns 0 on success. It returns 1 on error.
    400400
    401 
    402 
    403 //////////////////////////////////////////////////////////////////////////////////
    404 // This recursive function scans one File-Cache (or Fat-Cache) from root to
    405 // leaves. All memory allocated for 4KB buffers, and buffer descriptors (in
    406 // leaves) is released, along with the 64-Tree structure (root node is kept).
    407 // The cache is identified by the "root" and "levels" arguments.
    408 // It should not contain any dirty clusters.
    409 //////////////////////////////////////////////////////////////////////////////////
    410 
    411 static void _release_cache_memory( fat_cache_node_t*  root,
    412                                    unsigned int       levels );
    413 
    414 //////////////////////////////////////////////////////////////////////////////////
    415 // The following function allocates and initializes a new cache node.
    416 // Its first child can be specified (used when adding a cache level).
    417 // The 63 other children are set to NULL.
    418 // It returns a pointer to a new Fat-Cache node.
    419 //////////////////////////////////////////////////////////////////////////////////
    420 
    421 static fat_cache_node_t* _allocate_one_cache_node( fat_cache_node_t* first_child );
    422 
    423 //////////////////////////////////////////////////////////////////////////////////
    424 // The following function allocates and initializes a new inode,
    425 // using the values defined by the arguments.
    426 // If the "cache_allocate" argument is true, an empty cache is allocated.
    427 // It returns a pointer on the new inode.
    428 //////////////////////////////////////////////////////////////////////////////////
    429 
    430 static fat_inode_t* _allocate_one_inode( char*        name,
    431                                          unsigned int is_dir,
    432                                          unsigned int cluster,
    433                                          unsigned int size,
    434                                          unsigned int count,
    435                                          unsigned int dentry,
    436                                          unsigned int cache_allocate );
    437 
    438 //////////////////////////////////////////////////////////////////////////////////
    439 // The following function allocates a 4 Kbytes buffer and the associated cluster
    440 // descriptor for the file (or directory) identified by the <inode> argument,
    441 // and updates the Cache_File slot identified by the <cluster_id> argument.
    442 // The File-Cache slot must be empty.
    443 // It updates the buffer descriptor, using the <cluster> argument, that is
    444 // the cluster index in FAT.  The cluster descriptor dirty field is set.
    445 // It traverse the 64-tree Cache-file from top to bottom to find the last level.
    446 //////////////////////////////////////////////////////////////////////////////////
    447 
    448 static void _allocate_one_buffer( fat_inode_t*    inode,
    449                                   unsigned int    cluster_id,
    450                                   unsigned int    cluster );
    451 
    452 //////////////////////////////////////////////////////////////////////////////////
    453 // The following function allocates one free cluster from the FAT 
    454 // and returns the cluster index in the <cluster> argument.
    455 // It updates the FAT slot, and the two FAT global variables: first_free_cluster,
    456 // and free_clusters_number.
    457 // It returns 0 on success.
    458 // It returns 1 on error.
    459 //////////////////////////////////////////////////////////////////////////////////
    460 
    461 static unsigned int _allocate_one_cluster( unsigned int*  cluster );
    462 
    463 /////////////////////////////////////////////////////////////////////////////
    464 // This function remove from the file system a file or a directory
    465 // identified by the <inode> argument.
    466 // The remove condition must be checked by the caller.
    467 // The relevant lock(s) must have been taken by te caller.
    468 // It returns 0 on success.
    469 // It returns 1 on error.
    470 /////////////////////////////////////////////////////////////////////////////
    471 
    472 static unsigned int _remove_node_from_fs( fat_inode_t* inode );
    473 
     401=== __void '''_release_cache_memory'''( fat_cache_node_t*  root , unsigned int levels )__ ===
     402This recursive function scans one File-Cache (or Fat-Cache) from root to leaves. All memory allocated for 4KB buffers, and buffer descriptors (in leaves) is released, along with the 64-Tree structure (root node is kept).
     403The released cache is identified by the <root> and <levels> arguments.
     404It should not contain any dirty clusters.
     405
     406=== __fat_cache_node_t* '''_allocate_one_cache_node'''( fat_cache_node_t* first_child )__ ===
     407This function allocates and initializes a new cache node.
     408Its first child can be specified (used when adding a cache level).
     409The 63 other children are set to NULL.
     410It returns a pointer to the new Fat-Cache node.
     411
     412=== __fat_inode_t* '''_allocate_one_inode'''( char* name , unsigned int is_dir , unsigned int cluster , unsigned int size , unsigned int count ,  unsigned int dentry , unsigned int cache_allocate )__ ===
     413This function allocates and initializes a new inode, using the values defined by the <name>, <is_dir>, <cluster>, <size>, <count>, and <dentry> arguments. If the <cache_allocate> argument is true, an empty cache is allocated.
     414It returns a pointer on the new inode.
     415
     416=== __void '''_allocate_one_buffer'''( fat_inode_t* inode , unsigned int cluster_id , unsigned int cluster )__ ===
     417This function allocates a 4 Kbytes buffer and the associated cluster descriptor from the heap[x,y] defined by the calling thread, for the file (or directory) identified by the <inode> argument. It updates the Cache_File slot identified by the <cluster_id> argument.
     418The File-Cache slot must be empty. It updates the buffer descriptor, using the <cluster> argument, that is the cluster index in FAT.  The buffer descriptor dirty bit is set.
     419It traverses the 64-tree Cache-file from top to bottom to find the last level.
     420
     421=== __unsigned int '''_allocate_one_cluster'''( unsigned int*  cluster )__ ==
     422This  function allocates one free cluster from the FAT and returns the cluster index in the <cluster> argument.
     423It updates the FAT slot, and the two FAT global variables "first_free_cluster" and "free_clusters_number".
     424It returns 0 on success. It returns 1 on error.
     425
     426=== __unsigned int '''_remove_node_from_fs'''( fat_inode_t* inode )__ ===
     427This function remove from the file system a file or a directory identified by the <inode> argument.
     428The remove conditions must be checked by the caller. The relevant lock(s) must have been taken by te caller.
     429It returns 0 on success. It returns 1 on error.
    474430
    475431=== __unsigned int '''_file_info_no_cache'''( char* pathname , unsigned int*  file_cluster , unsigned int*  file_size )__ ===