Index: trunk/kernel/vfs/vfs.h
===================================================================
--- trunk/kernel/vfs/vfs.h	(revision 101)
+++ trunk/kernel/vfs/vfs.h	(revision 188)
@@ -132,7 +132,7 @@
 	vfs_fs_type_t  type;                     /*! File System type                        */
 	uint32_t	   attr;                     /*! global attributes for all files in FS   */
-	uint32_t       count;                    /*! total number of clusters on device      */
-	uint32_t       blksize;                  /*! device cluster size (bytes)             */
-	xptr_t         root_xp;                  /*! extended pointer on root inode          */
+	uint32_t       total_clusters;           /*! total number of clusters on device      */
+	uint32_t       cluster_size;             /*! cluster size on device (bytes)          */
+	xptr_t         vfs_root_xp;              /*! extended pointer on VFS root inode      */
     spinlock_t     lock;                     /*! lock protecting inum allocator          */
     uint32_t       bitmap[BITMAP_SIZE(CONFIG_VFS_MAX_INODES)];  /* inum allocator        */
@@ -160,11 +160,11 @@
 typedef enum   
 {
-    INODE_TYPE_FILE    =     0x001,      /*! file                                        */
-    INODE_TYPE_DIR     =     0x002,      /*! directory                                   */
-    INODE_TYPE_FIFO    =     0x004,      /*! POSIX named pipe                            */
-    INODE_TYPE_PIPE    =     0x008,      /*! POSIX anonymous pipe                        */
-    INODE_TYPE_SOCKET  =     0x010,      /*! POSIX socket                                */
-    INODE_TYPE_DEV     =     0x020,      /*! character peripheral channel                */
-    INODE_TYPE_SYML    =     0x080,      /*! symbolic link                               */
+    INODE_TYPE_FILE  =     0x001,      /*! file                                          */
+    INODE_TYPE_DIR   =     0x002,      /*! directory                                     */
+    INODE_TYPE_FIFO  =     0x004,      /*! POSIX named pipe                              */
+    INODE_TYPE_PIPE  =     0x008,      /*! POSIX anonymous pipe                          */
+    INODE_TYPE_SOCK  =     0x010,      /*! POSIX socket                                  */
+    INODE_TYPE_DEV   =     0x020,      /*! device channel                                */
+    INODE_TYPE_SYML  =     0x080,      /*! symbolic link                                 */
 }
 vfs_inode_type_t;
@@ -182,24 +182,23 @@
 typedef struct vfs_inode_s
 {
-	struct vfs_ctx_s      * ctx;         /*! local pointer on FS context                 */
-    uint32_t                gc;          /*! generation counter                          */
-	uint32_t                inum;        /*! inode identifier (unique in file system)    */
-	uint32_t                attr;        /*! inode attributes (see above)                */
-	vfs_inode_type_t        type;        /*! inode type (see above)                      */
-	uint32_t                size;        /*! number of bytes                             */
-	uint32_t                links;       /*! number of alias dentry                      */
-	uid_t                   uid;         /*! user owner identifier                       */
-	gid_t                   gid;         /*! group owner identifier                      */
-    uint32_t                rights;      /*! access rights                               */
-	uint32_t	            refcount;    /*! reference counter (all pointers)            */
-	xptr_t                  parent_xp;   /*! extended pointer on parent dentry           */
-	xhtab_t                 children;    /*! embedded xhtab of vfs_dentry_t              */
-	remote_rwlock_t         data_lock;   /*! protect read/write to data and to size      */
-	remote_spinlock_t       main_lock;   /*! protect inode tree traversal and modifs     */
-	list_entry_t            list;        /*! member of set of inodes in same cluster     */
-	xlist_entry_t           wait_root;   /*! root of threads waiting on this inode       */
-	struct vfs_inode_op_s * op;          /*! TODO ???                                    */
-	struct mapper_s       * mapper;      /*! associated file cache                       */
-	void                  * extend;      /*! FS specific inode extension                 */
+	struct vfs_ctx_s * ctx;              /*! local pointer on FS context                 */
+    uint32_t           gc;               /*! generation counter                          */
+	uint32_t           inum;             /*! inode identifier (unique in file system)    */
+	uint32_t           attr;             /*! inode attributes (see above)                */
+	vfs_inode_type_t   type;             /*! inode type (see above)                      */
+	uint32_t           size;             /*! number of bytes                             */
+	uint32_t           links;            /*! number of alias dentry                      */
+	uid_t              uid;              /*! user owner identifier                       */
+	gid_t              gid;              /*! group owner identifier                      */
+    uint32_t           rights;           /*! access rights                               */
+	uint32_t	       refcount;         /*! reference counter (all pointers)            */
+	xptr_t             parent_xp;        /*! extended pointer on parent dentry           */
+	xhtab_t            children;         /*! embedded xhtab of children dentries         */
+	remote_rwlock_t    data_lock;        /*! protect read/write to data and to size      */
+	remote_spinlock_t  main_lock;        /*! protect inode tree traversal and modifs     */
+	list_entry_t       list;             /*! member of set of inodes in same cluster     */
+	xlist_entry_t      wait_root;        /*! root of threads waiting on this inode       */
+	struct mapper_s  * mapper;           /*! associated file cache                       */
+	void             * extend;           /*! fs_type_specific inode extension            */
 }
 vfs_inode_t;
