Index: trunk/kernel/vfs/vfs.c
===================================================================
--- trunk/kernel/vfs/vfs.c	(revision 188)
+++ trunk/kernel/vfs/vfs.c	(revision 204)
@@ -215,6 +215,6 @@
     xlist_root_init( XPTR( local_cxy , &inode->wait_root ) );
 
-    // initialize dentries hash table, if new inode is a directory
-    if( inode_type == INODE_TYPE_DIR ) xhtab_init( &inode->children , XHTAB_DENTRY_TYPE );
+    // initialize dentries hash table
+    xhtab_init( &inode->children , XHTAB_DENTRY_TYPE );
 
     // initialize inode locks 
@@ -329,5 +329,46 @@
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////
+void vfs_inode_display( xptr_t inode_xp )
+{
+    cxy_t          inode_cxy;
+    vfs_inode_t  * inode_ptr;
+    xptr_t         dentry_xp;
+    cxy_t          dentry_cxy;
+    vfs_dentry_t * dentry_ptr;
+    
+    char           name[CONFIG_VFS_MAX_NAME_LENGTH];
+
+    // get inode cluster and local pointer
+    inode_cxy = GET_CXY( inode_xp );
+    inode_ptr = (vfs_inode_t *)GET_PTR( inode_xp );
+
+    // get parent dentry
+    dentry_xp  = hal_remote_lwd( XPTR( inode_cxy , &inode_ptr->parent_xp ) );
+
+    // get local copy of name
+    if( dentry_xp == XPTR_NULL )  // it is the VFS root
+    {
+        strcpy( name , "/" );
+    }
+    else                          // not the VFS root
+    {
+        dentry_cxy = GET_CXY( dentry_xp );
+        dentry_ptr = (vfs_dentry_t *)GET_PTR( dentry_xp );
+
+        hal_remote_strcpy( XPTR( local_cxy  , name ) , 
+                           XPTR( dentry_cxy , &dentry_ptr->name ) );
+    }
+
+    // display inode header
+    printk("\n*** inode <%s> / inode_xp = %l / dentry_xp = %l ***\n",
+           name , inode_xp , dentry_xp );
+
+    // display children from xhtab
+    xhtab_display( XPTR( inode_cxy , &inode_ptr->children ) );
+
+}  // end vfs_inode_display()
+
+////////////////////////////////////////////////////////////////////////////////////////////
 //           Dentry related functions
 //////////////////////////////////////////////////////////////////////////////////////////
@@ -509,5 +550,5 @@
 
     vfs_dmsg("\n[INFO] %s : enters for <%s> at cycle %d\n",
-             __FUNCTION__ , path , hal_get_cycles() );
+             __FUNCTION__ , path , (uint32_t)hal_time_stamp() );
 
     // compute lookup working mode
@@ -619,5 +660,5 @@
     else if (inode_type == INODE_TYPE_DEV )
     {
-        // TODO
+        // TODO  [AG]
         return 0;
     }
@@ -628,5 +669,5 @@
         return -1;
     }
-}  // end vfs_access()
+}  // end vfs_move()
 
 //////////////////////////////////////
