Index: trunk/kernel/kern/rpc.c
===================================================================
--- trunk/kernel/kern/rpc.c	(revision 188)
+++ trunk/kernel/kern/rpc.c	(revision 238)
@@ -66,7 +66,7 @@
     &rpc_vfs_file_create_server,        // 14
     &rpc_vfs_file_destroy_server,       // 15
-    &rpc_fatfs_get_cluster_server,      // 16
-    &rpc_undefined,                     // 17
-    &rpc_undefined,                     // 18
+    &rpc_vfs_inode_load_server,         // 16
+    &rpc_vfs_mapper_load_all_server,    // 17
+    &rpc_fatfs_get_cluster_server,      // 18
     &rpc_undefined,                     // 19
 
@@ -100,10 +100,5 @@
                                 uint32_t * ppn )       // out 
 {
-    // any RPC must be remote
-    if( cxy == local_cxy ) 
-    {
-        printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
-        hal_core_sleep();
-    }
+    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
 
     // initialise RPC descriptor header 
@@ -157,10 +152,5 @@
                                    pid_t     * pid )     // out
 {
-    // RPC must be remote
-    if( cxy == local_cxy ) 
-    {
-        printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
-        hal_core_sleep();
-    }
+    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
 
     // initialise RPC descriptor header 
@@ -213,10 +203,5 @@
                               error_t     * error )   // out
 {
-    // RPC must be remote
-    if( cxy == local_cxy ) 
-    {
-        printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
-        hal_core_sleep();
-    }
+    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
 
     // initialise RPC descriptor header 
@@ -270,9 +255,6 @@
 {
     // only reference cluster can send this RPC
-    if( GET_CXY( process->ref_xp ) != local_cxy )
-    {
-        printk("PANIC in %s : caller is not the reference process\n", __FUNCTION__ );
-        hal_core_sleep();
-    }
+    assert( (GET_CXY( process->ref_xp ) == local_cxy) , __FUNCTION__ ,
+            "caller must be reference process cluster\n");
 
     // get local process index in reference cluster
@@ -344,10 +326,5 @@
                                     error_t        * error )      // out 
 {
-    // RPC must be remote
-    if( cxy == local_cxy ) 
-    {
-        printk("\n[PANIC] in %s : target is not remote\n", __FUNCTION__ );
-        hal_core_sleep();
-    }
+    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
 
     // initialise RPC descriptor header 
@@ -427,10 +404,5 @@
                                       error_t * error )      // out
 {
-    // RPC must be remote
-    if( cxy == local_cxy ) 
-    {
-        printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
-        hal_core_sleep();
-    }
+    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
 
     // initialise RPC descriptor header 
@@ -490,10 +462,5 @@
                              uint32_t    sig_id )    // in
 {
-    // RPC must be remote
-    if( cxy == local_cxy ) 
-    {
-        printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
-        hal_core_sleep();
-    }
+    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
 
     // initialise RPC descriptor header 
@@ -545,10 +512,5 @@
                                   error_t      * error )     // out
 {
-    // RPC must be remote
-    if( cxy == local_cxy ) 
-    {
-        printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ );
-        hal_core_sleep();
-    }
+    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
 
     // initialise RPC descriptor header 
@@ -627,10 +589,5 @@
                                    struct vfs_inode_s * inode )
 {
-    // RPC must be remote
-    if( cxy == local_cxy ) 
-    {
-        printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ );
-        hal_core_sleep();
-    }
+    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
 
     // initialise RPC descriptor header 
@@ -674,10 +631,5 @@
                                    error_t              * error )       // out
 {
-    // RPC must be remote
-    if( cxy == local_cxy ) 
-    {
-        printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ );
-        hal_core_sleep();
-    }
+    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
 
     // initialise RPC descriptor header 
@@ -689,6 +641,5 @@
     rpc.args[0] = (uint64_t)type;
     rpc.args[1] = (uint64_t)(intptr_t)name;
-    rpc.args[2] = (uint64_t)strlen( name );
-    rpc.args[3] = (uint64_t)(intptr_t)parent;
+    rpc.args[2] = (uint64_t)(intptr_t)parent;
 
     // register RPC request in remote RPC fifo (blocking function)
@@ -696,6 +647,6 @@
 
     // get output values from RPC descriptor
-    *dentry_xp = (xptr_t)rpc.args[4];
-    *error     = (error_t)rpc.args[5];
+    *dentry_xp = (xptr_t)rpc.args[3];
+    *error     = (error_t)rpc.args[4];
 }
 
