Ignore:
Timestamp:
Jan 11, 2019, 6:35:07 PM (5 years ago)
Author:
alain
Message:

Fix several bugs in vfs.c, fatfs.c, and devfs.c to support
the <.> and <..> directory entries.

File:
1 edited

Legend:

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

    r611 r612  
    2929#include <hal_special.h>
    3030#include <printk.h>
     31#include <user_dir.h>
    3132#include <remote_sem.h>
    3233#include <core.h>
     
    6667    &rpc_vfs_file_create_server,           // 14
    6768    &rpc_vfs_file_destroy_server,          // 15
    68     &rpc_vfs_fs_child_init_server,         // 16
     69    &rpc_vfs_fs_get_dentry_server,         // 16
    6970    &rpc_vfs_fs_add_dentry_server,         // 17
    7071    &rpc_vfs_fs_remove_dentry_server,      // 18
     
    102103    "VFS_FILE_CREATE",           // 14
    103104    "VFS_FILE_DESTROY",          // 15
    104     "VFS_FS_CHILD_INIT",         // 16
     105    "VFS_FS_GET_DENTRY",         // 16
    105106    "VFS_FS_ADD_DENTRY",         // 17
    106107    "VFS_FS_REMOVE_DENTRY",      // 18
     
    650651
    651652/////////////////////////////////////////////////////////////////////////////////////////
    652 // [4]      undefined slot
    653 /////////////////////////////////////////////////////////////////////////////////////////
    654 
    655 /////////////////////////////////////////////////////////////////////////////////////////
    656 // [5]      undefined slot
    657 /////////////////////////////////////////////////////////////////////////////////////////
     653// [4]      Marshaling functions attached to RPC_USER_DIR_CREATE (blocking)
     654/////////////////////////////////////////////////////////////////////////////////////////
     655
     656////////////////////////////////////////////////////
     657void rpc_user_dir_create_client( cxy_t          cxy,
     658                                 vfs_inode_t *  inode,
     659                                 user_dir_t  ** dir )
     660{
     661#if DEBUG_RPC_USER_DIR_CREATE
     662thread_t * this = CURRENT_THREAD;
     663uint32_t cycle = (uint32_t)hal_get_cycles();
     664if( cycle > DEBUG_RPC_USER_DIR_CREATE)
     665printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
     666__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
     667#endif
     668
     669    assert( (cxy != local_cxy) , "server cluster is not remote\n");
     670
     671    // initialise RPC descriptor header
     672    rpc_desc_t  rpc;
     673    rpc.index    = RPC_USER_DIR_CREATE;
     674    rpc.blocking = true;
     675    rpc.responses = 1;
     676
     677    // set input arguments in RPC descriptor
     678    rpc.args[0] = (uint64_t)(intptr_t)inode;
     679
     680    // register RPC request in remote RPC fifo
     681    rpc_send( cxy , &rpc );
     682
     683    // get output argument from RPC descriptor
     684    *dir = (user_dir_t *)(intptr_t)rpc.args[1];
     685
     686#if DEBUG_RPC_USER_DIR_CREATE
     687cycle = (uint32_t)hal_get_cycles();
     688if( cycle > DEBUG_RPC_USER_DIR_CREATE)
     689printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
     690__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
     691#endif
     692}
     693
     694////////////////////////////////////////////
     695void rpc_user_dir_create_server( xptr_t xp )
     696{
     697#if DEBUG_RPC_USER_DIR_CREATE
     698thread_t * this = CURRENT_THREAD;
     699uint32_t cycle = (uint32_t)hal_get_cycles();
     700if( cycle > DEBUG_RPC_USER_DIR_CREATE)
     701printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
     702__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
     703#endif
     704
     705    vfs_inode_t * inode;          // pointer on inode in server cluster
     706    user_dir_t  * dir;            // pointer on user_dir structure in server cluster
     707
     708    // get client cluster identifier and pointer on RPC descriptor
     709    cxy_t        client_cxy  = GET_CXY( xp );
     710    rpc_desc_t * desc        = GET_PTR( xp );
     711
     712    // get input argument from RPC descriptor
     713    inode = (vfs_inode_t *)(intptr_t)hal_remote_l64(XPTR(client_cxy , &desc->args[0]));
     714
     715    // call kernel function
     716    dir = user_dir_create( inode );
     717
     718    // set output argument into RPC descriptor
     719    hal_remote_s64( XPTR( client_cxy , &desc->args[1] ) , (intptr_t)dir );
     720
     721#if DEBUG_RPC_USER_DIR_CREATE
     722cycle = (uint32_t)hal_get_cycles();
     723if( cycle > DEBUG_RPC_USER_DIR_CREATE)
     724printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
     725__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
     726#endif
     727}
     728
     729/////////////////////////////////////////////////////////////////////////////////////////
     730// [5]      Marshaling functions attached to RPC_USER_DIR_DESTROY (blocking)
     731/////////////////////////////////////////////////////////////////////////////////////////
     732
     733////////////////////////////////////////////////////
     734void rpc_user_dir_destroy_client( cxy_t         cxy,
     735                                  user_dir_t  * dir )
     736{
     737#if DEBUG_RPC_USER_DIR_DESTROY
     738thread_t * this = CURRENT_THREAD;
     739uint32_t cycle = (uint32_t)hal_get_cycles();
     740if( cycle > DEBUG_RPC_USER_DIR_DESTROY)
     741printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
     742__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
     743#endif
     744
     745    assert( (cxy != local_cxy) , "server cluster is not remote\n");
     746
     747    // initialise RPC descriptor header
     748    rpc_desc_t  rpc;
     749    rpc.index    = RPC_USER_DIR_DESTROY;
     750    rpc.blocking = true;
     751    rpc.responses = 1;
     752
     753    // set input arguments in RPC descriptor
     754    rpc.args[0] = (uint64_t)(intptr_t)dir;
     755
     756    // register RPC request in remote RPC fifo
     757    rpc_send( cxy , &rpc );
     758
     759#if DEBUG_RPC_USER_DIR_DESTROY
     760cycle = (uint32_t)hal_get_cycles();
     761if( cycle > DEBUG_RPC_USER_DIR_DESTROY)
     762printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
     763__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
     764#endif
     765}
     766
     767/////////////////////////////////////////////
     768void rpc_user_dir_destroy_server( xptr_t xp )
     769{
     770#if DEBUG_RPC_USER_DIR_DESTROY
     771thread_t * this = CURRENT_THREAD;
     772uint32_t cycle = (uint32_t)hal_get_cycles();
     773if( cycle > DEBUG_RPC_USER_DIR_DESTROY)
     774printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
     775__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
     776#endif
     777
     778    user_dir_t * dir;            // pointer on user_dir structure in server cluster
     779
     780    // get client cluster identifier and pointer on RPC descriptor
     781    cxy_t        client_cxy  = GET_CXY( xp );
     782    rpc_desc_t * desc        = GET_PTR( xp );
     783
     784    // get input argument from RPC descriptor
     785    dir = (user_dir_t *)(intptr_t)hal_remote_l64(XPTR(client_cxy , &desc->args[0]));
     786
     787    // call kernel function
     788    user_dir_destroy( dir );
     789
     790#if DEBUG_RPC_USER_DIR_DESTROY
     791cycle = (uint32_t)hal_get_cycles();
     792if( cycle > DEBUG_RPC_USER_DIR_DESTROY)
     793printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
     794__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
     795#endif
     796}
    658797
    659798/////////////////////////////////////////////////////////////////////////////////////////
     
    731870    cxy_t        client_cxy  = GET_CXY( xp );
    732871    rpc_desc_t * desc        = GET_PTR( xp );
    733 
    734     // get pointer on attributes structure in client cluster from RPC descriptor
    735872
    736873    // get input arguments from RPC descriptor
     
    751888                                &attr_copy,
    752889                                &thread_ptr );
    753 
    754890    // set output arguments
    755891    thread_xp = XPTR( local_cxy , thread_ptr );
     
    14261562
    14271563/////////////////////////////////////////////////////////////////////////////////////////
    1428 // [16]      Marshaling functions attached to RPC_VFS_FS_CHILD_INIT  (blocking)
     1564// [16]      Marshaling functions attached to RPC_VFS_FS_GET_DENTRY  (blocking)
    14291565/////////////////////////////////////////////////////////////////////////////////////////
    14301566
    14311567/////////////////////////////////////////////////////////
    1432 void rpc_vfs_fs_child_init_client( cxy_t         cxy,
     1568void rpc_vfs_fs_get_dentry_client( cxy_t         cxy,
    14331569                                   vfs_inode_t * parent_inode,    // in
    14341570                                   char        * name,            // in
     
    14361572                                   error_t     * error )          // out
    14371573{
    1438 #if DEBUG_RPC_VFS_FS_CHILD_INIT
    1439 thread_t * this = CURRENT_THREAD;
    1440 uint32_t cycle = (uint32_t)hal_get_cycles();
    1441 if( cycle > DEBUG_RPC_VFS_FS_CHILD_INIT )
     1574#if DEBUG_RPC_VFS_FS_GET_DENTRY
     1575thread_t * this = CURRENT_THREAD;
     1576uint32_t cycle = (uint32_t)hal_get_cycles();
     1577if( cycle > DEBUG_RPC_VFS_FS_GET_DENTRY )
    14421578printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
    14431579__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
     
    14481584    // initialise RPC descriptor header
    14491585    rpc_desc_t  rpc;
    1450     rpc.index    = RPC_VFS_FS_CHILD_INIT;
     1586    rpc.index    = RPC_VFS_FS_GET_DENTRY;
    14511587    rpc.blocking = true;
    14521588    rpc.responses = 1;
     
    14631599    *error   = (error_t)rpc.args[3];
    14641600
    1465 #if DEBUG_RPC_VFS_FS_CHILD_INIT
    1466 cycle = (uint32_t)hal_get_cycles();
    1467 if( cycle > DEBUG_RPC_VFS_FS_CHILD_INIT )
     1601#if DEBUG_RPC_VFS_FS_GET_DENTRY
     1602cycle = (uint32_t)hal_get_cycles();
     1603if( cycle > DEBUG_RPC_VFS_FS_GET_DENTRY )
    14681604printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
    14691605__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
     
    14721608
    14731609//////////////////////////////////////////////
    1474 void rpc_vfs_fs_child_init_server( xptr_t xp )
    1475 {
    1476 #if DEBUG_RPC_VFS_FS_CHILD_INIT
    1477 thread_t * this = CURRENT_THREAD;
    1478 uint32_t cycle = (uint32_t)hal_get_cycles();
    1479 if( cycle > DEBUG_RPC_VFS_FS_CHILD_INIT )
     1610void rpc_vfs_fs_get_dentry_server( xptr_t xp )
     1611{
     1612#if DEBUG_RPC_VFS_FS_GET_DENTRY
     1613thread_t * this = CURRENT_THREAD;
     1614uint32_t cycle = (uint32_t)hal_get_cycles();
     1615if( cycle > DEBUG_RPC_VFS_FS_GET_DENTRY )
    14801616printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
    14811617__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
     
    15031639
    15041640    // call the kernel function
    1505     error = vfs_fs_child_init( parent , name_copy , child_xp );
     1641    error = vfs_fs_get_dentry( parent , name_copy , child_xp );
    15061642
    15071643    // set output argument
    15081644    hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error );
    15091645
    1510 #if DEBUG_RPC_VFS_FS_CHILD_INIT
    1511 cycle = (uint32_t)hal_get_cycles();
    1512 if( cycle > DEBUG_RPC_VFS_FS_CHILD_INIT )
     1646#if DEBUG_RPC_VFS_FS_GET_DENTRY
     1647cycle = (uint32_t)hal_get_cycles();
     1648if( cycle > DEBUG_RPC_VFS_FS_GET_DENTRY )
    15131649printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
    15141650__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
Note: See TracChangeset for help on using the changeset viewer.