Index: trunk/kernel/vfs/fatfs.c
===================================================================
--- trunk/kernel/vfs/fatfs.c	(revision 265)
+++ trunk/kernel/vfs/fatfs.c	(revision 279)
@@ -217,64 +217,4 @@
 } // end get_name_from_long()
 
-//////////////////////////////////////////////////////////////////////////////////////////
-// This function returns the FATFS cluster index of a page identified by its page
-// index in the file, using the FAT mapper. It scans the FAT mapper, starting from the
-// FATFS cluster index allocated to the first page of the file, until it reaches the 
-// searched page. The FAT mapper is automatically updated in case of miss. 
-// This function can be called by any thread running in any cluster, as it uses the
-// RPC_FATFS_GET_CLUSTER to access the remote FAT mapper if required.
-// We use a RPC to scan the FAT because the RPC_FIFO will avoid contention
-// in the cluster containing the FAT mapper, and the RPC latency is not critical
-// compared to the device access latency.
-//////////////////////////////////////////////////////////////////////////////////////////
-// @ ctx	       : pointer on local FATFS context.
-// @ first_cluster : first cluster allocated to a file in FATFS.
-// @ page_index    : index of searched page in file (one page occupies one cluster).
-// @ cluster_index : [out] pointer on buffer for FATFS cluster index.
-// @ return 0 if success / return EIO if a FAT cluster miss cannot be solved.
-//////////////////////////////////////////////////////////////////////////////////////////
-static error_t fatfs_cluster_from_index( fatfs_ctx_t * ctx,
-                                         uint32_t      first_cluster,
-                                         uint32_t      page_index,
-                                         uint32_t    * cluster_index )
-{
-    uint32_t searched_cluster;   // searched FATFS cluster index
-    error_t  error;
-
-    // get extended pointer on FAT mapper
-    xptr_t fat_mapper_xp = ctx->fat_mapper_xp;
-
-    // get cluster cxy and local pointer on FAT mapper
-    cxy_t      fat_mapper_cxy = GET_CXY( fat_mapper_xp );
-    mapper_t * fat_mapper_ptr = (mapper_t *)GET_PTR( fat_mapper_xp );
-
-    if( fat_mapper_cxy == local_cxy )    // FAT mapper is local
-    {
-        error = fatfs_get_cluster( fat_mapper_ptr,
-                                   first_cluster,
-                                   page_index,
-                                   &searched_cluster );
-    }
-    else                                 // FAT mapper is remote
-    {
-        rpc_fatfs_get_cluster_client( fat_mapper_cxy,
-                                      fat_mapper_ptr,
-                                      first_cluster,
-                                      page_index,
-                                      &searched_cluster,
-                                      &error );
-    }
-    
-    if( error )
-    {
-        printk("\n[ERROR] in %s : cannot access FAT\n", __FUNCTION__ );
-        return error;
-    }
-
-    // return success
-    *cluster_index = searched_cluster;
-    return 0;
-
-}  // end fatfs_cluster_from_index()
 
 //////////////////////////////////////////////////////////////////////////////////////////
@@ -400,5 +340,5 @@
     uint8_t     * buffer;
 
-    fatfs_dmsg("\n[INFO] %s : enters for fatfs_ctx = %x\n",
+    fatfs_dmsg("\n[INFO] %s : enter for fatfs_ctx = %x\n",
                __FUNCTION__ , fatfs_ctx );
 
@@ -414,7 +354,11 @@
                    "cannot allocate memory for 512 bytes buffer\n" );
      
+    fatfs_dmsg("\n[INFO] %s : allocated 512 bytes buffer\n", __FUNCTION__ );
+
     // load the boot record from device
     // using a synchronous access to IOC device  
     error = dev_ioc_sync_read( buffer , 0 , 1 );
+
+    fatfs_dmsg("\n[INFO] %s : buffer loaded\n", __FUNCTION__ );
 
     assert( (error == 0) , __FUNCTION__ ,
@@ -441,30 +385,30 @@
     uint32_t sector_size = fatfs_get_record( BPB_BYTSPERSEC , buffer , 1 );
 
-    nolock_assert( (sector_size == 512) , __FUNCTION__ ,
-                   "sector size must be 512 bytes\n" );
+    assert( (sector_size == 512) , __FUNCTION__ ,
+            "sector size must be 512 bytes\n" );
 
     // check cluster size from boot record
     uint32_t nb_sectors = fatfs_get_record( BPB_SECPERCLUS , buffer , 1 );
 
-    nolock_assert( (nb_sectors == 8) , __FUNCTION__ ,
-                   "cluster size must be 8 sectors\n" );
+    assert( (nb_sectors == 8) , __FUNCTION__ ,
+            "cluster size must be 8 sectors\n" );
 
     // check number of FAT copies from boot record
     uint32_t nb_fats = fatfs_get_record( BPB_NUMFATS , buffer , 1 );
 
-    nolock_assert( (nb_fats == 1) , __FUNCTION__ ,
-                   "number of FAT copies must be 1\n" );
+    assert( (nb_fats == 1) , __FUNCTION__ ,
+            "number of FAT copies must be 1\n" );
 
     // get & check number of sectors in FAT from boot record
     uint32_t fat_sectors = fatfs_get_record( BPB_FAT32_FATSZ32 , buffer , 1 );
 
-    nolock_assert( ((fat_sectors & 0xF) == 0) , __FUNCTION__ ,
-                   "FAT not multiple of 16 sectors\n");
+    assert( ((fat_sectors & 0xF) == 0) , __FUNCTION__ ,
+            "FAT not multiple of 16 sectors\n");
 
     // get and check root cluster from boot record
     uint32_t root_cluster = fatfs_get_record( BPB_FAT32_ROOTCLUS , buffer , 1 );
 
-    nolock_assert( (root_cluster == 2) , __FUNCTION__ ,
-                   "root cluster index must be  2\n");
+    assert( (root_cluster == 2) , __FUNCTION__ ,
+            "root cluster index must be  2\n");
 
     // get FAT lba from boot record
@@ -475,4 +419,7 @@
     req.ptr  = buffer;
     kmem_free( &req );
+
+    fatfs_dmsg("\n[INFO] %s : boot record read & released\n",
+               __FUNCTION__ );
 
     // allocate a mapper for the FAT itself
@@ -494,4 +441,7 @@
     fatfs_ctx->last_allocated_index  = 0;    // TODO ???
     fatfs_ctx->fat_mapper_xp         = XPTR( local_cxy , fat_mapper );
+
+    fatfs_dmsg("\n[INFO] %s : exit for fatfs_ctx = %x\n",
+               __FUNCTION__ , fatfs_ctx );
 
 }  // end fatfs_ctx_init()