@@ -214,13 +213,12 @@
 typedef struct vfs_dentry_s
 {
-    struct vfs_ctx_s       * ctx;        /*! local pointer on FS context                 */
-	char                     name[CONFIG_VFS_MAX_NAME_LENGTH];
-	uint32_t                 length;     /*! name length (bytes)                         */
-	uint32_t                 refcount;   /*! reference counter (all pointers)            */
-    struct vfs_inode_s     * parent;     /*! local pointer on parent inode               */
-    xptr_t                   child_xp;   /*! extended pointer on child inode             */
-    xlist_entry_t            xlist;      /*! member of xlist of dentries with same key   */
-	struct vfs_dentry_op_s * op;         /*! TODO                                        */
-	void                   * extend;     /*! FS specific extension                       */
+    struct vfs_ctx_s   * ctx;            /*! local pointer on FS context                 */
+	char                 name[CONFIG_VFS_MAX_NAME_LENGTH];
+	uint32_t             length;         /*! name length (bytes)                         */
+	uint32_t             refcount;       /*! reference counter (all pointers)            */
+    struct vfs_inode_s * parent;         /*! local pointer on parent inode               */
+    xptr_t               child_xp;       /*! extended pointer on child inode             */
+    xlist_entry_t        list;           /*! member of list of dentries with same key    */
+	void               * extend;         /*! FS specific extension                       */
 }
 vfs_dentry_t;
@@ -231,5 +229,5 @@
  * the inode, when a thread makes an open() or opendir() system call.
  * It cannot exist a file structure without an inode structure.
- * Aa the fd_array (containing extended pointers on the open file descriptors)
+ * Aa the fd_array (containing extended pointers on the open file descriptors)* is replicated in all process descriptors, we need a references counter.
  * is replicated in all process descriptors, we need a references counter.
  *****************************************************************************************/
@@ -313,6 +311,23 @@
 
 /*****************************************************************************************/
-/******************* FS Context related functions ****************************************/
-/*****************************************************************************************/
+/******************* VFS Context related functions ****************************************/
+/*****************************************************************************************/
+
+/****************************************************************************************** 
+ * This function initialise a (statically allocated) VFS context in local cluster. 
+ ******************************************************************************************
+ * @ fs_type        : file system type.
+ * @ attr           : global attributes (for all files in FS.
+ * @ total_clusters : total number of clusters on device.
+ * @ cluster_size   : cluster size on device (bytes).
+ * @ vfs_root_xp    : extended pointer on VFS root inode.
+ * @ extend         : fs_type_specific extension.
+ *****************************************************************************************/
+void vfs_ctx_init( vfs_fs_type_t   type,
+                   uint32_t        attr,
+	               uint32_t        total_clusters,
+	               uint32_t        cluster_size,
+	               xptr_t          vfs_root_xp,
+                   void          * extend );
 
 /****************************************************************************************** 
@@ -355,4 +370,5 @@
  * @ fs_type    : file system type.
  * @ inode_type : inode type.
+ * @ extend     : local pointer on vs_type_specific extension.
  * @ attr       : inode attributes.
  * @ rights     : inode access rights.
@@ -365,4 +381,5 @@
                           vfs_fs_type_t     fs_type,
                           vfs_inode_type_t  inode_type,
+                          void            * extend,
                           uint32_t          attr,
                           uint32_t          rights,
@@ -550,4 +567,11 @@
 /******************* Inode-Tree related functions ****************************************/ 
 /*****************************************************************************************/ 
+
+/****************************************************************************************** 
+ * This function randomly selects a cluster for a new inode.
+ ******************************************************************************************
+ * @ returns the selected cluster identifier.
+ *****************************************************************************************/
+cxy_t vfs_cluster_random_select();
 
 /****************************************************************************************** 
@@ -594,19 +618,23 @@
  * uses the rpc_dentry_create_client() and rpc_inode_create client() if required.
  * - The dentry is created in the cluster containing the existing <parent_xp> inode.
- * - the child inode and its associated mapper are created in a randomly selected cluster.
+ * - the inode and its associated mapper are created in cluster identified by <child_cxy>.
  * - The new dentry name is defined by the <name> argument.
  * - The new inode and the parent inode can have different FS types.
  ******************************************************************************************
+ * @ child_cxy  : target cluster for child inode.
  * @ inode_type : new inode type
  * @ fs_type    : new inode FS type.
  * @ parent_xp  : extended pointer on parent inode.
  * @ name       : new directory entry name.
+ * @ extend     : fs_type_specific inode extension.
  * @ child_xp   : [out] buffer for extended pointer on child inode.
  * @ return 0 if success / ENOENT if entry not found in parent directory
  *****************************************************************************************/
-error_t vfs_add_child_in_parent( vfs_inode_type_t   inode_type,
+error_t vfs_add_child_in_parent( cxy_t              child_cxy,
+                                 vfs_inode_type_t   inode_type,
                                  vfs_fs_type_t      fs_type,
                                  xptr_t             parent_xp,
                                  char             * name,   
+                                 void             * extend,
                                  xptr_t           * child_xp );
 
@@ -620,4 +648,12 @@
 error_t vfs_remove_child_from_parent( xptr_t child_xp );
 
+/******************************************************************************************
+ * This recursive function diplays a complete inode/dentry sub-tree.
+ * Any inode can be selected as the sub-tree root.
+ * TODO this function is not ptotected against a concurrent node removal...
+ ******************************************************************************************
+ * @ inode_xp   : extended pointer on sub-tree root inode.
+ *****************************************************************************************/
+void vfs_display( xptr_t   inode_xp );
 
 
