Index: trunk/kernel/libk/xhtab.c
===================================================================
--- trunk/kernel/libk/xhtab.c	(revision 188)
+++ trunk/kernel/libk/xhtab.c	(revision 204)
@@ -76,15 +76,12 @@
 // returns true if given name matches directory entry name.
 ////////////////////////////////////////////////////////////////////////////////////////////
-static bool_t xhtab_dentry_item_match_key( xptr_t item_xp,
+static bool_t xhtab_dentry_item_match_key( xptr_t    item_xp,
                                            void    * key )
 {
-    vfs_dentry_t * dentry_ptr;
-    cxy_t          dentry_cxy;
-
-    char           name[CONFIG_VFS_MAX_NAME_LENGTH];
+    char name[CONFIG_VFS_MAX_NAME_LENGTH];
 
     // get dentry cluster and local pointer
-    dentry_cxy = GET_CXY( item_xp );
-    dentry_ptr = (vfs_dentry_t *)GET_PTR( item_xp );
+    cxy_t          dentry_cxy = GET_CXY( item_xp );
+    vfs_dentry_t * dentry_ptr = (vfs_dentry_t *)GET_PTR( item_xp );
 
     // make a local copy of directory entry name
@@ -94,5 +91,26 @@
     return( strcmp( name , (char*)key ) == 0 );
 }
-                       
+
+////////////////////////////////////////////////////////////////////////////////////////////
+// This function print the item key, that is the name for a vfs_entry_t,
+////////////////////////////////////////////////////////////////////////////////////////////
+// @ item_xp   : extended pointer on item.
+////////////////////////////////////////////////////////////////////////////////////////////
+static void xhtab_dentry_item_print_key( xptr_t item_xp )
+{
+    char name[CONFIG_VFS_MAX_NAME_LENGTH];
+
+    // get dentry cluster and local pointer
+    cxy_t          dentry_cxy = GET_CXY( item_xp );
+    vfs_dentry_t * dentry_ptr = (vfs_dentry_t *)GET_PTR( item_xp );
+    
+    // make a local copy of directory entry name
+    hal_remote_strcpy( XPTR( local_cxy , name ) ,
+                       XPTR( dentry_cxy , &dentry_ptr->name ) );
+
+    // print dentry name
+    printk("%s , ", name );
+}                       
+
 ////////////////////////////////////////////////////////////////////////////////////////
 //         Generic access functions
@@ -108,5 +126,7 @@
     remote_rwlock_init( XPTR( local_cxy , &xhtab->lock) );
 
-    xhtab->items  = 0;
+    xhtab->items            = 0;
+    xhtab->current_index    = 0;
+    xhtab->current_xlist_xp = XPTR_NULL;
 
     if( type == XHTAB_DENTRY_TYPE )
@@ -115,4 +135,5 @@
         xhtab->index_from_key  = &xhtab_dentry_index_from_key;
         xhtab->item_from_xlist = &xhtab_dentry_item_from_xlist;
+        xhtab->item_print_key  = &xhtab_dentry_item_print_key;
     }
     else
@@ -134,12 +155,21 @@
                    void    * key )
 {
-    xptr_t    xlist_xp;                                 // xlist_entry_t (iterator)
-    xptr_t    item_xp;                                  // associated item
-    xhtab_t * xhtab_ptr;                                // hash table local pointer
-    cxy_t     xhtab_cxy;                                // hash table cluster
+    xptr_t              xlist_xp;           // xlist_entry_t (iterator)
+    xptr_t              item_xp;            // associated item
+    xhtab_t           * xhtab_ptr;          // hash table local pointer
+    cxy_t               xhtab_cxy;          // hash table cluster
+    item_from_xlist_t * item_from_xlist;    // function pointer
+    item_match_key_t  * item_match_key;     // function pointer
 
     // get hash table cluster and local pointer
     xhtab_cxy = GET_CXY( xhtab_xp );
     xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
+
+    // get pointer on "item_from_xlist" function
+    item_from_xlist = (item_from_xlist_t *)hal_remote_lpt( XPTR( xhtab_cxy , 
+                                                           &xhtab_ptr->item_from_xlist ) );
+    // get pointer on "item_match_key" function
+    item_match_key = (item_match_key_t *)hal_remote_lpt( XPTR( xhtab_cxy , 
+                                                         &xhtab_ptr->item_match_key ) );
 
     // scan sub-list[index]
@@ -147,13 +177,14 @@
     {
         // get extended pointer on item containing the xlist entry
-	    item_xp = xhtab_ptr->item_from_xlist( xlist_xp );
+	    item_xp = item_from_xlist( xlist_xp );
 
         // check matching
-        if( xhtab_ptr->item_match_key( item_xp , key ) ) return item_xp;
+        if( item_match_key( item_xp , key ) ) return item_xp;
     }
 
     // No matching item found
     return XPTR_NULL;
-}
+
+}  // end xhtab_scan()
 
 ///////////////////////////////////////
