Ignore:
Timestamp:
Jul 19, 2017, 3:31:39 PM (5 years ago)
Author:
alain
Message:

Fixing bugs in vfs_lookup()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/vfs/fatfs.h

    r188 r238  
    3333///////////////////////////////////////////////////////////////////////////////////////////
    3434// The FATFS File System implements a FAT32 read/write file system.
     35//
     36// The FATFS extensions to the generic VFS are the following:
     37// 1) The vfs_ctx_t "extend" field is a void* pointing on the fatfs_ctx_t structure.
     38//    This structure contains various general informations such as the total
     39//    number of sectors in FAT region, the number of bytes per sector, the number
     40//    of sectors per cluster, the lba of FAT region, the lba of data region, or the
     41//    cluster index for the root directory. It contains also an extended pointer
     42//    on the FAT mapper.
     43// 2) The vfs_inode_t "extend" field is a void*, but contains for each inode,
     44//    the first FAT cluster index (after cast to intptr).
    3545///////////////////////////////////////////////////////////////////////////////////////////
    3646
     
    173183
    174184//////////////////////////////////////////////////////////////////////////////////////////
     185//              FATFS specific but public functions (used by RPC)
     186//////////////////////////////////////////////////////////////////////////////////////////
     187
     188/******************************************************************************************
     189 * This static function scan the FAT (File Allocation Table), stored in the FAT mapper,
     190 * and returns the FATFS cluster index for a given page of a given file.
     191 * It must be called by a thread running in the cluster containing the FAT mapper.
     192 * The FAT is actually an array of uint32_t slots. Each slot in this array contains the
     193 * index of another slot in this array, to form one linked list for each file stored on
     194 * device in the FATFS file system. This index in the FAT array is also the index of the
     195 * FATFS cluster on the device. One FATFS cluster is supposed to contain one PPM page.
     196 * For a given file, the entry point in the FAT is simply the index of the FATFS cluster
     197 * containing the first page of the file. The mapper being a cache, this function
     198 * automatically updates the FAT mapper from informations stored on device in case of miss.
     199 ******************************************************************************************
     200 * @ mapper              : local pointer on the FAT mapper.
     201 * @ first_cluster       : index of the first FATFS cluster allocated to the file.
     202 * @ searched_page   : index of searched page in the file.
     203 * @ cluster         : [out] pointer on buffer for the found FATFS cluster index.
     204 * @ return 0 if success / return EIO if FAT mapper miss cannot be solved.
     205 *****************************************************************************************/
     206error_t fatfs_get_cluster( struct mapper_s * mapper,
     207                           uint32_t          first_cluster,
     208                           uint32_t          searched_page,
     209                           uint32_t        * cluster );
     210
     211
     212
     213
     214//////////////////////////////////////////////////////////////////////////////////////////
    175215// Generic API: These functions are called by the kernel,
    176216//              and must be implemented by all File Systems.
     
    185225
    186226/*****************************************************************************************
    187  * This function access the external boot device, and initialises it
     227 * This function access the boot device, and initialises the FATFS context
    188228 * from informations contained in the boot record.
    189229 *****************************************************************************************
     
    200240
    201241/*****************************************************************************************
    202  * This function moves a page from the mapper to the FATFS file system on device.
     242 * This function moves a page from/to the mapper to/from the FATFS file system on device.
    203243 * It must be called by a thread running in cluster containing the mapper.
    204244 * The pointer on the mapper and the page index in file are registered
    205245 * in the page descriptor.
    206246 *****************************************************************************************
    207  * @ page    : local pointer on page descriptor.
     247 * @ page      : local pointer on page descriptor.
     248 * @ to_mapper : transfer direction
    208249 * @ return 0 if success / return EIO if error.
    209250 ****************************************************************************************/
    210 error_t fatfs_write_page( struct page_s * page );
    211 
    212 /*****************************************************************************************
    213  * This function moves a page from the FATFS file system on device to the mapper.
    214  * It must be called by a thread running in cluster containing the mapper.
    215  * The pointer on the mapper and the page index in file are registered
    216  * in the page descriptor.
    217  *****************************************************************************************
    218  * @ page    : local pointer on page descriptor.
    219  * @ return 0 if success / return EIO if error.
    220  ****************************************************************************************/
    221 error_t fatfs_read_page( struct page_s * page );
    222 
    223 /*****************************************************************************************
    224  * This function scan the FAT (File Allocation Table), stored in the FAT mapper,
    225  * and return the FATFS cluster index for a given page of a given file.
    226  * It must be called by a thread running in the cluster containing the FAT mapper
    227  * (can be a local thread or a RPC thread).
    228  * The FAT is actually an array of uint32_t slots. Each slot in this array contains the
    229  * index of another slot in this array, to form one linked list for each file stored on
    230  * device in the RAMFS file system. This index in the FAT array is also the index of the
    231  * FATFS cluster on the device. One FATFS cluster is supposed to contain one PPM page.
    232  * For a given file, the entry point in the FAT is simply the index of the FATFS cluster
    233  * containing the first page of the file. The mapper being a cache, this function
    234  * automatically updates the FAT mapper from informations stored on device in case of miss.
    235  *****************************************************************************************
    236  * @ mapper              : local pointer on the FAT mapper.
    237  * @ first_cluster       : index of the first FATFS cluster allocated to the file.
    238  * @ searched_page   : index of searched page in the file.
    239  * @ cluster         : [out] pointer on buffer for the found FATFS cluster index.
    240  * @ return 0 if success / return EIO if FAT mapper miss cannot be solved.
    241  ****************************************************************************************/
    242 error_t fatfs_get_cluster( struct mapper_s * mapper,
    243                            uint32_t          first_cluster,
    244                            uint32_t          searched_page,
    245                            uint32_t *        cluster );
     251error_t fatfs_move_page( struct page_s * page,
     252                         bool_t          to_mapper );
     253
     254
     255/*****************************************************************************************
     256 * This function scan an existing parent directory, identified by the <parent> argument,
     257 * to find a directory entry identified by the <name> argument and update the remote
     258 * child inode, identified by the <child_xp> argument.
     259 * It set the "type", "size", and "extend" (FAT cluster index) fields in child inode.
     260 * It must be called by a thread running in the cluster containing the parent inode.
     261 *****************************************************************************************
     262 * @ parent_inode    : local pointer on parent inode (directory).
     263 * @ name            : child name.
     264 * @ child_inode_xp  : extended pointer on remote child inode (file or directory).
     265 * @ return 0 if success / return ENOENT if child not found.
     266 ****************************************************************************************/
     267error_t fatfs_inode_load( struct vfs_inode_s * parent_inode,
     268                          char               * name,
     269                          xptr_t               child_inode_xp );
    246270
    247271#endif  /* _FATFS_H_ */
Note: See TracChangeset for help on using the changeset viewer.