source: trunk/kernel/fs/fatfs.h @ 656

Last change on this file since 656 was 656, checked in by alain, 4 years ago

Fix several bugs in the FATFS and in the VFS,
related to the creation of big files requiring
more than 4 Kbytes (one cluster) on device.

File size: 29.5 KB
Line 
1/*
2 * fatfs.h - FATFS file system API definition.
3 *
4 * Author    Mohamed Lamine Karaoui (2014,2015)
5 *           Alain Greiner (2016,2017,2018)
6 *
7 * Copyright (c) UPMC Sorbonne Universites
8 *
9 * This file is part of ALMOS-MKH.
10 *
11 * ALMOS-MKH is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; version 2.0 of the License.
14 *
15 * ALMOS-MKH is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25#ifndef _FATFS_H_
26#define _FATFS_H_
27
28#include <hal_kernel_types.h>
29#include <remote_queuelock.h>
30#include <vfs.h>
31#include <dev_ioc.h>
32
33
34/******************************************************************************************
35 * The FATFS File System implements a FAT32 read/write file system.
36 *
37 * The FATFS specific extensions to the generic VFS are the following:
38 * 1) The vfs_ctx_t "extend" field is a void* pointing on the fatfs_ctx_t structure.
39 *    This structure contains various general informations such as the total
40 *    number of sectors in FAT region, the number of bytes per sector, the number
41 *    of sectors per cluster, the lba of FAT region, the lba of data region, or the
42 *    cluster index for the root directory. It contains also an extended pointer
43 *    on the FAT mapper.
44 * 2) The vfs_inode_t "extend" contains, for each inode,
45 *    the first FAT32 cluster_id (after cast to intptr).
46 * 3) The vfs_dentry_t "extend" field contains, for each dentry, the entry index
47 *    in the FATFS directory (32 bytes per FATFS directory entry).
48 *
49 * In the FAT32 File System, the File Allocation Table is is actually an array
50 * of uint32_t slots. Each slot in this array contains the index (called cluster_id)
51 * of another slot in this array, to form one linked list for each file stored on
52 * device in the FAT32 File System. This index in the FAT array is also the index of
53 * the FATFS cluster on the device. One FATFS cluster is supposed to contain one PPM page.
54 * For a given file, the entry point in the FAT is the cluster_id of the FATFS cluster
55 * containing the first page of the file, but it can be any cluster_id already allocated
56 * to the file.
57 *****************************************************************************************/
58 
59///////////////////////////////////////////////////////////////////////////////////////////
60
61/*************** Partition Boot Sector Format **********************************/
62//                                     offset |  length
63#define BS_JMPBOOT                          0 ,  3
64#define BS_OEMNAME                          3 ,  8
65#define BPB_BYTSPERSEC                     11 ,  2
66#define BPB_SECPERCLUS                     13 ,  1
67#define BPB_RSVDSECCNT                     14 ,  2
68#define BPB_NUMFATS                        16 ,  1
69#define BPB_ROOTENTCNT                     17 ,  2
70#define BPB_TOTSEC16                       19 ,  2
71#define BPB_MEDIA                          21 ,  1
72#define BPB_FATSZ16                        22 ,  2
73#define BPB_SECPERTRK                      24 ,  2
74#define BPB_NUMHEADS                       26 ,  2
75#define BPB_HIDDSEC                        28 ,  4
76#define BPB_TOTSEC32                       32 ,  4
77#define BPB_PARTITION_TABLE               446 , 64
78
79// FAT 32
80#define BPB_FAT32_FATSZ32                  36 ,  4
81#define BPB_FAT32_EXTFLAGS                 40 ,  2
82#define BPB_FAT32_FSVER                    42 ,  2
83#define BPB_FAT32_ROOTCLUS                 44 ,  4
84#define BPB_FAT32_FSINFO                   48 ,  2
85#define BPB_FAT32_BKBOOTSEC                50 ,  2
86#define BS_FAT32_DRVNUM                    64 ,  1
87#define BS_FAT32_BOOTSIG                   66 ,  1
88#define BS_FAT32_VOLID                     67 ,  4
89#define BS_FAT32_VOLLAB                    71 , 11
90#define BS_FAT32_FILSYSTYPE                82 ,  8
91
92// Partitions
93#define FIRST_PARTITION_ACTIVE            446 ,  8
94#define FIRST_PARTITION_BEGIN_LBA         454 ,  4
95#define FIRST_PARTITION_SIZE              458 ,  4
96#define SECOND_PARTITION_ACTIVE           462 ,  8
97#define SECOND_PARTITION_BEGIN_LBA        470 ,  4
98#define SECOND_PARTITION_SIZE             474 ,  4
99#define THIRD_PARTITION_ACTIVE            478 ,  8
100#define THIRD_PARTITION_BEGIN_LBA         486 ,  4
101#define THIRD_PARTITION_SIZE              490 ,  4
102#define FOURTH_PARTITION_ACTIVE           494 ,  8
103#define FOURTH_PARTITION_BEGIN_LBA        502 ,  4
104#define FOURTH_PARTITION_SIZE             506 ,  4   
105/*******************************************************************************/
106
107#define MBR_SIGNATURE_POSITION            510 , 2
108#define MBR_SIGNATURE_VALUE               0xAA55 
109
110/************** FAT_FS_INFO SECTOR  ********************************************/
111#define FS_SIGNATURE_VALUE_1              0x52526141
112#define FS_SIGNATURE_VALUE_2              0x72724161
113#define FS_SIGNATURE_VALUE_3              0x000055AA 
114#define FS_SIGNATURE_POSITION_1           0   , 4 
115#define FS_SIGNATURE_POSITION_2           484 , 4
116#define FS_SIGNATURE_POSITION_3           508 , 4 
117#define FS_FREE_CLUSTERS                  488 , 4
118#define FS_FREE_CLUSTER_HINT              492 , 4
119/*******************************************************************************/
120
121#define DIR_ENTRY_SIZE          32
122                   
123#define NAME_MAX_SIZE           31
124
125/******* SFN Directory Entry Structure (32 bytes) ******************************/
126//                            offset | length
127#define DIR_NAME                   0 , 11   // dir_entry name
128#define DIR_ATTR                  11 ,  1   // attributes
129#define DIR_NTRES                 12 ,  1   // reserved for the OS       
130#define DIR_CRT_TIMES_TENTH       13 ,  1
131#define DIR_FST_CLUS_HI           20 ,  2   // cluster index 16 MSB bits
132#define DIR_WRT_TIME              22 ,  2   // time of last write
133#define DIR_WRT_DATE              24 ,  2   // date of last write
134#define DIR_FST_CLUS_LO           26 ,  2   // cluster index 16 LSB bit
135#define DIR_FILE_SIZE             28 ,  4   // dir_entry size (up to 4 Gbytes)
136/*******************************************************************************/
137
138/******* LFN Directory Entry Structure  (32 bytes) *****************************/
139//                            offset | length
140#define LDIR_ORD                   0 ,  1   // Sequence number (from 0x01 to 0x0f)   
141#define LDIR_NAME_1                1 , 10   // name broken into 3 parts
142#define LDIR_ATTR                 11 ,  1   // attributes (must be 0x0F)
143#define LDIR_TYPE                 12 ,  1   // directory type (must be 0x00)
144#define LDIR_CHKSUM               13 ,  1   // checksum of name in short dir 
145#define LDIR_NAME_2               14 , 12
146#define LDIR_RSVD                 26 ,  2   // artifact of previous fat (must be 0)
147#define LDIR_NAME_3               28 ,  4   
148/*******************************************************************************/
149
150/***********************  DIR_ATTR values  (attributes) ************************/
151#define ATTR_READ_ONLY            0x01
152#define ATTR_HIDDEN               0x02
153#define ATTR_SYSTEM               0x04
154#define ATTR_VOLUME_ID            0x08
155#define ATTR_DIRECTORY            0x10
156#define ATTR_ARCHIVE              0x20
157#define ATTR_LONG_NAME_MASK       0x0f      // READ_ONLY|HIDDEN|SYSTEM|VOLUME_ID
158/*******************************************************************************/
159
160/********************* DIR_ORD special values **********************************/
161#define FREE_ENTRY                0xE5     // this entry is free in the directory
162#define NO_MORE_ENTRY             0x00     // no more entry in the directory
163/*******************************************************************************/
164
165/******************** CLuster Index Special Values *****************************/
166#define FREE_CLUSTER              0x00000000
167#define RESERVED_CLUSTER          0x00000001
168#define BAD_CLUSTER               0x0FFFFFF7
169#define END_OF_CHAIN_CLUSTER_MIN  0x0ffffff8
170#define END_OF_CHAIN_CLUSTER_MAX  0x0fffffff
171/*******************************************************************************/
172
173/****  Forward declarations  ****/
174
175struct mapper_s;
176struct page_s;
177struct vfs_ctx_s;
178struct vfs_inode_s;
179struct vfs_dentry_s;
180
181/*****************************************************************************************
182 * This structure defines a FATFS specific context extension to the VFS context.
183 * This fatfs context is replicated in all clusters.
184 *
185 * WARNING 1 : All access to the FAT are protected by a remote_rwlock.
186 * - it is taken in READ mode by the fatfs_get_cluster() function to scan the
187 *   linked list associated to a given inode.
188 * - it is taken in WRITE mode by the fatfs_cluster_alloc() and fatfs_release_inode()
189 *   functions to modify the FAT in both the FAT mapper and on IOC device.
190 *
191 * WARNING 2 : Most fields are constant values, but the <free_cluster_hint>,
192 * <free_clusters>, <lock>, and the <fs_info_buffer> are shared variables,
193 * that can be modified by any thread running in any cluster. The <fs_info_buffer>
194 * contains a copy of the FS_INFO sector, and is only allocated in the FAT cluster
195 * (cluster 0). It is used to synchronously update the free clusters info on IOC device.
196 *  => For all these variables, only the values stored in the FAT cluster must be used.
197 ****************************************************************************************/
198
199typedef struct fatfs_ctx_s
200{
201    /* read-only constants replicated in all clusters                                   */
202    uint32_t            fat_sectors_count;     /*! number of sectors in FAT region      */
203    uint32_t            bytes_per_sector;      /*! number of bytes per sector           */
204    uint32_t            sectors_per_cluster;   /*! number of sectors per cluster        */
205    uint32_t            fat_begin_lba;         /*! lba of FAT region                    */
206    uint32_t            cluster_begin_lba;     /*! lba of data region                   */
207    uint32_t            fs_info_lba;           /*! lba of FS_INFO sector                */
208    uint32_t            root_dir_cluster;      /*! cluster index for  root directory    */
209    xptr_t              fat_mapper_xp;         /*! extended pointer on FAT mapper       */
210
211    /* shared variables (only the copy in FAT cluster must be used)                     */
212    uint32_t            free_cluster_hint;     /*! cluster[hint+1] is the first free    */
213    uint32_t            free_clusters;         /*! free clusters number                 */
214    remote_rwlock_t     lock;                  /*! exclusive access to FAT              */
215    uint8_t           * fs_info_buffer;        /*! local pointer on FS_INFO buffer      */
216}
217fatfs_ctx_t;
218
219//////////////////////////////////////////////////////////////////////////////////////////
220//              FATFS specific extern functions 
221//////////////////////////////////////////////////////////////////////////////////////////
222
223/*****************************************************************************************
224 * This debug function display the content of the FATFS context copy in cluster
225 * identified by the <cxy> argument.
226 * This function can be called by a thread running in any cluster.
227 *****************************************************************************************
228 * @ cxy       :  target cluster identifier.
229 ****************************************************************************************/
230void fatfs_display_ctx( cxy_t cxy );
231
232/*****************************************************************************************
233 * This debug function access the FAT mapper to display the current FAT state,
234 * as defined by the <page_id>, <min_slot>, and <nb_slots> arguments.
235 * It loads the missing pages from IOC to mapper if required.
236 * This function can be called by a thread running in any cluster.
237 *****************************************************************************************
238 * @ page_id   : page index in FAT mapper (one page is 4 Kbytes = 1024 slots).
239 * @ min_slot  : first slot in page
240 * @ nb_slots  : number of slots (one slot is 4 bytes).
241 ****************************************************************************************/
242void fatfs_display_fat( uint32_t  page_id,
243                        uint32_t  min_slot,
244                        uint32_t  nb_slots );
245
246
247//////////////////////////////////////////////////////////////////////////////////////////
248// Generic API: These functions are called by the kernel VFS,
249//              and must be implemented by all File Systems.
250//////////////////////////////////////////////////////////////////////////////////////////
251
252/*****************************************************************************************
253 * This fuction allocates memory from local cluster for a FATFS context descriptor.
254 *****************************************************************************************
255 * @ return a pointer on the created context / return NULL if failure.
256 ****************************************************************************************/
257fatfs_ctx_t * fatfs_ctx_alloc( void );
258
259/*****************************************************************************************
260 * This function access the boot device, and initialises the local FATFS context,
261 * from informations contained in the boot record. This initialisation includes the
262 * creation of the FAT mapper in cluster 0.
263 *****************************************************************************************
264 * @ vfs_ctx   : local pointer on VFS context for FATFS.
265 ****************************************************************************************/
266void fatfs_ctx_init( fatfs_ctx_t * fatfs_ctx );
267
268/*****************************************************************************************
269 * This function releases memory dynamically allocated for the FATFS context extension.
270 *****************************************************************************************
271 * @ vfs_ctx   : local pointer on VFS context.
272 ****************************************************************************************/
273void fatfs_ctx_destroy( fatfs_ctx_t * fatfs_ctx );
274
275/*****************************************************************************************
276 * This function implements the generic vfs_fs_add_dentry() function for the FATFS.
277 *****************************************************************************************
278 * This function updates a directory mapper identified by the <inode> argument
279 * to add a new directory entry identified by the <dentry> argument.
280 * All modified pages in the directory mapper are synchronously updated on IOC device.
281 * It must be called by a thread running in the cluster containing the directory inode.
282 *
283 * Implementation note : this function works in two steps:
284 * - It scan the set of 32 bytes FATFS directry entries, using two embedded loops 
285 *   to find the end of directory (NO_MORE_ENTRY marker).
286 * - Then it writes 3, 4, or 5 directory entries (depending on the name length), using
287 *   a 5 steps FSM (one state per entry to be written), updates on IOC device the
288 *   modified pages, and updates the dentry extension field, that must contain
289 *   the dentry index in FATFS directory.
290 *****************************************************************************************
291 * @ inode    : local pointer on directory inode.
292 * @ dentry   : local pointer on dentry.
293 * @ return 0 if success / return ENOENT if not found, or EIO if no access to IOC device.
294 ****************************************************************************************/
295error_t fatfs_add_dentry( struct vfs_inode_s  * inode,
296                          struct vfs_dentry_s * dentry );
297
298/*****************************************************************************************
299 * This function implements the generic vfs_fs_remove_dentry() function for the FATFS.
300 *****************************************************************************************
301 * This function updates a directory identified by the <inode> argument
302 * to remove a directory entry identified by the <dentry> argument.
303 * All modified pages in directory mapper are synchronously updated on IOC device.
304 * It must be called by a thread running in the cluster containing the inode.
305 *
306 * Implementation note: this function uses the dentry extension to directly access
307 * the NORMAL directory entry and invalidate all involved LFN entries. Then it
308 * updates the modified pages on IOC device.
309 *****************************************************************************************
310 * @ inode    : local pointer on directory inode.
311 * @ dentry   : local pointer on dentry.
312 * @ return 0 if success / return ENOENT if not found, or EIO if no access to IOC device.
313 ****************************************************************************************/
314error_t fatfs_remove_dentry( struct vfs_inode_s  * inode,
315                             struct vfs_dentry_s * dentry );
316
317/*****************************************************************************************
318 * This function implements the generic vfs_fs_new_dentry() function for the FATFS.
319 *****************************************************************************************
320 * It scan a parent directory mapper, identified by the <parent_inode> argument to find
321 * a directory entry identified by the <name> argument.  In case of success, it completes
322 * initialization the inode/dentry couple, identified by the  <child_inode_xp> argument.
323 * The child inode descriptor, and the associated dentry descriptor must have been
324 * previously allocated by the caller.
325 * - It set the "type", "size", and "extend" fields in the child inode descriptor.
326 * - It set the " extend" field in the dentry descriptor.
327 * It must be called by a thread running in the cluster containing the parent inode.
328 *****************************************************************************************
329 * @ parent_inode    : local pointer on parent inode (directory).
330 * @ name            : child name.
331 * @ child_inode_xp  : extended pointer on remote child inode (file or directory).
332 * @ return 0 if success / return -1 if child not found.
333 ****************************************************************************************/
334error_t fatfs_new_dentry( struct vfs_inode_s * parent_inode,
335                          char               * name,
336                          xptr_t               child_inode_xp );
337
338/*****************************************************************************************
339 * This function implements the generic vfs_fs_update_dentry() function for the FATFS.
340 *****************************************************************************************
341 * It update the size of a directory entry identified by the <dentry> argument in
342 * the mapper of a directory identified by the <inode> argument, as defined by the
343 * <size> argument.
344 * It scan the mapper to find the entry identified by the dentry "name" field.
345 * It set the "size" field in the in the directory mapper AND marks the page as DIRTY.
346 * It must be called by a thread running in the cluster containing the directory inode.
347 *****************************************************************************************
348 * @ inode        : local pointer on inode (directory).
349 * @ dentry       : local pointer on dentry (for name).
350 * @ size         : new size value.
351 * @ return 0 if success / return ENOENT if child not found.
352 ****************************************************************************************/
353error_t fatfs_update_dentry( struct vfs_inode_s  * inode,
354                             struct vfs_dentry_s * dentry,
355                             uint32_t              size );
356
357/*****************************************************************************************
358 * This function implements the generic vfs_fs_get_user_dir() function for the FATFS.
359 *****************************************************************************************
360 * It is called by the remote_dir_create() function to scan the mapper of a directory
361 * identified by the <inode> argument, and copy up to <max_dirent> valid dentries to a
362 * local dirent array, defined by the <array> argument. The <min_dentry> argument defines
363 * the index of the first dentry to be copied to the target dirent array.
364 * This function returns in the <entries> buffer the number of dentries actually written,
365 * and signals in the <done> buffer when the last valid entry has been found.
366 * If the <detailed> argument is true, a dentry/inode couple that does not exist in
367 * the Inode Tree is dynamically created, and all dirent fields are documented in the
368 * dirent array. Otherwise, only the dentry name is documented.
369 * It must be called by a thread running in the cluster containing the directory inode.
370 *****************************************************************************************
371 * @ inode      : [in]  local pointer on directory inode.
372 * @ array      : [in]  local pointer on array of dirents.
373 * @ max_dirent : [in]  max number of slots in dirent array.
374 * @ min_dentry : [in]  index of first dentry to be copied into array.
375 * @ detailed   : [in]  dynamic inode creation if true.
376 * @ entries    : [out] number of dentries actually copied into array.
377 * @ done       : [out] Boolean true when last entry found.
378 * @ return 0 if success / return -1 if failure.
379 ****************************************************************************************/
380error_t fatfs_get_user_dir( struct vfs_inode_s * inode,
381                            struct dirent      * array, 
382                            uint32_t             max_dirent,
383                            uint32_t             min_dentry,
384                            bool_t               detailed,
385                            uint32_t           * entries,
386                            bool_t             * done );
387
388/*****************************************************************************************
389 * This function implements the generic vfs_fs_sync_inode() function for the FATFS.
390 *****************************************************************************************
391 * It updates the FATFS on the IOC device for a given inode identified by
392 * the <inode> argument. It scan all pages registered in the associated mapper,
393 * and copies from mapper to device each page marked as dirty.
394 * WARNING : The target <inode> cannot be a directory, because all modifications in a
395 * directory are synchronously done on the IOC device by the two fatfs_add_dentry()
396 * and fatfs_remove_dentry() functions.
397 *****************************************************************************************
398 * @ inode   : local pointer on inode.
399 * @ return 0 if success / return -1 if failure during IOC device access.
400 ****************************************************************************************/
401error_t fatfs_sync_inode( struct vfs_inode_s * inode );
402
403/*****************************************************************************************
404 * This function implements the generic vfs_fs_sync_fat() function for the FATFS.
405 *****************************************************************************************
406 * It updates the FAT on the IOC device for the FAT itself.
407 * It scan all clusters registered in the FAT mapper, and copies from mapper to device
408 * each page marked as dirty.
409 *
410 * TODO : the current implementation check ALL pages in the FAT region, even if most
411 * pages are empty, and not copied in mapper. It is sub-optimal.
412 * A solution is to maintain in the FAT context two "dirty_min" and "dirty_max"
413 * variables defining the smallest/largest dirty page index in FAT mapper...
414 *****************************************************************************************
415 * @ return 0 if success / return -1 if failure during IOC device access.
416 ****************************************************************************************/
417error_t fatfs_sync_fat( void );
418
419/*****************************************************************************************
420 * This function implements the generic vfs_fs_sync_fsinfo() function for the FATFS.
421 *****************************************************************************************
422 * It checks the current values of the "free_clusters" and "free_cluster_hint" variables
423 * in the FS_INFO sector on IOC, versus the values stored in the fatfs context.
424 * As these values are synchronously updated on IOC device at each modification,
425 * it does nothing if the values are equal. It updates the FS_INFO sector on IOC device,
426 * and displays a warning message on TXT0 if they are not equal.
427 * This function can be called by any thread running in any cluster.
428 *****************************************************************************************
429 * @ return 0 if success / return -1 if failure during IOC device access.
430 ****************************************************************************************/
431error_t fatfs_sync_free_info( void );
432
433/*****************************************************************************************
434 * This function implements the generic vfs_fs_cluster_alloc() function for the FATFS.
435 *****************************************************************************************
436 * It access the FAT (File allocation table), stored in the FAT mapper, and returns
437 * in <searched_cluster> the FATFS cluster index of a free cluster.
438 * It can be called by a thread running in any cluster, as it uses remote access
439 * primitives when the FAT mapper is remote. It takes the rwlock stored in the FATFS
440 * context located in the same cluster as the FAT mapper itself, to get exclusive
441 * access to the FAT. It uses and updates the <free_cluster_hint> and <free_clusters>
442 * variables stored in this FATFS context.
443 * - it updates the <free_cluster_hint> and <free_clusters> variables in FATFS context.
444 * - it updates the FAT mapper (handling miss from IOC device if required).
445 * - it synchronously updates the FAT region on IOC device.
446 * - it returns the allocated cluster index.
447 *****************************************************************************************
448 * @ searched_cluster_id  : [out] allocated FATFS cluster index.
449 * @ return 0 if success / return -1 if no more free clusters on IOC device.
450 ****************************************************************************************/
451error_t fatfs_cluster_alloc( uint32_t * searched_cluster_id );
452
453/*****************************************************************************************
454 * This function implements the generic vfs_fs_release_inode() function for the FATFS.
455 *****************************************************************************************
456 * This function is used to remove a given file or directory from FATFS the file system.
457 * It releases all clusters allocated to a file/directory identified by the <inode_xp>
458 * argument. All released clusters are marked FREE_CLUSTER in the FAT mapper.
459 * This function calls the recursive function fatfs_cluster_release() to release
460 * the clusters in reverse order of the linked list (from last to first).
461 * When the FAT mapper has been updated, it calls the fatfs_sync_fat() function to
462 * synchronously update all modified pages in the FAT mapper to the IOC device.
463 * Finally the FS-INFO sector on the IOC device is updated.
464 *****************************************************************************************
465 * @ inode_xp   : extended pointer on inode.
466 * @ return 0 if success / return EIO if failure during device access.
467 ****************************************************************************************/
468error_t fatfs_release_inode( xptr_t inode_xp );
469
470/*****************************************************************************************
471 * This function implements the generic vfs_fs_move_page() function for the FATFS.
472 *****************************************************************************************
473 * This function moves a page from/to the mapper to/from the FATFS file system on device.
474 * The page must have been previously allocated and registered in the mapper.   
475 * The pointer on the mapper and the page index in file are found in the page descriptor.
476 * It is used for both a regular file/directory mapper, and the FAT mapper.
477 * - For the FAT mapper, it read/write the FAT region on IOC device.
478 * - For a regular file, it scan the FAT mapper to get the cluster_id on IOC device,
479 *   and read/write this cluster.
480 * It can be called by any thread running in any cluster.
481 *
482 * WARNING : For the FAT mapper, the inode field in the mapper MUST be NULL, as this
483 *           is used to indicate that the corresponding mapper is the FAT mapper.
484 *
485 * TODO : In this first implementation, the entry point in the FAT to get the cluster_id
486 *        is always the cluster_id of the first page, registered in the inode extension.
487 *        This can introduce a quadratic cost when trying of acessing all pages of a
488 *        big file. An optimisation would be to introduce in the inode extension two
489 *        new fields <other_page_id> & <other_cluster_id>, defining a second entry point
490 *        in the FAT.
491 *****************************************************************************************
492 * @ page_xp   : extended pointer on page descriptor.
493 * @ cmd_type  : IOC_READ / IOC_WRITE / IOC_SYNC_READ / IOC_SYNC_WRITE
494 * @ return 0 if success / return EIO if error during device access.
495 ****************************************************************************************/
496error_t fatfs_move_page( xptr_t      page_xp,
497                         cmd_type_t  cmd_type );
498
499
500
501
502
503
504#endif  /* _FATFS_H_ */
Note: See TracBrowser for help on using the repository browser.