@@ -857,4 +898,5 @@
 static void vfs_recursive_display( xptr_t   inode_xp,
                                    xptr_t   name_xp,
+                                   xptr_t   dentry_xp,
                                    uint32_t indent )
 {
@@ -862,14 +904,13 @@
     vfs_inode_t      * inode_ptr;
     vfs_inode_type_t   inode_type;
-    xptr_t             inode_children_xp;    // extended pointer on children xhtab
-
-    xptr_t             dentry_xp;
-    cxy_t              dentry_cxy;
-    vfs_dentry_t     * dentry_ptr;
+    xptr_t             children_xp;    // extended pointer on children xhtab
+
+    xptr_t             child_dentry_xp;
+    cxy_t              child_dentry_cxy;
+    vfs_dentry_t     * child_dentry_ptr;
+    xptr_t             child_inode_xp;
+    xptr_t             child_dentry_name_xp;
 
     char               name[CONFIG_VFS_MAX_NAME_LENGTH];
-
-    xptr_t             child_inode_xp;
-    xptr_t             dentry_name_xp;
 
     char *             indent_str[] = { "",                                  // level 0
@@ -905,5 +946,7 @@
 
     // display inode
-    printk(" %s %s : %s\n", indent_str[indent], vfs_inode_type_str( inode_type ), name );
+    printk("%s%s <%s> inode_xp = %l / dentry_xp = %l\n",
+           indent_str[indent], vfs_inode_type_str( inode_type ), 
+           name , inode_xp , dentry_xp );
 
     // scan directory entries  
@@ -911,33 +954,37 @@
     {
         // get extended pointer on directory entries xhtab
-        inode_children_xp = hal_remote_lwd( XPTR( inode_cxy , &inode_ptr->children ) );
+        children_xp =  XPTR( inode_cxy , &inode_ptr->children );
 
         // get xhtab lock
-        xhtab_read_lock( inode_children_xp );
+        xhtab_read_lock( children_xp );
 
         // get first dentry from xhtab
-        dentry_xp = xhtab_get_first( inode_children_xp );
-
-        while( dentry_xp != XPTR_NULL )
+        child_dentry_xp = xhtab_get_first( children_xp );
+
+        while( child_dentry_xp != XPTR_NULL )
         {
             // get dentry cluster and local pointer
-            dentry_cxy = GET_CXY( dentry_xp );
-            dentry_ptr = (vfs_dentry_t *)GET_PTR( dentry_xp );
+            child_dentry_cxy = GET_CXY( child_dentry_xp );
+            child_dentry_ptr = (vfs_dentry_t *)GET_PTR( child_dentry_xp );
 
             // get extended pointer on child inode
-            child_inode_xp = hal_remote_lwd( XPTR( dentry_cxy , &dentry_ptr->child_xp ) );
+            child_inode_xp = hal_remote_lwd( XPTR( child_dentry_cxy,
+                                                   &child_dentry_ptr->child_xp ) );
 
             // get extended pointer on dentry name
-            dentry_name_xp = XPTR( dentry_cxy , &dentry_ptr->name );
+            child_dentry_name_xp = XPTR( child_dentry_cxy , &child_dentry_ptr->name );
 
             // recursive call on child inode
-            vfs_recursive_display( child_inode_xp , dentry_name_xp , indent+1 );
+            vfs_recursive_display( child_inode_xp,
+                                   child_dentry_name_xp,
+                                   child_dentry_xp,
+                                   indent+1 );
 
             // get next dentry
-            dentry_xp = xhtab_get_next( inode_children_xp );
+            child_dentry_xp = xhtab_get_next( children_xp );
         }
 
         // release xhtab lock
-        xhtab_read_unlock( inode_children_xp );
+        xhtab_read_unlock( children_xp );
     }
 }  // end vfs_recursive_display()
@@ -946,11 +993,9 @@
 void vfs_display( xptr_t inode_xp )
 {
-    xptr_t         name_xp;      // extended pointer on string containing the inode name
+    xptr_t         name_xp;
     xptr_t         dentry_xp; 
     cxy_t          dentry_cxy;
     vfs_dentry_t * dentry_ptr;
 
-printk("\n@@@ %s enters\n", __FUNCTION__ );
-
     // get target inode cluster and local pointer 
     cxy_t         inode_cxy = GET_CXY( inode_xp );
@@ -977,10 +1022,10 @@
 
     // print header
-    printk("\n*** Current VFS content ***\n");
+    printk("\n*** VFS ***\n");
 
     // call recursive function
-    vfs_recursive_display( inode_xp , name_xp , 0 );
-
-}  // end vfs_diplay()
+    vfs_recursive_display( inode_xp , name_xp , dentry_xp , 0 );
+
+}  // end vfs_display()
 
 //////////////////////////////////////////////////////////////////////////////////////////
@@ -1015,5 +1060,5 @@
 //////////////////////////////////////////////////////////////////////////////////////////
 // This static function is used by the vfs_lookup() function.
-// It takes an extended pointer on a remote inode (parent directory inode), a directory 
+// It takes an extended pointer on a remote parent directory inode, a directory 
 // entry name, and returns an extended pointer on the child inode. 
 // It can be used by any thread running in any cluster.
@@ -1050,5 +1095,6 @@
     *child_xp = (xptr_t)hal_remote_lwd( XPTR( dentry_cxy , &dentry_ptr->child_xp ) );
     return true;
-}
+
+}  // end vfs_get_child()
 
 //////////////////////////////////////////////////////////////////////////////////////////
@@ -1083,4 +1129,7 @@
     while( (*ptr != 0) && (*ptr !='/') )  *(name++) = *(ptr++);
 
+    // set NUL terminating character in name buffer
+    *(name++) = 0;
+
     // return last an next
     if( *ptr == 0 )             // last found character is NUL => last name in path
@@ -1095,5 +1144,6 @@
 
     return 0;
-}
+
+}  // end vfs_get name_from_path()
    
 //////////////////////////////////////////////
@@ -1122,6 +1172,6 @@
     error_t            error;
 
