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

Last change on this file since 626 was 626, checked in by alain, 2 years ago

This version has been tested on the sort multithreaded application
for TSAR_IOB architectures ranging from 1 to 8 clusters.
It fixes three bigs bugs:
1) the dev_ioc device API has been modified: the dev_ioc_sync_read()
and dev_ioc_sync_write() function use now extended pointers on the
kernel buffer to access a mapper stored in any cluster.
2) the hal_uspace API has been modified: the hal_copy_to_uspace()
and hal_copy_from_uspace() functions use now a (cxy,ptr) couple
to identify the target buffer (equivalent to an extended pointer.
3) an implementation bug has been fixed in the assembly code contained
in the hal_copy_to_uspace() and hal_copy_from_uspace() functions.

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