@@ -707,7 +658,7 @@
     vfs_inode_t * parent;
     xptr_t        dentry_xp;
+    error_t       error;
+
     char          name_copy[CONFIG_VFS_MAX_NAME_LENGTH];
-    uint32_t      length;
-    error_t       error;
 
     // get client cluster identifier and pointer on RPC descriptor
@@ -715,15 +666,13 @@
     rpc_desc_t * desc        = (rpc_desc_t *)GET_PTR( xp );
 
-    // get argument "name" & "length" from client RPC descriptor and makes a local copy
-    name   = (char *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) );
-    length = (uint32_t)        hal_remote_lwd( XPTR( client_cxy , &desc->args[2] ) );
-    hal_remote_memcpy( XPTR( local_cxy , name_copy ),
-                       XPTR( client_cxy , name ),
-					   length + 1 );               // +1 for the NUL char
-
-    // get arguments "type" and "parent" from client RPC descriptor
+    // get arguments "name", "type", and "parent" from client RPC descriptor
     type   = (uint32_t)               hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) );
-    parent = (vfs_inode_t *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[3] ) );
+    name   = (char *)(intptr_t)       hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) );
+    parent = (vfs_inode_t *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[2] ) );
                        
+    // makes a local copy of  name
+    hal_remote_strcpy( XPTR( local_cxy , name_copy ),
+                       XPTR( client_cxy , name ) );
+
     // call local kernel function
     error = vfs_dentry_create( type,
@@ -733,6 +682,6 @@
  
     // set output arguments
-    hal_remote_swd( XPTR( client_cxy , &desc->args[4] ) , (uint64_t)dentry_xp );
-    hal_remote_swd( XPTR( client_cxy , &desc->args[5] ) , (uint64_t)error );
+    hal_remote_swd( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)dentry_xp );
+    hal_remote_swd( XPTR( client_cxy , &desc->args[4] ) , (uint64_t)error );
 }
 
@@ -745,10 +694,5 @@
                                     vfs_dentry_t * dentry )
 {
-    // RPC must be remote
-    if( cxy == local_cxy ) 
-    {
-        printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ );
-        hal_core_sleep();
-    }
+    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
 
     // initialise RPC descriptor header 
@@ -792,10 +736,5 @@
                                  error_t              * error )      // out
 {
-    // RPC must be remote
-    if( cxy == local_cxy ) 
-    {
-        printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ );
-        hal_core_sleep();
-    }
+    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
 
     // initialise RPC descriptor header 
@@ -850,10 +789,5 @@
                                   vfs_file_t * file )
 {
-    // RPC must be remote
-    if( cxy == local_cxy ) 
-    {
-        printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ );
-        hal_core_sleep();
-    }
+    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
 
     // initialise RPC descriptor header 
@@ -886,5 +820,111 @@
 
 /////////////////////////////////////////////////////////////////////////////////////////