-    vfs_dmsg("\n[INFO] %s : enters for <%s>\n",
-             __FUNCTION__ , pathname );
+    vfs_dmsg("\n[INFO] %s : enters for <%s> at cycle %d\n",
+             __FUNCTION__ , pathname , (uint32_t)hal_time_stamp() );
 
     this    = CURRENT_THREAD;
@@ -1142,5 +1192,5 @@
 
     // load from device if one intermediate node not found
-    // exit  when last name found (i.e. last == true)
+    // exit while loop when last name found (i.e. last == true)
     do
     {
@@ -1148,8 +1198,8 @@
         vfs_get_name_from_path( current , name , &next , &last );
 
-        vfs_dmsg("\n[INFO] %s : looking for node <%s> / last = %d\n",
+        vfs_dmsg("\n[INFO] %s : looking for <%s> / last = %d\n",
                  __FUNCTION__ , name , last );
 
-        // search a child dentry matching name for parent inode
+        // search a child dentry matching name in parent inode
         found = vfs_get_child( parent_xp,
                                name,
@@ -1158,5 +1208,5 @@
         if( found == false ) // child inode not found in inode tree => try to load it
         {
-            vfs_dmsg("\n[INFO] %s : node <%s> not found, try to load it\n",
+            vfs_dmsg("\n[INFO] %s : <%s> not found, try to load it\n",
                      __FUNCTION__ , name );
 
@@ -1168,7 +1218,9 @@
             parent_ptr = (vfs_inode_t *)GET_PTR( parent_xp );
 
+            // get local pointer on parent inode context
+            ctx_ptr = (vfs_ctx_t *)hal_remote_lpt( XPTR( parent_cxy , &parent_ptr->ctx ) );
+
             // get parent inode FS type
-            ctx_ptr = (vfs_ctx_t *)hal_remote_lpt( XPTR( parent_cxy , &parent_ptr->ctx ) );
-            fs_type = ctx_ptr->type;
+            fs_type = hal_remote_lw( XPTR( parent_cxy , &ctx_ptr->type ) );
 
             // get child inode type
@@ -1179,4 +1231,6 @@
             cxy_t child_cxy = vfs_cluster_random_select();
                      
+printk("\n@@@ name not found : <%s>\n", name );
+
             // insert a new child dentry/inode in parent inode
             error = vfs_add_child_in_parent( child_cxy,
@@ -1187,5 +1241,4 @@
                                              name, 
                                              &child_xp );
-
             if( error )
             {
@@ -1199,5 +1252,9 @@
         }
 
-        vfs_dmsg("\n[INFO] %s : node <%s> found / parent = %l / child = %l / last = %d\n",
+vfs_inode_display( child_xp );
+
+vfs_display( parent_xp );
+
+        vfs_dmsg("\n[INFO] %s : found <%s> / parent = %l / child = %l / last = %d\n",
                  __FUNCTION__ , name , parent_xp , child_xp , last );
 
@@ -1334,8 +1391,5 @@
     parent_ptr = (vfs_inode_t *)GET_PTR( parent_xp );
 
-    // get parent inode context local pointer
-    parent_ctx = (vfs_ctx_t *)hal_remote_lpt( XPTR( parent_cxy , &parent_ptr->ctx ) );
-
-    // create dentry
+    // 1. create dentry
     if( parent_cxy == local_cxy )      // parent cluster is the local cluster
     {
@@ -1359,8 +1413,8 @@
         printk("\n[ERROR] in %s : cannot create dentry in cluster %x\n",
                __FUNCTION__ , parent_cxy );
-        return error;
-    }
-
-    // create child inode TODO : define attr / mode / uid / gid
+        return ENOMEM;
+    }
+
+    // 2. create child inode TODO : define attr / mode / uid / gid
     uint32_t attr = 0;
     uint32_t mode = 0;
@@ -1403,6 +1457,11 @@
         if( parent_cxy == local_cxy ) vfs_dentry_destroy( dentry );
         else rpc_vfs_dentry_destroy_client( parent_cxy , dentry );
-        return error;
-    }
+        return ENOMEM;
+    }
+
+    // 3. update extended pointer on inode in dentry
+    cxy_t          dentry_cxy = GET_CXY( dentry_xp );
+    vfs_dentry_t * dentry_ptr = (vfs_dentry_t *)GET_PTR( dentry_xp );
+    hal_remote_swd( XPTR( dentry_cxy , &dentry_ptr->child_xp ) , inode_xp );
 
     // success : return extended pointer on child inode
@@ -1422,5 +1481,5 @@
 error_t vfs_move_page_to_mapper( page_t * page )
 {
-    error_t         error = 0;
+    error_t error = 0;
 
     assert( (page != NULL) , __FUNCTION__ , "page pointer is NULL\n" );
