source: trunk/kernel/fs/vfs.h @ 636

Last change on this file since 636 was 635, checked in by alain, 5 years ago

This version is a major evolution: The physical memory allocators,
defined in the kmem.c, ppm.c, and kcm.c files have been modified
to support remote accesses. The RPCs that were previously user
to allocate physical memory in a remote cluster have been removed.
This has been done to cure a dead-lock in case of concurrent page-faults.

This version 2.2 has been tested on a (4 clusters / 2 cores per cluster)
TSAR architecture, for both the "sort" and the "fft" applications.

File size: 62.2 KB
Line 
1/*
2 * vfs.h - Virtual File System 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 _VFS_H_
26#define _VFS_H_
27
28#include <kernel_config.h>
29#include <hal_kernel_types.h>
30#include <hal_atomic.h>
31#include <remote_rwlock.h>
32#include <remote_busylock.h>
33#include <busylock.h>
34#include <list.h>
35#include <xlist.h>
36#include <bits.h>
37#include <xhtab.h>
38#include <errno.h>
39#include <shared_syscalls.h>
40#include <fatfs.h>
41#include <ramfs.h>
42#include <devfs.h>
43#include <dev_ioc.h>
44
45/****  Forward declarations  ***/
46
47struct vfs_inode_s;
48struct vfs_dentry_s;
49struct vfs_ctx_s;
50struct vfs_file_s;
51
52struct mapper_s;
53struct process_s;
54struct device_s;
55struct vseg_s;
56struct page_s;
57
58/******************************************************************************************
59 * These flags are used to define the working mode of the vfs_lookup() function. 
60 *****************************************************************************************/
61
62#define VFS_LOOKUP_DIR      0x01     /* the searched inode must be a directory           */
63#define VFS_LOOKUP_OPEN         0x02     /* the search is for an open/opendir                */
64#define VFS_LOOKUP_PARENT       0x04     /* return the parent inode (not the inode itself)   */
65#define VFS_LOOKUP_CREATE   0x10     /* file must be created if missing                  */
66#define VFS_LOOKUP_EXCL     0x20     /* file cannot previously exist                     */
67
68/******************************************************************************************
69 * This structure defines a VFS context, that contains informations common to all inodes
70 * and dentries for a given file system. As it is declared as a global variable in the
71 * kdata segment (fs_context[] array), it is replicated in all clusters.
72 * The <extend> field is a pointer on the FS specific context extension.
73 * This extension is dynamically allocated by kernel_init in all clusters.
74 * In each cluster, both this VFS context and the FS specific context are handled as
75 * private by the local OS intance.
76 *****************************************************************************************/
77
78typedef enum
79{
80        FS_TYPE_DEVFS = 0,
81        FS_TYPE_FATFS = 1,
82        FS_TYPE_RAMFS = 2,
83 
84        FS_TYPES_NR   = 3,
85}
86vfs_fs_type_t;
87
88typedef enum
89{
90    CTX_ATTR_READ_ONLY    = 0x01,            /*! write access prohibited                 */
91    CTX_ATTR_SYNC         = 0x10,            /*! synchronise FS on each write            */
92}
93vfs_ctx_attr_t;
94
95typedef struct vfs_ctx_s
96{
97        vfs_fs_type_t  type;                     /*! File System type                        */
98        uint32_t           attr;                     /*! global attributes for all files in FS   */
99        uint32_t       total_clusters;           /*! total number of clusters on device      */
100        uint32_t       cluster_size;             /*! cluster size on device (bytes)          */
101        xptr_t         vfs_root_xp;              /*! extended pointer on VFS root inode      */
102    busylock_t     lock;                     /*! lock protecting inum allocator          */
103    uint32_t       bitmap[BITMAP_SIZE(CONFIG_VFS_MAX_INODES)];  /* inum allocator        */
104    void         * extend;                   /*! FS specific context extension           */
105}
106vfs_ctx_t;
107
108/******************************************************************************************
109 * This structure define a VFS inode.
110 * An inode can have several children dentries (if it is a directory), an can have several
111 * parents dentries (if it hass several aliases links):
112 * - The "parents" field is the root of the xlist of parents dentries, and the "links"
113 *   fiels define the number of aliases parent dentries. only a FILE inode can have
114 *   several parents (no hard links for directories).
115 * - The "children" field is an embedded xhtab containing pointers on all local children
116 *   dentries. This set of children is empty for a FILE inode.
117 * Synchronisation:
118 * - the main_lock (remote_rwlock) is used during the inode tree traversal,
119 *   or for inode modification (add/remove children in xhtab).
120 * - the size_lock (remote_rwlock) is used during read/write accesses to the size
121 *   field in the mapper.
122 * - access to the data stored in the associated mapper use the mapper remote_rwlock
123 *   protecting radix tree traversal and modifications.
124 *****************************************************************************************/
125
126/* this enum define the VFS inode types values                                           */
127/* WARNING : this enum must be kept consistent with macros in <shared_stat.h> file       */
128/*           and with types in <shared_dirent.h> file.                                   */
129
130typedef enum   
131{
132    INODE_TYPE_FILE  =     0,           /*! regular file                                 */
133    INODE_TYPE_DIR   =     1,           /*! directory                                    */
134    INODE_TYPE_FIFO  =     2,           /*! POSIX named pipe                             */
135    INODE_TYPE_PIPE  =     3,           /*! POSIX anonymous pipe                         */
136    INODE_TYPE_SOCK  =     4,           /*! POSIX socket                                 */
137    INODE_TYPE_DEV   =     5,           /*! character device                             */
138    INODE_TYPE_BLK   =     6,           /*! block device                                 */
139    INODE_TYPE_SYML  =     7,           /*! symbolic link                                */
140}
141vfs_inode_type_t;
142
143/* this enum define the VFS inode attributes values */
144
145typedef enum 
146{
147    INODE_ATTR_DIRTY   =     0x01,       /* modified versus the value on device          */ 
148    INODE_ATTR_INLOAD  =     0x04,       /* loading from device in progress              */
149    INODE_ATTR_NEW     =     0x08,       /* not saved on device yet                      */
150}
151vfs_inode_attr_t;
152
153typedef struct vfs_inode_s
154{
155    struct vfs_ctx_s * ctx;              /*! local pointer on FS context                 */
156    uint32_t           inum;             /*! inode identifier (unique in file system)    */
157    uint32_t           attr;             /*! inode attributes (see above)                */
158    vfs_inode_type_t   type;             /*! inode type (see above)                      */
159    uint32_t           size;             /*! number of bytes                             */
160    uint32_t           uid;              /*! user owner identifier                       */
161    uint32_t           gid;              /*! group owner identifier                      */
162    uint32_t           rights;           /*! access rights                               */
163    xlist_entry_t      parents;          /*! root of list of parents dentries            */
164    uint32_t           links;            /*! number of parent dentries (hard links)      */
165    xhtab_t            children;         /*! embedded xhtab of children dentries         */
166    remote_rwlock_t    size_lock;        /*! protect read/write to size                  */
167    remote_rwlock_t    main_lock;        /*! protect inode tree traversal and modifs     */
168    struct mapper_s  * mapper;           /*! associated file cache                       */
169    void             * extend;           /*! fs_type_specific inode extension            */
170}
171vfs_inode_t;
172
173/* This define the masks for the inode <rights> field  */
174
175#define VFS_ISUID          0x0004000
176#define VFS_ISGID          0x0002000
177#define VFS_ISVTX          0x0001000
178
179#define VFS_IRWXU      0x0000700
180#define VFS_IRUSR      0x0000400
181#define VFS_IWUSR      0x0000200
182#define VFS_IXUSR      0x0000100
183
184#define VFS_IRWXG      0x0000070
185#define VFS_IRGRP      0x0000040
186#define VFS_IWGRP      0x0000020
187#define VFS_IXGRP      0x0000010
188
189#define VFS_IRWXO      0x0000007
190#define VFS_IROTH      0x0000004
191#define VFS_IWOTH      0x0000002
192#define VFS_IXOTH      0x0000001
193
194/******************************************************************************************
195 Rpt* This structure defines a directory entry.
196 * A dentry contains the name of a remote file/dir, an extended pointer on the
197 * inode representing this file/dir, a local pointer on the inode representing
198 * the parent directory.
199 * A dentry can be member of the set of children of a given directory inode (xhtab).
200 * A dentry can be member of the set of parents  of a given inode (xlist).
201 *****************************************************************************************/
202
203typedef struct vfs_dentry_s
204{
205    struct vfs_ctx_s   * ctx;            /*! local pointer on FS context                 */
206        char                 name[CONFIG_VFS_MAX_NAME_LENGTH];
207        uint32_t             length;         /*! name length (bytes)                         */
208    struct vfs_inode_s * parent;         /*! local pointer on parent inode               */
209    xptr_t               child_xp;       /*! extended pointer on child inode             */
210    xlist_entry_t        children;       /*! member of set of children dentries          */
211    xlist_entry_t        parents;        /*! member of set of parent dentries            */
212        void               * extend;         /*! FS specific extension                       */
213}
214vfs_dentry_t;
215
216/******************************************************************************************
217 * This file structure describes an open file/directory for a given process.
218 * It is not replicated, and is dynamically allocated in the cluster that contains
219 * the inode, when a thread makes an open() or opendir() system call.
220 * It cannot exist a file structure without an inode structure in same cluster.
221 * As the fd_array (containing extended pointers on the open file descriptors)
222 * is replicated in all process descriptors, we need a references counter.
223 *****************************************************************************************/
224
225typedef enum
226{
227    FD_ATTR_READ_ENABLE    = 0x01,     /*! read access possible                         */
228    FD_ATTR_WRITE_ENABLE   = 0x02,     /*! write access possible                        */
229    FD_ATTR_APPEND         = 0x04,     /*! append on each write                         */
230    FD_ATTR_CLOSE_EXEC     = 0x08,     /*! close file on exec                           */
231    FD_ATTR_SYNC           = 0x10,     /*! synchronise FS on each write                 */
232    FD_ATTR_IS_DIR         = 0x20,     /*! this is a directory                          */
233}
234vfs_file_attr_t;
235
236typedef struct vfs_file_s
237{
238        struct vfs_ctx_s      * ctx;        /*! local pointer on FS context.                 */
239        uint32_t                gc;         /*! generation counter                           */
240        vfs_file_attr_t         attr;       /*! file attributes bit vector (see above)       */
241        vfs_inode_type_t        type;       /*! same type as inode                           */
242        uint32_t                offset;     /*! seek position in file                        */
243        uint32_t                refcount;   /*! all pointers on this file descriptor         */
244        remote_rwlock_t         lock;       /*! protect offset modifications                 */
245        struct mapper_s       * mapper;     /*! associated file cache                        */
246        struct vfs_inode_s    * inode;      /*! local pointer on associated inode            */
247        void                  * extend;     /*! FS specific extension                        */
248}
249vfs_file_t;
250
251
252/******************************************************************************************
253 *        These functions access / modify  a VFS context.
254 *****************************************************************************************/
255
256/******************************************************************************************
257 * This function initialise a (statically allocated) VFS context in local cluster.
258 ******************************************************************************************
259 * @ fs_type        : file system type.
260 * @ attr           : global attributes (for all files in FS.
261 * @ total_clusters : total number of clusters on device.
262 * @ cluster_size   : cluster size on device (bytes).
263 * @ vfs_root_xp    : extended pointer on VFS root inode.
264 * @ extend         : fs_type_specific extension.
265 *****************************************************************************************/
266void vfs_ctx_init( vfs_fs_type_t   type,
267                   uint32_t        attr,
268                       uint32_t        total_clusters,
269                       uint32_t        cluster_size,
270                       xptr_t          vfs_root_xp,
271                   void          * extend );
272
273/******************************************************************************************
274 * This function allocates an inode identifier from the local cluster inum allocator.
275 * The inum respects a fixed format:
276 * - the 16 MSB bits contain the cluster identifier : cxy
277 * - the 16 LSB bits contains the local inode identifier  : lid
278 ******************************************************************************************
279 * @ ctx      : local pointer on file system context.
280 * @ inum     : [ou] buffer for allocated inode identifier.
281 * @ return 0 if success / return non-zero if error.
282 *****************************************************************************************/
283error_t vfs_ctx_inum_alloc( vfs_ctx_t * ctx,
284                            uint32_t  * inum );
285
286/******************************************************************************************
287 * This function release an inode identifier.                                 
288 ******************************************************************************************
289 * @ ctx      : local pointer on file system context.
290 * @ inum     : released inode identifier.
291 *****************************************************************************************/
292void vfs_ctx_inum_release( vfs_ctx_t * ctx,
293                           uint32_t    inum );
294
295
296
297/******************************************************************************************
298 *        These low-level functions access / modify a VFS inode descriptor
299 *****************************************************************************************/
300
301/******************************************************************************************
302 * This function returns a printable string for the inode type.
303 *****************************************************************************************/
304const char * vfs_inode_type_str( vfs_inode_type_t type );
305
306/******************************************************************************************
307 * This function allocates memory from local cluster for an inode descriptor and the
308 * associated mapper, and partially initialise this inode from arguments values.
309 * It does NOT link it to the Inode Tree, as this is done by add_child_in_parent().
310 * It must called by a local thread. Use the RPC_INODE_CREATE if client thread is remote.
311 ******************************************************************************************
312 * @ fs_type    : file system type.
313 * @ inode_type : inode type.
314 * @ attr       : inode attributes.
315 * @ rights     : inode access rights.
316 * @ uid        : user owner ID.
317 * @ gid        : group owner ID.
318 * @ inode_xp   : [out] buffer for extended pointer on created inode.
319 * @ return 0 if success / return ENOMEM or EINVAL if error.
320 *****************************************************************************************/
321error_t vfs_inode_create( vfs_fs_type_t     fs_type,
322                          uint32_t          attr,
323                          uint32_t          rights,
324                          uid_t             uid,
325                          gid_t             gid,
326                          xptr_t          * inode_xp );
327
328/******************************************************************************************
329 * This function releases memory allocated to an inode descriptor, including
330 * all memory allocated to the mapper (both mapper descriptor and radix tree).
331 * The mapper should not contain any dirty page (should be synchronized before deletion).
332 * It must be executed by a thread running in the cluster containing the inode.
333 * Use the rpc_vfs_inode_destroy_client() function if required.
334 ******************************************************************************************
335 * @ inode  : local pointer on inode descriptor.
336 *****************************************************************************************/
337void vfs_inode_destroy( vfs_inode_t *  inode ); 
338
339/******************************************************************************************
340 * This function returns the <size> of a file/dir from a remote inode,
341 * taking the remote_rwlock protecting <size> in READ_MODE.
342 *****************************************************************************************
343 * @ inode_xp  : extended pointer on the remote inode.
344 * @ return the current size.
345 *****************************************************************************************/
346uint32_t vfs_inode_get_size( xptr_t inode_xp );
347
348/******************************************************************************************
349 * This function updates the "size" field of a remote inode identified by <inode_xp>.
350 * It takes the rwlock protecting the file size in WRITE_MODE, and set the "size" field
351 * when the current size is smaller than the requested <size> argument.
352 *****************************************************************************************
353 * @ inode_xp  : extended pointer on the remote inode.
354 * @ size      : requested size value.
355 *****************************************************************************************/
356void vfs_inode_update_size( xptr_t   inode_xp,
357                            uint32_t size );
358
359/******************************************************************************************
360 * This function takes the main lock of a remote inode.
361 * This lock protect all inode fields, including the children dentries.
362 *****************************************************************************************
363 * @ inode_xp  : extended pointer on the remote inode.
364 *****************************************************************************************/
365void vfs_inode_lock( xptr_t inode_xp );
366
367/******************************************************************************************
368 * This function releases the main lock of a remote inode.
369 * This lock protect all inode fiels, including the children dentries.
370 *****************************************************************************************
371 * @ inode_xp  : extended pointer on the remote inode.
372 *****************************************************************************************/
373void vfs_inode_unlock( xptr_t inode_xp );
374
375/******************************************************************************************
376 * This debug function copies the name of a remote inode identified by the <inode_xp>
377 * argument to a local buffer identified by the <name> argument.
378 * The local buffer size must be at least CONFIG_VFS_MAX_NAME_LENGTH.
379 ******************************************************************************************
380 * @ inode_xp  : extended pointer on the remote inode.
381 * @ name      : local buffer pointer.
382 *****************************************************************************************/
383void vfs_inode_get_name( xptr_t inode_xp,
384                         char * name );
385
386/******************************************************************************************
387 * This function accesses successively all pages of a file identified by the <inode>,
388 * argument, to force misses, and load all pages into mapper.
389 * The target inode can be a directory or a file, but this function is mainly used
390 * to prefetch a complete directory to the mapper.
391 * It must be executed by a thread running in the cluster containing the inode.
392 * This function does NOT take any lock.
393 ******************************************************************************************
394 * @ inode  : local pointer on inode.
395 * @ return 0 if success / return -1 if device access failure.
396 *****************************************************************************************/
397error_t vfs_inode_load_all_pages( vfs_inode_t * inode );
398
399/******************************************************************************************
400 * This debug function display the curren state of an inode descriptor identified by
401 * the <inode_xp> argument.
402 *****************************************************************************************/
403void vfs_inode_display( xptr_t inode_xp );
404
405/******************************************************************************************
406 *        These low-level functions access / modify a VFS dentry descriptor
407 *****************************************************************************************/
408
409/******************************************************************************************
410 * This function allocates memory from local cluster for a dentry descriptor,
411 * initialises it from  arguments values, and returns the extended pointer on dentry.
412 * It must called by a local thread. Use the RPC_DENTRY_CREATE if client thread is remote.
413 ******************************************************************************************
414 * @ fs_type    : [in]  file system type.
415 * @ name       : [in]  directory entry file/dir name.
416 * @ dentry_xp  : [out] buffer for extended pointer on created dentry.
417 * @ return 0 if success / return ENOMEM or EINVAL if error.
418 *****************************************************************************************/
419error_t vfs_dentry_create( vfs_fs_type_t   fs_type,
420                           char          * name,
421                           xptr_t        * dentry_xp );
422 
423/******************************************************************************************
424 * This function removes the dentry from the parent inode xhtab, and releases the memory
425 * allocated to the dentry descriptor.
426 * It must be executed by a thread running in the cluster containing the dentry.
427 * Use the RPC_DENTRY_DESTROY if required.
428 ******************************************************************************************
429 * @ dentry  : [in] local pointer on dentry descriptor.
430 *****************************************************************************************/
431void vfs_dentry_destroy( vfs_dentry_t *  dentry ); 
432
433
434/******************************************************************************************
435 *        These low-level functions access / modify a VFS file descriptor
436 *****************************************************************************************/
437
438/******************************************************************************************
439 * This function allocates memory and initializes a new local file descriptor.
440 * It must be executed in the cluster containing the inode.
441 * If the client thread is not running in the owner cluster, it must use the
442 * rpc_vfs_file_create_client() function.
443 ******************************************************************************************
444 * @ inode    : local pointer on associated inode.
445 * @ attr     : file descriptor attributes.
446 * @ file_xp  : [out] buffer for extended pointer on created file descriptor.
447 * @ return 0 if success / return ENOMEM if error.
448 *****************************************************************************************/
449error_t vfs_file_create( vfs_inode_t * inode,
450                         uint32_t      attr,
451                         xptr_t      * file_xp ); 
452
453/******************************************************************************************
454 * This function releases memory allocated to a local file descriptor.
455 * It must be executed by a thread running in the cluster containing the inode,
456 * and the file refcount must be zero. Use the RPC_VFS_FILE_DESTROY if required.
457 ******************************************************************************************
458 * @ file  : local pointer on file descriptor.
459 *****************************************************************************************/
460void vfs_file_destroy( vfs_file_t *  file ); 
461
462/******************************************************************************************
463 * These functions increment (resp. decrement) the count field in a remote file
464 * descriptor, using a remote_atomic access.
465 *****************************************************************************************/
466void vfs_file_count_up  ( xptr_t   file_xp );
467void vfs_file_count_down( xptr_t   file_xp );
468
469/******************************************************************************************
470 * This debug function copies the name of a the file identified by <file_xp>
471 * argument to a local buffer identified by the <name> argument.
472 * The local buffer size must be at least CONFIG_VFS_MAX_NAME_LENGTH.
473 *****************************************************************************************
474 * @ file_xp  : extended pointer on the remote inode.
475 * @ name     : local buffer pointer.
476 *****************************************************************************************/
477void vfs_file_get_name( xptr_t inode_xp,
478                        char * name );
479
480
481
482
483/******************************************************************************************
484 *        These functions access / modify the distributed VFS Inode Tree
485 *****************************************************************************************/
486
487/******************************************************************************************
488 * This function returns in a kernel <buffer> allocated by the caller function,
489 * the pathname of a file/dir identified by the <inode_xp> argument.
490 * It traverse the Inode Tree from the target node to the root.
491 * It can be called by any thread running in any cluster.
492 * As this buffer if filled in "reverse order" (i.e. from the target inode to the root),
493 * the pathname is stored in the higher part of the buffer.
494 * A pointer on the first character of the pathname is returned in <first> buffer.
495 *
496 * WARNING : This function takes & releases the remote_rwlock protecting the Inode Tree.
497 ******************************************************************************************
498 * @ inode_xp    : [in]  extended pointer on target inode descriptor.
499 * @ buffer      : [in]  kernel buffer for pathname (allocated by caller).
500 * @ first       : [out] pointer on first character in buffer.
501 * @ max_size    : [in]  max number of characters in buffer.
502 * @ return 0 if success / return EINVAL if buffer too small.
503 *****************************************************************************************/
504error_t vfs_get_path( xptr_t    inode_xp,
505                      char    * buffer,
506                      char   ** first,
507                      uint32_t  max_size );
508
509/******************************************************************************************
510 * This function traverses the the Inode Tree, from inode identified by the <root_xp>
511 * argument, and returns in <inode_xp> the inode identified by the < pathname> argument.
512 * It can be called by a thread running in any cluster.
513 * It supports the following flags that define the lookup modes :
514 * - VFS_LOOKUP_DIR    : the searched inode must be a directory
515 * - VFS_LOOKUP_OPEN   : the search is for an open/opendir
516 * - VFS_LOOKUP_PARENT : return the parent inode (not the inode itself)
517 * - VFS_LOOKUP_CREATE : file/directory must be created if missing on IOC
518 * - VFS_LOOKUP_EXCL   : file cannot previously exist
519 * As the inode Tree is a cache, the search policy is the following :
520 * - If a given directory name in the path is not found in the inode tree, it try to load
521 *   the missing dentry/inode couple, from informations found in the parent directory.
522 * - If this directory entry does not exist on IOC, it returns an error.
523 * - If the the file identified by the pathname does not exist on IOC but the
524 *   flag CREATE is set, the inode is created. It returns an error otherwise.
525 * - If the the file identified by the pathname exist on device, but both flags EXCL
526 *   and CREATE are set, an error is returned.
527 * - If the PARENT flag is set, it returns in <inode_xp> an extended pointer on the parent
528 *   inode, and copies in <last_name> buffer a string containing the last name in path.
529 *
530 * WARNING : The remote_rwlock protecting the Inode Tree must be taken by the caller.
531 *
532 * TODO the access rights are not checked yet.
533 ******************************************************************************************
534 * @ root_xp     : [in]  extended pointer on root inode (can be root of a subtree).
535 * @ pathname    : [in]  path (can be relative or absolute).
536 * @ lookup_mode : [in]  flags defining the searching mode.
537 * @ inode_xp    : [out] buffer for extended pointer on searched inode.
538 * @ last_name   : [out] pointer on buffer for last name in path.
539 * @ return 0 if success / ENOENT if inode not found , EACCES if permisson denied,
540 *****************************************************************************************/
541error_t vfs_lookup( xptr_t             root_xp,
542                    char             * pathname,
543                    uint32_t           lookup_mode,
544                                        xptr_t           * inode_xp,
545                    char             * last_name );
546
547/******************************************************************************************
548 * This function creates a new couple dentry/inode, and insert it in the Inode-Tree.
549 * Only the distributed Inode Tree is modified: it does NOT modify the parent mapper,
550 * and does NOT update the FS on IOC device.
551 * It set the inode type to the default INODE_TYPE_FILE value
552 * It can be executed by any thread running in any cluster (can be different from both
553 * the child cluster and the parent cluster).
554 * The new child inode and the parent inode can have different FS types.
555 * [Implementation note]
556 * As there are cross-references between inode and dentry, this function implements
557 * a five steps scenario :
558 * 1) The dentry descriptor is created in the cluster containing the existing <parent_xp>
559 *    inode, and partially initialized, using the RPC_VFS_CREATE DENTRY if required.
560 * 2) The inode and its associated mapper are created in cluster identified by <child_cxy>,
561 *    and partially initialised, using the RPC_VFS_CREATE_INODE if required.
562 * 3) The pointers on dentry in parent inode are updated, using remote access.
563 * 4) The pointers on dentry in child inode are updated, using remotes access.
564 * 5) The pointers on parent and child inode in dentry are updated, using remotes access.
565 *****************************************************************************************
566 * @ child_inode_cxy  : [in]  target cluster for child inode.
567 * @ fs_type          : [in]  child inode FS type.
568 * @ parent_inode_xp  : [in]  extended pointer on parent inode.
569 * @ name             : [in]  new directory entry name.
570 * @ dentry_xp        : [out] buffer for extended pointer on dentry
571 * @ child_inode_xp   : [out] buffer for extended pointer on child inode.
572 * @ return 0 if success / -1 if dentry or inode cannot be created.
573 *****************************************************************************************/
574error_t vfs_add_child_in_parent( cxy_t              child_inode_cxy,
575                                 vfs_fs_type_t      fs_type,
576                                 xptr_t             parent_inode_xp,
577                                 char             * name,
578                                 xptr_t           * dentry_xp,   
579                                 xptr_t           * child_inode_xp );
580
581/******************************************************************************************
582 * This function removes a remote dentry from the Inode-Tree.
583 * - It removes the dentry from the parent inode xhtab ("children" field), and from the
584 *   child inode xlist ("parents" field).
585 * - It releases the memory allocated to the dentry descriptor.
586 * - If the number of parents of the child inode is one, it also releases the memory
587 *   allocated to the child inode.
588 * Only the Inode Tree is modified: it does NOT modify the parent mapper,
589 * and does NOT update the FS on IOC device.
590 * It can be executed by any thread running in any cluster (can be different from both
591 * the inode cluster and the dentry cluster).
592 ******************************************************************************************
593 * @ dentry_xp   : extended pointer on removed dentry.
594 *****************************************************************************************/
595void vfs_remove_child_from_parent( xptr_t dentry_xp );
596
597/******************************************************************************************
598 * This function is called by the vfs_lookup() function when a new (dentry/inode) must
599 * be created from scratch and introduced in both the parent mapper and the IOC device.
600 * The dentry and inode descriptors must have been previously created by the caller.
601 * 1. It allocates one cluster from the relevant FS, updates the FAT mapper,
602 *    and synchronously update the IOC device).
603 * 2. It set the "size", and "extend" fields in child inode descriptor.
604 * 3. It updates the parent directory mapper to introduce the new child,
605 *    and synchronously update the IOC device.
606 * 4. It set the "extend" field in dentry descriptor.
607 * It can be called by a thread running in any cluster.
608 ******************************************************************************************
609 * @ parent_xp   : extended pointer on parent inode descriptor.
610 * @ dentry_xp   : extended pointer on new dentry descriptor.
611 * @ child_xp    : extended pointer on child inode descriptor.
612 * @ return 0 if success / -1 if failure.
613 *****************************************************************************************/
614error_t vfs_new_dentry_init( xptr_t   parent_xp,
615                             xptr_t   dentry_xp,
616                             xptr_t   child_xp );
617
618/******************************************************************************************
619 * This function creates in the directory identified by the <child_xp> argument,
620 * the two special dentries <.> and <..>. The parent directory inode is defined
621 * by the <parent_xp> argument. The two dentries are introduced in the Inode Tree.
622 * They are also introduced in the child directory mapper, and the IOC device is updated.
623 * This function is called by all functions creating a brand new directory : vfs_mkdir(),
624 * devfs_global_init(), and devfs_local_init().
625 ******************************************************************************************
626 * @ child_xp    : extended pointer on new directory inode.
627 * @ parent_xp   : extended pointer on parent directory inode.
628 * @ return 0 if success / -1 if failure.
629 *****************************************************************************************/
630error_t vfs_add_special_dentries( xptr_t  child_xp,
631                                  xptr_t  parent_xp );
632
633/******************************************************************************************
634 * This recursive function diplays a complete inode/dentry sub-tree.
635 * Any inode can be selected as the sub-tree root.
636 * WARNING : this function is not protected against a concurrent inode/dentry removal...
637 ******************************************************************************************
638 * @ inode_xp   : extended pointer on sub-tree root inode.
639 *****************************************************************************************/
640void vfs_display( xptr_t   inode_xp );
641
642/******************************************************************************************
643 * This function mount a given file system type for a given process
644 * TODO non implemented yet [AG].     
645 *****************************************************************************************/
646error_t vfs_mount_fs_root( struct device_s  * device,
647                                       uint32_t           fs_type,
648                                       struct process_s * process );
649
650
651
652
653/******************************************************************************************
654 *        These functions define the VFS "syscalls" API (user commands)
655 *****************************************************************************************/
656
657/******************************************************************************************
658 * This function moves <size> bytes between a remote file mapper, identified by the
659 * <file_xp> argument, and a - possibly distributed - user space <buffer>, taken into
660 * account the offset in <file_xp>. The transfer direction is defined by <to_buffer>.
661 * It is called by the sys_read() and sys_write() functions.
662 ******************************************************************************************
663 * @ to_buffer : mapper -> buffer if true / buffer -> mapper if false.
664 * @ file_xp   : extended pointer on the remote file descriptor.
665 * @ buffer    : user space pointer on buffer (can be physically distributed).
666 * @ size      : requested number of bytes from offset.
667 * @ returns number of bytes actually moved if success / -1 if error.
668 *****************************************************************************************/
669int vfs_user_move( bool_t   to_buffer,
670                   xptr_t   file_xp, 
671                   void   * buffer,
672                   uint32_t size );
673
674/******************************************************************************************
675 * This function moves <size> bytes between a remote file mapper, identified by the
676 * <file_xp> argument, and a - possibly remote - kernel <buffer_xp>, taken into
677 * account the offset in <file_xp>. The transfer direction is defined by <to_buffer>.
678 * It is called by the elf_load_process() function.
679 ******************************************************************************************
680 * @ to_buffer : mapper -> buffer if true / buffer -> mapper if false.
681 * @ file_xp   : extended pointer on the remote file descriptor.
682 * @ buffer_xp : user space pointer on buffer (can be physically distributed).
683 * @ size      : requested number of bytes from offset.
684 * @ returns 0 if success / -1 if error.
685 *****************************************************************************************/
686error_t vfs_kernel_move( bool_t   to_buffer,
687                         xptr_t   file_xp, 
688                         xptr_t   buffer_xp,
689                         uint32_t size );
690
691/******************************************************************************************
692 * This function allocates a vfs_file_t structure in the cluster containing the inode
693 * identified by the <root_xp> & <path> arguments.
694 * It initializes it, register it in the reference process fd_array identified by the
695 * <process_xp> argument, and returns both the extended pointer on the file descriptor,
696 * and the allocated index in the <file_xp> and <file_id> buffers.
697 * The pathname can be relative to current directory or absolute.
698 * If the inode does not exist in the inode cache, it try to find the file on the IOC
699 * device, and creates an inode on a pseudo randomly selected cluster if found.
700 * It the requested file does not exist on device, it creates a new inode if the
701 * O_CREAT flag is set, and return an error otherwise.
702 *
703 * WARNING : this function takes & releases the remote_rwlock protecting the Inode Tree.
704 ******************************************************************************************
705 * @ root_xp     : extended pointer on path root inode.
706 * @ path        : file pathname (absolute or relative to current directory).
707 * @ process_xp  : extended pointer on client reference process.
708 * @ flags       : defined in vfs_file_t structure.
709 * @ mode        : access rights (as defined by chmod).
710 * @ file_xp     : [out] buffer for extended pointer on created remote file descriptor.
711 * @ file_id     : [out] buffer for created file descriptor index in reference fd_array.
712 * @ return 0 if success / return non-zero if error.
713 *****************************************************************************************/
714error_t vfs_open( xptr_t             root_xp,
715                          char             * path,
716                  xptr_t             process_xp,
717                          uint32_t           flags,
718                  uint32_t           mode,
719                          xptr_t           * file_xp,
720                          uint32_t         * file_id );
721
722/******************************************************************************************
723 * This function set a new value in the offset of the open file descriptor <file_xp>.
724 * This value depends on the <whence> argument:
725 * - if VFS_SEEK_SET, new value is <offset>
726 * - if VFS_SEEK_CUR, new value is current_offset + <offset>
727 * - if VFS_SEEK_END, new value is file_size + <offset>
728 ******************************************************************************************
729 * @ file_xp   : extended pointer on the remote open file descriptor.
730 * @ offset    : local pointer on source kernel buffer.
731 * @ whence    : VFS_SEEK_SET / VFS_SEEK_CUR / VFS_SEEK_END.
732 * @ new_offset : [out] buffer for new offset value.
733 * @ returns 0 if success / -1 if error.
734 *****************************************************************************************/
735error_t vfs_lseek( xptr_t     file_xp,
736                   uint32_t   offset,
737                   uint32_t   whence, 
738                   uint32_t * new_offset );
739
740/******************************************************************************************
741 * This function close the - non-replicated - file descriptor identified by the <file_xp>
742 * and <file_id> arguments. The <file_id> is required to reset the fd_array[] slot.
743 * It can be called by a thread running in any cluster, and executes the following actions:
744 * 1) It access the block device to updates all dirty pages from the mapper associated
745 *    to the file, and removes these pages from the dirty list, using an RPC if required.
746 * 2) It updates the file size in all parent directory mapper(s), and update the modified
747 *    pages on the block device, using RPCs if required.
748 * 3) All entries in the fd_array copies are directly reset by the calling thread,
749 *    using remote accesses.
750 * 4) The memory allocated to file descriptor in cluster containing the inode is released,
751 *    using an RPC if cluster containing the file descriptor is remote.
752 ******************************************************************************************
753 * @ file_xp     : extended pointer on the file descriptor.
754 * @ file_id     : file descriptor index in fd_array[].
755 * @ returns 0 if success / -1 if error.
756 *****************************************************************************************/
757error_t vfs_close( xptr_t    file_xp,
758                   uint32_t  file_id );
759
760/******************************************************************************************
761 * This function is called by the kernel to create in the file system a new directory
762 * identified by the <root_xp> & <path> arguments, with the access permission defined
763 * by the <rights> argument. All nodes in the path - but the last -  must exist.
764 *
765 * WARNING : this function takes & releases the remote_rwlock protecting the Inode Tree.
766 ******************************************************************************************
767 * @ root_xp : extended pointer on path root inode (any inode in Inode Tree).
768 * @ path    : pathname (absolute or relative to current directory).
769 * @ rights  : access rights.
770 * @ returns 0 if success / -1 if error.
771 *****************************************************************************************/
772error_t vfs_mkdir( xptr_t   root_xp,
773                   char   * path,
774                   uint32_t rights );
775
776/******************************************************************************************
777 * This function is called by the kernel to create in the file system a new directory
778 * entry identified by the <new_root_xp> & <new_path> arguments, to be linked to an
779 * existing inode, identified by the  <old_root_xp> & <old_path> arguments.
780 * If the link is successful, the link count of the target inode is incremented.
781 * The <new_path> and <old_path> share equal access rights to the underlying inode.
782 * Both the IOC device and the Inode Tree are modified.
783 $
784 * TODO This function should handle any type of node, but the current implementation
785 * handles only the FILE and DIR types.
786 *
787 * WARNING : this function takes & releases the remote_rwlock protecting the Inode Tree.
788 ******************************************************************************************
789 * @ old_root_xp : extended pointer on old path root inode (any inode in Inode Tree).
790 * @ old_path    : old pathname (absolute or relative to current directory).
791 * @ nld_root_xp : extended pointer on new path root inode (any inode in Inode Tree).
792 * @ new_path    : new pathname (absolute or relative to current directory).
793 * @ returns 0 if success / -1 if error.
794 *****************************************************************************************/
795error_t vfs_link( xptr_t   old_root_xp,
796                  char   * old_path,
797                  xptr_t   new_root_xp,
798                  char   * new_path );
799
800/******************************************************************************************
801 * This function is called by the kernel to remove from the file system a directory entry
802 * identified by the  <root_xp> & <path> arguments.
803 * The link count of the target node is decremented.
804 * If the removed link is the last, the target inode is deleted.
805 * Both the IOC device and the Inode Tree are modified.
806 *
807 * TODO This function should handle any type of node, but the current implementation
808 * handles only only the FILE and DIR types.
809 *
810 * WARNING : this function takes & releases the remote_rwlock protecting the Inode Tree.
811 ******************************************************************************************
812 * @ root_xp  : extended pointer on root inode (can be any inode in Inode Tree).
813 * @ path     : pathname (absolute or relative to current directory).
814 * @ returns 0 if success / -1 if error.
815 *****************************************************************************************/
816error_t vfs_unlink( xptr_t   root_xp,
817                    char   * path );
818
819/******************************************************************************************
820 * This function returns, in the structure pointed by the <st> pointer, various
821 * informations on the inode identified by the <root_inode_xp> and <patname> arguments.
822 *
823 * TODO : only partially implemented yet (only size and inum fields).
824 *
825 * WARNING : this function takes & releases the remote_rwlock protecting the Inode Tree.
826 ******************************************************************************************
827 * @ root_xp    : extended pointer on path root inode (any inode in Inode Tree)
828 * @ pathname   : pathname to target inode.
829 * @ st         : local pointer on the stat structure in kernel space.
830 * @ returns 0 if success / -1 if error.
831 *****************************************************************************************/
832error_t vfs_stat( xptr_t        root_xp,
833                  char        * pathname,
834                  struct stat * st );
835
836/******************************************************************************************
837 * This function  creates a new directory as defined by the <root_xp> & <path> arguments.
838 * TODO not implemented yet...
839 ******************************************************************************************
840 * @ root_xp  : extended pointer on the path root directory.
841 * @ path     : pathname (absolute or relative to CWD).                     
842 * @ mode     : access rights (as defined by chmod)
843 * @ returns 0 if success / -1 if error.
844 *****************************************************************************************/
845error_t vfs_mkdir( xptr_t     root_xp,
846                   char     * path,
847                   uint32_t   mode );
848
849/******************************************************************************************
850 * This function makes the directory identified by the <root_xp and <path> arguments
851 * to become the working directory for the calling process.
852 ******************************************************************************************
853 * @ root_xp  : extended pointer on the path root directory.
854 * @ path     : pathname (absolute or relative to CWD).
855 * return 0 if success / -1 if error.
856 *****************************************************************************************/
857error_t vfs_chdir( xptr_t   root_xp,
858                   char   * path );
859
860/******************************************************************************************
861 * This function change the access rigths for the file/directory identified by the
862 * <root_xp> and <path> arguments as defined by the <mode> argument value.
863 ******************************************************************************************
864 * @ root_xp  : extended pointer on the path root directory.
865 * @ path     : pathname (absolute or relative to CWD).
866 * @ mode     : access rights
867 * return 0 if success / -1 if error.
868 *****************************************************************************************/
869error_t vfs_chmod( xptr_t        root_xp,
870                   char        * path,
871                   uint32_t      mode );
872
873/******************************************************************************************
874 * This function creates a named FIFO file.
875 * TODO not implemented yet                                                         
876 ******************************************************************************************
877 * @ root_xp  : extended pointer on the path root directory.
878 * @ path     : pathname (absolute or relative to CWD).
879 * @ mode     : access rights new value.
880 *****************************************************************************************/
881error_t vfs_mkfifo( xptr_t       root_xp,
882                    char       * path,
883                    uint32_t     mode );
884
885
886
887
888
889/******************************************************************************************
890 *        These functions define the VFS "FS" API to a specific File System
891 *****************************************************************************************/
892
893/******************************************************************************************
894 * This function makes the I/O operation to move one page identified by the <page_xp>
895 * argument to/from the IOC device from/to the mapper, as defined by the <cmd_type>.
896 * Depending on the file system type, it calls the proper, FS specific function.
897 * It is used in case of MISS on the mapper, or when a dirty page in the mapper must
898 * be updated in the File System.
899 * The mapper pointer is obtained from the page descriptor.
900 * It can be executed by any thread running in any cluster.
901 * This function does NOT take any lock.
902 ******************************************************************************************
903 * @ page_xp   : extended pointer on page descriptor (for mapper and page_id).
904 * @ cmd_type  : IOC_READ / IOC_WRITE / IOC_SYNC_READ / IOC_SYNC_WRITE
905 * @ returns 0 if success / return -1 if device access failure.
906 *****************************************************************************************/
907error_t vfs_fs_move_page( xptr_t      page_xp,
908                          cmd_type_t  cmd_type );
909
910/******************************************************************************************
911 * This function updates the mapper associated to a directory inode identified by the
912 * <parent> argument, to add a new entry identified by the <dentry> argument.
913 * The directory inode descriptor and the dentry descriptor are in the same cluster.
914 * Depending on the file system type, it calls the proper, FS specific function.
915 * It also updates the dentry descriptor and/or the inode descriptor extensions
916 * as required by the specific file system type.
917 * Finally, it synchronously updates the parent directory on IOC device.
918 *
919 * It must be executed by a thread running in the cluster containing the parent directory.
920 * It can be the RPC_VFS_FS_ADD_DENTRY. This function does NOT take any lock.
921 ******************************************************************************************
922 * @ parent  : local pointer on parent (directory) inode.
923 * @ dentry  : local pointer on dentry containing name.
924 * @ return 0 if success / return -1 if device access failure.
925 *****************************************************************************************/
926error_t vfs_fs_add_dentry( vfs_inode_t  * parent,
927                           vfs_dentry_t * dentry );
928
929/******************************************************************************************
930 * This function updates the mapper associated to a directory inode identified by the
931 * <parent> argument, to remove an entry identified by the <dentry> argument.
932 * The directory inode descriptor and the dentry descriptor are in the same cluster.
933 * Depending on the file system type, it calls the proper, FS specific function.
934 * Finally, it synchronously updates the parent directory on IOC device.
935 *
936 * Depending on the file system type, it calls the relevant, FS specific function.
937 * It must be executed by a thread running in the cluster containing the parent directory.
938 * It can be the RPC_VFS_FS_REMOVE_DENTRY. This function does NOT take any lock.
939 ******************************************************************************************
940 * @ parent  : local pointer on parent (directory) inode.
941 * @ dentry  : local pointer on dentry containing name.
942 * @ return 0 if success / return -1 if device access failure.
943 *****************************************************************************************/
944error_t vfs_fs_remove_dentry( vfs_inode_t  * parent,
945                              vfs_dentry_t * dentry );
946
947/******************************************************************************************
948 * This function scan the mapper of an an existing parent inode directory, identified by
949 * the <parent> argument to find a directory entry identified by the <name> argument,
950 * and updates both the child inode descriptor, identified by the <child_xp> argument,
951 * and the associated dentry descriptor :
952 * - It set the "size", "type", and "extend" fields in inode descriptor.
953 * - It set the "extend" field in dentry descriptor.
954 * It is called by the vfs_lookup() function in case of miss.
955 *
956 * Depending on the file system type, it calls the relevant, FS specific function.
957 * It must be called by a thread running in the cluster containing the parent inode.
958 * It can be the RPC_VFS_FS_NEW_DENTRY. This function does NOT take any lock.
959 ******************************************************************************************
960 * @ parent    : local pointer on parent inode (directory).
961 * @ name      : child name.
962 * @ child_xp  : extended pointer on remote child inode (file or directory)
963 * @ return 0 if success / return -1 if dentry not found.
964 *****************************************************************************************/
965error_t vfs_fs_new_dentry( vfs_inode_t * parent,
966                           char        * name,
967                           xptr_t        child_xp );
968
969/******************************************************************************************
970 * This function scan the mapper of an an existing inode directory, identified by
971 * the <inode> argument, to find a directory entry identified by the <dentry> argument,
972 * and update the size for this directory entry in mapper, as defined by <size>.
973 * The parent directory on device is synchronously updated.
974 * It is called by the vfs_close() function.
975 *
976 * Depending on the file system type, it calls the relevant, FS specific function.
977 * It must be called by a thread running in the cluster containing the parent inode.
978 * It can be the RPC_VFS_FS_UPDATE_DENTRY. This function does NOT take any lock.
979 ******************************************************************************************
980 * @ parent    : local pointer on parent inode (directory).
981 * @ dentry    : local pointer on dentry.
982 * @ size      : new size value (bytes).
983 * @ return 0 if success / return ENOENT if not found.
984 *****************************************************************************************/
985error_t vfs_fs_update_dentry( vfs_inode_t  * inode,
986                              vfs_dentry_t * dentry,
987                              uint32_t       size );
988
989/******************************************************************************************
990 * This function scan the mapper of an an existing parent inode directory, identified by
991 * the <inode> argument and copy up to <max_dirent> valid dentries to a
992 * local dirent array, defined by the <array> argument. The <min_dentry> argument defines
993 * the index of the first dentry to copied to the target dirent array.
994 * This function returns in the <entries> buffer the number of dentries actually written,
995 * and signals in the <done> buffer when the last valid entry has been found.
996 * If the <detailed> argument is true, a dentry/inode couple that does not exist in
997 * the Inode Tree is dynamically created, and all dirent fiels are documented in the
998 * dirent array. Otherwise, only the dentry name is documented.
999 *
1000 * Depending on the file system type, it calls the relevant, FS specific function.
1001 * It must be called by a thread running in the cluster containing the parent inode.
1002 * This function does NOT take any lock.
1003 ******************************************************************************************
1004 * @ inode      : [in]  local pointer on directory inode.
1005 * @ array      : [in]  local pointer on array of dirents.
1006 * @ max_dirent : [in]  max number of slots in dirent array.
1007 * @ min_dentry : [in]  index of first dentry to be copied into array.
1008 * @ detailed   : [in]  dynamic inode creation if true.
1009 * @ entries    : [out] number of dentries actually copied into array.
1010 * @ done       : [out] Boolean true when last entry found.
1011 * @ return 0 if success / return -1 if failure.
1012 *****************************************************************************************/
1013error_t vfs_fs_get_user_dir( vfs_inode_t   * inode,
1014                             struct dirent * array,
1015                             uint32_t        max_dirent,
1016                             uint32_t        min_dentry,
1017                             bool_t          detailed,
1018                             uint32_t      * entries,
1019                             bool_t        * done );
1020 
1021/*****************************************************************************************
1022 * This function  updates the FS on the IOC device for a given inode identified by
1023 * the <inode> argument. It scan all pages registered in the associated mapper,
1024 * and copies from mapper to device each page marked as dirty.
1025 * WARNING : The target <inode> cannot be a directory, because all modifications in a
1026 * directory are synchronously done on the IOC device by the two vfs_fs_add_dentry()
1027 * and vfs_fs_remove_dentry() functions.
1028 *
1029 * Depending on the file system type, it calls the relevant, FS specific function.
1030 * It must be called by a thread running in the inode cluster.
1031 *****************************************************************************************
1032 * @ inode   : local pointer on inode.
1033 * @ return 0 if success / return EIO if failure during device access.
1034 ****************************************************************************************/
1035error_t vfs_fs_sync_inode( struct vfs_inode_s * inode );
1036
1037/*****************************************************************************************
1038 * This function updates the FS defined by the <fs_type> argument on the IOC device
1039 * for the FAT itself. It scan all clusters registered in the FAT mapper, and copies
1040 * to device each page marked as dirty.
1041 *
1042 * Depending on the file system type, it calls the relevant, FS specific function.
1043 * It can be called by a thread running in any cluster.
1044 *****************************************************************************************
1045 * @ fs_type   : specific file system type.
1046 * @ return 0 if success / return EIO if failure during device access.
1047 ****************************************************************************************/
1048error_t vfs_fs_sync_fat( vfs_fs_type_t fs_type );
1049
1050/*****************************************************************************************
1051 * This function updates the free clusters info on the IOC device for the FS defined
1052 * by the <fs_type> argument.
1053 *
1054 * Depending on the file system type, it calls the relevant, FS specific function.
1055 * It can be called by a thread running in any cluster.
1056 *****************************************************************************************
1057 * @ fs_type   : specific file system type.
1058 * @ return 0 if success / return EIO if failure during device access.
1059 ****************************************************************************************/
1060error_t vfs_fs_sync_free_info( vfs_fs_type_t fs_type );
1061
1062/******************************************************************************************
1063 * This function allocates a free cluster from the FS identified by the <fs_type>
1064 * argument. It updates the selected FS File Allocation Table.
1065 *
1066 * Depending on the file system type, it calls the relevant, FS specific function.
1067 * It can be called by a thread running in any cluster.
1068 ******************************************************************************************
1069 * @ fs_type   : [in]  File System type.
1070 * @ cluster   : [out] cluster index in File system.
1071 * @ return 0 if success / return -1 if no free cluster
1072 *****************************************************************************************/
1073error_t vfs_fs_cluster_alloc( uint32_t   fs_type,
1074                              uint32_t * cluster );
1075
1076/******************************************************************************************
1077 * This function makes all I/O operations required to release all clusters allocated
1078 * on IOC device to a given inode, identified by the <inode_xp> argument.
1079 * Depending on the file system type, it calls the proper, FS specific function.
1080 * It is called by the vfs_unlink() function.
1081 * It can be executed by a thread running in any cluster.
1082 * This function does NOT take any lock.
1083 ******************************************************************************************
1084 * @ inode_xp  : extended pointer on inode.
1085 * @ return 0 if success / return -1 if device access failure.
1086 *****************************************************************************************/
1087error_t vfs_fs_release_inode( xptr_t  inode_xp ); 
1088
1089
1090#endif  /* _VFS_H_ */
Note: See TracBrowser for help on using the repository browser.