@@ -162,10 +193,19 @@
                       xptr_t   xlist_xp )
 {
-    // get xhtab cluster and local pointer 
-    cxy_t     xhtab_cxy = GET_CXY( xhtab_xp );
-    xhtab_t * xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
-
+    xptr_t             item_xp;
+    uint32_t           index;
+    cxy_t              xhtab_cxy;
+    xhtab_t          * xhtab_ptr;
+    index_from_key_t * index_from_key;     // function pointer
+    
+    // get xhtab cluster and local pointer 
+    xhtab_cxy = GET_CXY( xhtab_xp );
+    xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
+
+    // get pointer on "index_from_key" function
+    index_from_key = (index_from_key_t *)hal_remote_lpt( XPTR( xhtab_cxy , 
+                                                         &xhtab_ptr->index_from_key ) );
     // compute index from key
-	uint32_t index = xhtab_ptr->index_from_key( key );
+	index = index_from_key( key );
 
     // take the lock protecting hash table
@@ -173,5 +213,5 @@
 
     // search a matching item 
-    xptr_t item_xp = xhtab_scan( xhtab_xp , index , key );
+    item_xp = xhtab_scan( xhtab_xp , index , key );
 
     if( item_xp != XPTR_NULL )    // error if found
@@ -202,10 +242,19 @@
                       xptr_t   xlist_entry_xp )
 {
-    // get xhtab cluster and local pointer 
-    cxy_t     xhtab_cxy = GET_CXY( xhtab_xp );
-    xhtab_t * xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
-
+    xptr_t             item_xp;
+    uint32_t           index;
+    cxy_t              xhtab_cxy;
+    xhtab_t          * xhtab_ptr;
+    index_from_key_t * index_from_key;     // function pointer
+
+    // get xhtab cluster and local pointer 
+    xhtab_cxy = GET_CXY( xhtab_xp );
+    xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
+
+    // get pointer on "index_from_key" function
+    index_from_key = (index_from_key_t *)hal_remote_lpt( XPTR( xhtab_cxy , 
+                                                         &xhtab_ptr->index_from_key ) );
     // compute index from key
-	uint32_t index = xhtab_ptr->index_from_key( key );
+	index = index_from_key( key );
 
     // take the lock protecting hash table
@@ -213,5 +262,5 @@
 
     // get extended pointer on item to remove
-    xptr_t item_xp = xhtab_scan( xhtab_xp , index , key );
+    item_xp = xhtab_scan( xhtab_xp , index , key );
 
     if( item_xp == XPTR_NULL )    // error if not found
@@ -241,12 +290,19 @@
                       void    * key )
 {
-    xptr_t  item_xp;
-
-    // get xhtab cluster and local pointer 
-    cxy_t     xhtab_cxy = GET_CXY( xhtab_xp );
-    xhtab_t * xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
-
+    xptr_t             item_xp;
+    uint32_t           index;
+    cxy_t              xhtab_cxy;
+    xhtab_t          * xhtab_ptr;
+    index_from_key_t * index_from_key;     // function pointer
+
+    // get xhtab cluster and local pointer 
+    xhtab_cxy = GET_CXY( xhtab_xp );
+    xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
+
+    // get pointer on "index_from_key" function
+    index_from_key = (index_from_key_t *)hal_remote_lpt( XPTR( xhtab_cxy , 
+                                                         &xhtab_ptr->index_from_key ) );
     // compute index from key
-	uint32_t index = xhtab_ptr->index_from_key( key );
+	index = index_from_key( key );
 
     // take the lock protecting hash table
@@ -288,13 +344,19 @@
 xptr_t xhtab_get_first( xptr_t xhtab_xp )
 {
-    uint32_t index;
-    xptr_t   xlist_xp;
-    xptr_t   item_xp;
-    xptr_t   root_xp;
-
-    // get xhtab cluster and local pointer 
-    cxy_t     xhtab_cxy = GET_CXY( xhtab_xp );
-    xhtab_t * xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
-
+    uint32_t            index;
+    cxy_t               xhtab_cxy;
+    xhtab_t           * xhtab_ptr;
+    xptr_t              xlist_xp;
+    xptr_t              item_xp;
+    xptr_t              root_xp;
+    item_from_xlist_t * item_from_xlist;   // function pointer
+
+    // get xhtab cluster and local pointer 
+    xhtab_cxy = GET_CXY( xhtab_xp );
+    xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
+
+    // get pointer on "item_from_xlist" function
+    item_from_xlist = (item_from_xlist_t *)hal_remote_lpt( XPTR( xhtab_cxy , 
+                                                           &xhtab_ptr->item_from_xlist ) );
     //loop on subsets
     for( index = 0 ; index < XHASHTAB_SIZE ; index++ )
@@ -309,5 +371,5 @@
         {
             // get extended pointer on item containing the xlist entry
-	        item_xp = xhtab_ptr->item_from_xlist( xlist_xp );
+	        item_xp = item_from_xlist( xlist_xp );
 
             // register item in hash table header
@@ -327,8 +389,11 @@
 xptr_t xhtab_get_next( xptr_t xhtab_xp )
 {
-    uint32_t index;
-    xptr_t   xlist_xp;
-    xptr_t   item_xp;
-    xptr_t   root_xp;
+    uint32_t            index;
+    cxy_t               xhtab_cxy;
+    xhtab_t           * xhtab_ptr;
+    xptr_t              xlist_xp;
+    xptr_t              item_xp;
+    xptr_t              root_xp;
+    item_from_xlist_t * item_from_xlist;   // function pointer
 
     uint32_t current_index;
@@ -336,6 +401,6 @@
 
     // get xhtab cluster and local pointer 
-    cxy_t     xhtab_cxy = GET_CXY( xhtab_xp );
-    xhtab_t * xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
+    xhtab_cxy = GET_CXY( xhtab_xp );
+    xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
 
     // get current item pointers
@@ -343,4 +408,7 @@
     current_xlist_xp = hal_remote_lwd( XPTR( xhtab_cxy , &xhtab_ptr->current_xlist_xp ) ); 
 
+    // get pointer on "item_from_xlist" function
+    item_from_xlist = (item_from_xlist_t *)hal_remote_lpt( XPTR( xhtab_cxy , 
+                                                           &xhtab_ptr->item_from_xlist ) );
     //loop on subsets
     for( index = current_index ; index < XHASHTAB_SIZE ; index++ )
@@ -350,10 +418,11 @@
 
         // get next item
-        xlist_xp = xlist_next( root_xp , current_xlist_xp );
+        if( index == current_index ) xlist_xp = xlist_next( root_xp , current_xlist_xp );
+        else                         xlist_xp = xlist_next( root_xp , root_xp );
 
         if( xlist_xp != XPTR_NULL )  // next item found
         {
             // get extended pointer on item containing the xlist entry
-	        item_xp = xhtab_ptr->item_from_xlist( xlist_xp );
+	        item_xp = item_from_xlist( xlist_xp );
 
             // register item in hash table header
@@ -370,3 +439,45 @@
 } // end xhtab_get_next()
 
-
+/////////////////////////////////////
+void xhtab_display( xptr_t xhtab_xp )
+{
+    uint32_t            index;
+    cxy_t               xhtab_cxy;
+    xhtab_t           * xhtab_ptr;
+    xptr_t              root_xp;
+    xptr_t              iter_xp;
+    xptr_t              item_xp;
+    item_from_xlist_t * item_from_xlist;   // function pointer
+    item_print_key_t  * item_print_key;    // function pointer
+
+    // get xhtab cluster and local pointer 
+    xhtab_cxy = GET_CXY( xhtab_xp );
+    xhtab_ptr = (xhtab_t *)GET_PTR( xhtab_xp );
+
+    // get pointer on "item_from_xlist" function
+    item_from_xlist = (item_from_xlist_t *)hal_remote_lpt( XPTR( xhtab_cxy , 
+                                                           &xhtab_ptr->item_from_xlist ) );
+    // get pointer on "item_print_key" function
+    item_print_key = (item_print_key_t *)hal_remote_lpt( XPTR( xhtab_cxy , 
+                                                         &xhtab_ptr->item_print_key ) );
+    //loop on subsets
+    for( index = 0 ; index < XHASHTAB_SIZE ; index++ )
+    {
+        printk(" index = %d : ", index );
+
+        // get root of subset 
+        root_xp = XPTR( xhtab_cxy , &xhtab_ptr->roots[index] );
+
+        // loop on xlist
+        XLIST_FOREACH( root_xp , iter_xp )
+        {
+            // get item from xlist
+            item_xp = item_from_xlist( iter_xp );
+            
+            // print item identifier
+            item_print_key( item_xp );
+        }
+
+        printk("\n");
+    }
+}  // end xhtab_display()
