| 256 | === __int _get_file_cache_buffer( fat_node_t* indoor , unsigned int cluster_id , unsigned int writable , fat_cache_desc_t** desc )__ === |
| 257 | This function returns in the <desc> argument a pointer on a buffer descriptor contained in a File_Cache. |
| 258 | The searched buffer is idenfified by the <inode> and <cluster_id> arguments. The <cluster_id> argument is the buffer index in the file. The <writable> argument define the behaviour in case of miss in File-Cache: |
| 259 | * if [all clusters (from 0 to cluster_id) are already allocated in FAT] it scan the FAT to find the cluster index on device, and load the missing cluster in the File-Cache, marked as dirty if writable. |
| 260 | * if [not writable and all clusters (from 0 to cluster_id) not allocated] it returns an error. |
| 261 | * if [writable and all clusters (from 0 to cluster_id) not allocated], it allocates in FAT all required clusters, it updates the size in the inode and dentry, and we allocate a buffer descriptor for the missing cluster, marked as dirty. |
| 262 | This function is called by the _sys_fat_mmap() function, and by other FAT functions. |
| 263 | It does not take the FAT lock, that must be taken by the caller. |
| 264 | It returns GIET_FAT32_OK on success, and returns a negative value on error: |
| 265 | * GIET_FAT32_NOT_INITIALIZED |
| 266 | * GIET_FAT32_INVALID_ARG |
| 267 | * GIET_FAT32_IO_ERROR |
| 268 | |