-// [16]          Marshaling functions attached to RPC_FATFS_GET_CLUSTER 
+// [16]          Marshaling functions attached to RPC_VFS_INODE_LOAD  
+/////////////////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////
+void rpc_vfs_inode_load_client( cxy_t         cxy,
+                                vfs_inode_t * parent_inode,    // in
+                                char        * name,            // in
+                                xptr_t        child_inode_xp,  // in
+                                error_t     * error )          // out
+{
+    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
+
+    // initialise RPC descriptor header 
+    rpc_desc_t  rpc;
+    rpc.index    = RPC_VFS_INODE_LOAD;
+    rpc.response = 1;
+
+    // set input arguments in RPC descriptor 
+    rpc.args[0] = (uint64_t)(intptr_t)parent_inode;
+    rpc.args[1] = (uint64_t)(intptr_t)name;
+    rpc.args[2] = (uint64_t)child_inode_xp;
+
+    // register RPC request in remote RPC fifo (blocking function)
+    rpc_send_sync( cxy , &rpc );
+
+    // get output values from RPC descriptor
+    *error   = (error_t)rpc.args[3];
+}
+
+///////////////////////////////////////////
+void rpc_vfs_inode_load_server( xptr_t xp )
+{
+    error_t       error;
+    vfs_inode_t * parent;
+    xptr_t        child_xp;
+    char        * name;
+
+    char          name_copy[CONFIG_VFS_MAX_NAME_LENGTH];
+
+    // get client cluster identifier and pointer on RPC descriptor
+    cxy_t        client_cxy  = (cxy_t)GET_CXY( xp );
+    rpc_desc_t * desc        = (rpc_desc_t *)GET_PTR( xp );
+
+    // get arguments "parent", "name", and "child_xp"
+    parent     = (vfs_inode_t*)(intptr_t)hal_remote_lwd(XPTR(client_cxy , &desc->args[0]));
+    name       = (char*)(intptr_t)       hal_remote_lwd(XPTR(client_cxy , &desc->args[1]));
+    child_xp   = (xptr_t)                hal_remote_lwd(XPTR(client_cxy , &desc->args[2]));
+
+    // get name local copy
+    hal_remote_strcpy( XPTR( local_cxy , name_copy ) ,
+                       XPTR( client_cxy , name ) );
+
+    // call the kernel function
+    error = vfs_inode_load( parent , name_copy , child_xp );
+
+    // set output argument
+    hal_remote_swd( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error );
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// [17]          Marshaling functions attached to RPC_VFS_MAPPER_LOAD_ALL
+/////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////
+void rpc_vfs_mapper_load_all_client( cxy_t         cxy,
+                                     vfs_inode_t * inode,      // in
+                                     error_t     * error )     // out
+{
+    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
+
+    // initialise RPC descriptor header 
+    rpc_desc_t  rpc;
+    rpc.index    = RPC_VFS_INODE_LOAD;
+    rpc.response = 1;
+
+    // set input arguments in RPC descriptor 
+    rpc.args[0] = (uint64_t)(intptr_t)inode;
+
+    // register RPC request in remote RPC fifo (blocking function)
+    rpc_send_sync( cxy , &rpc );
+
+    // get output values from RPC descriptor
+    *error   = (error_t)rpc.args[1];
+}
+
+////////////////////////////////////////////////
+void rpc_vfs_mapper_load_all_server( xptr_t xp )
+{
+    error_t       error;
+    vfs_inode_t * inode;
+
+    // get client cluster identifier and pointer on RPC descriptor
+    cxy_t        client_cxy  = (cxy_t)GET_CXY( xp );
+    rpc_desc_t * desc        = (rpc_desc_t *)GET_PTR( xp );
+
+    // get arguments "parent", "name", and "child_xp"
+    inode = (vfs_inode_t*)(intptr_t)hal_remote_lwd(XPTR(client_cxy , &desc->args[0]));
+
+    // call the kernel function
+    error = vfs_mapper_load_all( inode );
+
+    // set output argument
+    hal_remote_swd( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error );
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// [18]          Marshaling functions attached to RPC_FATFS_GET_CLUSTER 
 /////////////////////////////////////////////////////////////////////////////////////////
 
@@ -897,10 +937,5 @@
                                    error_t  * error )    // out
 {
-    // RPC must be remote
-    if( cxy == local_cxy ) 
-    {
-        printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
-        hal_core_sleep();
-    }
+    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
 
     // initialise RPC descriptor header 
@@ -958,10 +993,5 @@
                                   xptr_t    * vseg_xp )    // out
 {
-    // RPC must be remote
-    if( cxy == local_cxy ) 
-    {
-        printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
-        hal_core_sleep();
-    }
+    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
 
     // initialise RPC descriptor header 
@@ -1019,10 +1049,5 @@
                              error_t   * error )   // out 
 {
-    // RPC must be remote
-    if( cxy == local_cxy ) 
-    {
-        printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
-        hal_core_sleep();
-    }
+    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
 
     // initialise RPC descriptor header 
@@ -1079,10 +1104,5 @@
                            xptr_t *   buf_xp )     // out
 {
-    // RPC must be remote
-    if( cxy == local_cxy ) 
-    {
-        printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
-        hal_core_sleep();
-    }
+    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
 
     // initialise RPC descriptor header 
@@ -1131,10 +1151,5 @@
                           uint32_t   kmem_type )   // in
 {
-    // RPC must be remote
-    if( cxy == local_cxy ) 
-    {
-        printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
-        hal_core_sleep();
-    }
+    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
 
     // initialise RPC descriptor header 
@@ -1182,10 +1197,5 @@
                              error_t  * error )        // out
 {
-    // RPC must be remote
-    if( cxy == local_cxy ) 
-    {
-        printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ );
-        hal_core_sleep();
-    }
+    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
 
     // initialise RPC descriptor header 
