Ignore:
Timestamp:
Jul 19, 2017, 3:31:39 PM (4 years ago)
Author:
alain
Message:

Fixing bugs in vfs_lookup()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/rpc.c

    r188 r238  
    6666    &rpc_vfs_file_create_server,        // 14
    6767    &rpc_vfs_file_destroy_server,       // 15
    68     &rpc_fatfs_get_cluster_server,      // 16
    69     &rpc_undefined,                     // 17
    70     &rpc_undefined,                     // 18
     68    &rpc_vfs_inode_load_server,         // 16
     69    &rpc_vfs_mapper_load_all_server,    // 17
     70    &rpc_fatfs_get_cluster_server,      // 18
    7171    &rpc_undefined,                     // 19
    7272
     
    100100                                uint32_t * ppn )       // out
    101101{
    102     // any RPC must be remote
    103     if( cxy == local_cxy )
    104     {
    105         printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
    106         hal_core_sleep();
    107     }
     102    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
    108103
    109104    // initialise RPC descriptor header
     
    157152                                   pid_t     * pid )     // out
    158153{
    159     // RPC must be remote
    160     if( cxy == local_cxy )
    161     {
    162         printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
    163         hal_core_sleep();
    164     }
     154    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
    165155
    166156    // initialise RPC descriptor header
     
    213203                              error_t     * error )   // out
    214204{
    215     // RPC must be remote
    216     if( cxy == local_cxy )
    217     {
    218         printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
    219         hal_core_sleep();
    220     }
     205    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
    221206
    222207    // initialise RPC descriptor header
     
    270255{
    271256    // only reference cluster can send this RPC
    272     if( GET_CXY( process->ref_xp ) != local_cxy )
    273     {
    274         printk("PANIC in %s : caller is not the reference process\n", __FUNCTION__ );
    275         hal_core_sleep();
    276     }
     257    assert( (GET_CXY( process->ref_xp ) == local_cxy) , __FUNCTION__ ,
     258            "caller must be reference process cluster\n");
    277259
    278260    // get local process index in reference cluster
     
    344326                                    error_t        * error )      // out
    345327{
    346     // RPC must be remote
    347     if( cxy == local_cxy )
    348     {
    349         printk("\n[PANIC] in %s : target is not remote\n", __FUNCTION__ );
    350         hal_core_sleep();
    351     }
     328    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
    352329
    353330    // initialise RPC descriptor header
     
    427404                                      error_t * error )      // out
    428405{
    429     // RPC must be remote
    430     if( cxy == local_cxy )
    431     {
    432         printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
    433         hal_core_sleep();
    434     }
     406    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
    435407
    436408    // initialise RPC descriptor header
     
    490462                             uint32_t    sig_id )    // in
    491463{
    492     // RPC must be remote
    493     if( cxy == local_cxy )
    494     {
    495         printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
    496         hal_core_sleep();
    497     }
     464    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
    498465
    499466    // initialise RPC descriptor header
     
    545512                                  error_t      * error )     // out
    546513{
    547     // RPC must be remote
    548     if( cxy == local_cxy )
    549     {
    550         printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ );
    551         hal_core_sleep();
    552     }
     514    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
    553515
    554516    // initialise RPC descriptor header
     
    627589                                   struct vfs_inode_s * inode )
    628590{
    629     // RPC must be remote
    630     if( cxy == local_cxy )
    631     {
    632         printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ );
    633         hal_core_sleep();
    634     }
     591    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
    635592
    636593    // initialise RPC descriptor header
     
    674631                                   error_t              * error )       // out
    675632{
    676     // RPC must be remote
    677     if( cxy == local_cxy )
    678     {
    679         printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ );
    680         hal_core_sleep();
    681     }
     633    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
    682634
    683635    // initialise RPC descriptor header
     
    689641    rpc.args[0] = (uint64_t)type;
    690642    rpc.args[1] = (uint64_t)(intptr_t)name;
    691     rpc.args[2] = (uint64_t)strlen( name );
    692     rpc.args[3] = (uint64_t)(intptr_t)parent;
     643    rpc.args[2] = (uint64_t)(intptr_t)parent;
    693644
    694645    // register RPC request in remote RPC fifo (blocking function)
     
    696647
    697648    // get output values from RPC descriptor
    698     *dentry_xp = (xptr_t)rpc.args[4];
    699     *error     = (error_t)rpc.args[5];
     649    *dentry_xp = (xptr_t)rpc.args[3];
     650    *error     = (error_t)rpc.args[4];
    700651}
    701652
     
    707658    vfs_inode_t * parent;
    708659    xptr_t        dentry_xp;
     660    error_t       error;
     661
    709662    char          name_copy[CONFIG_VFS_MAX_NAME_LENGTH];
    710     uint32_t      length;
    711     error_t       error;
    712663
    713664    // get client cluster identifier and pointer on RPC descriptor
     
    715666    rpc_desc_t * desc        = (rpc_desc_t *)GET_PTR( xp );
    716667
    717     // get argument "name" & "length" from client RPC descriptor and makes a local copy
    718     name   = (char *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) );
    719     length = (uint32_t)        hal_remote_lwd( XPTR( client_cxy , &desc->args[2] ) );
    720     hal_remote_memcpy( XPTR( local_cxy , name_copy ),
    721                        XPTR( client_cxy , name ),
    722                                            length + 1 );               // +1 for the NUL char
    723 
    724     // get arguments "type" and "parent" from client RPC descriptor
     668    // get arguments "name", "type", and "parent" from client RPC descriptor
    725669    type   = (uint32_t)               hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) );
    726     parent = (vfs_inode_t *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[3] ) );
     670    name   = (char *)(intptr_t)       hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) );
     671    parent = (vfs_inode_t *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[2] ) );
    727672                       
     673    // makes a local copy of  name
     674    hal_remote_strcpy( XPTR( local_cxy , name_copy ),
     675                       XPTR( client_cxy , name ) );
     676
    728677    // call local kernel function
    729678    error = vfs_dentry_create( type,
     
    733682 
    734683    // set output arguments
    735     hal_remote_swd( XPTR( client_cxy , &desc->args[4] ) , (uint64_t)dentry_xp );
    736     hal_remote_swd( XPTR( client_cxy , &desc->args[5] ) , (uint64_t)error );
     684    hal_remote_swd( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)dentry_xp );
     685    hal_remote_swd( XPTR( client_cxy , &desc->args[4] ) , (uint64_t)error );
    737686}
    738687
     
    745694                                    vfs_dentry_t * dentry )
    746695{
    747     // RPC must be remote
    748     if( cxy == local_cxy )
    749     {
    750         printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ );
    751         hal_core_sleep();
    752     }
     696    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
    753697
    754698    // initialise RPC descriptor header
     
    792736                                 error_t              * error )      // out
    793737{
    794     // RPC must be remote
    795     if( cxy == local_cxy )
    796     {
    797         printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ );
    798         hal_core_sleep();
    799     }
     738    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
    800739
    801740    // initialise RPC descriptor header
     
    850789                                  vfs_file_t * file )
    851790{
    852     // RPC must be remote
    853     if( cxy == local_cxy )
    854     {
    855         printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ );
    856         hal_core_sleep();
    857     }
     791    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
    858792
    859793    // initialise RPC descriptor header
     
    886820
    887821/////////////////////////////////////////////////////////////////////////////////////////
    888 // [16]          Marshaling functions attached to RPC_FATFS_GET_CLUSTER
     822// [16]          Marshaling functions attached to RPC_VFS_INODE_LOAD 
     823/////////////////////////////////////////////////////////////////////////////////////////
     824
     825//////////////////////////////////////////////////
     826void rpc_vfs_inode_load_client( cxy_t         cxy,
     827                                vfs_inode_t * parent_inode,    // in
     828                                char        * name,            // in
     829                                xptr_t        child_inode_xp,  // in
     830                                error_t     * error )          // out
     831{
     832    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
     833
     834    // initialise RPC descriptor header
     835    rpc_desc_t  rpc;
     836    rpc.index    = RPC_VFS_INODE_LOAD;
     837    rpc.response = 1;
     838
     839    // set input arguments in RPC descriptor
     840    rpc.args[0] = (uint64_t)(intptr_t)parent_inode;
     841    rpc.args[1] = (uint64_t)(intptr_t)name;
     842    rpc.args[2] = (uint64_t)child_inode_xp;
     843
     844    // register RPC request in remote RPC fifo (blocking function)
     845    rpc_send_sync( cxy , &rpc );
     846
     847    // get output values from RPC descriptor
     848    *error   = (error_t)rpc.args[3];
     849}
     850
     851///////////////////////////////////////////
     852void rpc_vfs_inode_load_server( xptr_t xp )
     853{
     854    error_t       error;
     855    vfs_inode_t * parent;
     856    xptr_t        child_xp;
     857    char        * name;
     858
     859    char          name_copy[CONFIG_VFS_MAX_NAME_LENGTH];
     860
     861    // get client cluster identifier and pointer on RPC descriptor
     862    cxy_t        client_cxy  = (cxy_t)GET_CXY( xp );
     863    rpc_desc_t * desc        = (rpc_desc_t *)GET_PTR( xp );
     864
     865    // get arguments "parent", "name", and "child_xp"
     866    parent     = (vfs_inode_t*)(intptr_t)hal_remote_lwd(XPTR(client_cxy , &desc->args[0]));
     867    name       = (char*)(intptr_t)       hal_remote_lwd(XPTR(client_cxy , &desc->args[1]));
     868    child_xp   = (xptr_t)                hal_remote_lwd(XPTR(client_cxy , &desc->args[2]));
     869
     870    // get name local copy
     871    hal_remote_strcpy( XPTR( local_cxy , name_copy ) ,
     872                       XPTR( client_cxy , name ) );
     873
     874    // call the kernel function
     875    error = vfs_inode_load( parent , name_copy , child_xp );
     876
     877    // set output argument
     878    hal_remote_swd( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error );
     879}
     880
     881/////////////////////////////////////////////////////////////////////////////////////////
     882// [17]          Marshaling functions attached to RPC_VFS_MAPPER_LOAD_ALL
     883/////////////////////////////////////////////////////////////////////////////////////////
     884
     885///////////////////////////////////////////////////////
     886void rpc_vfs_mapper_load_all_client( cxy_t         cxy,
     887                                     vfs_inode_t * inode,      // in
     888                                     error_t     * error )     // out
     889{
     890    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
     891
     892    // initialise RPC descriptor header
     893    rpc_desc_t  rpc;
     894    rpc.index    = RPC_VFS_INODE_LOAD;
     895    rpc.response = 1;
     896
     897    // set input arguments in RPC descriptor
     898    rpc.args[0] = (uint64_t)(intptr_t)inode;
     899
     900    // register RPC request in remote RPC fifo (blocking function)
     901    rpc_send_sync( cxy , &rpc );
     902
     903    // get output values from RPC descriptor
     904    *error   = (error_t)rpc.args[1];
     905}
     906
     907////////////////////////////////////////////////
     908void rpc_vfs_mapper_load_all_server( xptr_t xp )
     909{
     910    error_t       error;
     911    vfs_inode_t * inode;
     912
     913    // get client cluster identifier and pointer on RPC descriptor
     914    cxy_t        client_cxy  = (cxy_t)GET_CXY( xp );
     915    rpc_desc_t * desc        = (rpc_desc_t *)GET_PTR( xp );
     916
     917    // get arguments "parent", "name", and "child_xp"
     918    inode = (vfs_inode_t*)(intptr_t)hal_remote_lwd(XPTR(client_cxy , &desc->args[0]));
     919
     920    // call the kernel function
     921    error = vfs_mapper_load_all( inode );
     922
     923    // set output argument
     924    hal_remote_swd( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error );
     925}
     926
     927/////////////////////////////////////////////////////////////////////////////////////////
     928// [18]          Marshaling functions attached to RPC_FATFS_GET_CLUSTER
    889929/////////////////////////////////////////////////////////////////////////////////////////
    890930
     
    897937                                   error_t  * error )    // out
    898938{
    899     // RPC must be remote
    900     if( cxy == local_cxy )
    901     {
    902         printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
    903         hal_core_sleep();
    904     }
     939    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
    905940
    906941    // initialise RPC descriptor header
     
    958993                                  xptr_t    * vseg_xp )    // out
    959994{
    960     // RPC must be remote
    961     if( cxy == local_cxy )
    962     {
    963         printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
    964         hal_core_sleep();
    965     }
     995    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
    966996
    967997    // initialise RPC descriptor header
     
    10191049                             error_t   * error )   // out
    10201050{
    1021     // RPC must be remote
    1022     if( cxy == local_cxy )
    1023     {
    1024         printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
    1025         hal_core_sleep();
    1026     }
     1051    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
    10271052
    10281053    // initialise RPC descriptor header
     
    10791104                           xptr_t *   buf_xp )     // out
    10801105{
    1081     // RPC must be remote
    1082     if( cxy == local_cxy )
    1083     {
    1084         printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
    1085         hal_core_sleep();
    1086     }
     1106    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
    10871107
    10881108    // initialise RPC descriptor header
     
    11311151                          uint32_t   kmem_type )   // in
    11321152{
    1133     // RPC must be remote
    1134     if( cxy == local_cxy )
    1135     {
    1136         printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
    1137         hal_core_sleep();
    1138     }
     1153    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
    11391154
    11401155    // initialise RPC descriptor header
     
    11821197                             error_t  * error )        // out
    11831198{
    1184     // RPC must be remote
    1185     if( cxy == local_cxy )
    1186     {
    1187         printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ );
    1188         hal_core_sleep();
    1189     }
     1199    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
    11901200
    11911201    // initialise RPC descriptor header
Note: See TracChangeset for help on using the changeset viewer.