Changeset 612 for trunk/kernel/kern


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.

Location:
trunk/kernel/kern
Files:
4 edited

Legend:

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

    r611 r612  
    33 *
    44 * Authors :  Mohamed Lamine Karaoui (2015)
    5  *            Alain Greiner  (2016,2017)
     5 *            Alain Greiner  (2016,2017,2018)
    66 *
    77 * Copyright (c) Sorbonne Universites
  • trunk/kernel/kern/process.h

    r611 r612  
    382382 * The "new" process keep the "old" process PID and PPID, all open files, and env variables,
    383383 * the vfs_root and vfs_cwd, but build a brand new memory image (new VMM from the new .elf).
    384  * It actually creates a "new" reference process descriptor, and copies all relevant
    385  * information from the "old" process descriptor to the "new" process descriptor.
    386  * It completes the "new" process descriptor, from information found in the <exec_info>
    387  * structure (defined in the process.h file), that must be built by the caller.
    388  * It creates and initializes the associated main thread. It finally destroys all copies
    389  * of the "old" process in all clusters, and destroys all old associated threads.
    390384 * It is executed in the local cluster, that becomes both the "owner" and the "reference"
    391385 * cluster for the "new" process.
  • 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 );
  • trunk/kernel/kern/rpc.h

    r611 r612  
    4040struct pthread_attr_s;
    4141struct remote_sem_s;
     42struct user_dir_s;
    4243struct fragment_s;
    4344struct vfs_inode_s;
     
    6364    RPC_UNDEFINED_2               = 2,     
    6465    RPC_PROCESS_MAKE_FORK         = 3,
    65     RPC_UNDEFINED_4               = 4,
    66     RPC_UNDEFINED_5               = 5,
     66    RPC_USER_DIR_CREATE           = 4,
     67    RPC_USER_DIR_DESTROY          = 5,
    6768    RPC_THREAD_USER_CREATE        = 6,
    6869    RPC_THREAD_KERNEL_CREATE      = 7,
     
    7677    RPC_VFS_FILE_CREATE           = 14,
    7778    RPC_VFS_FILE_DESTROY          = 15,
    78     RPC_VFS_FS_CHILD_INIT         = 16,
     79    RPC_VFS_FS_GET_DENTRY         = 16,
    7980    RPC_VFS_FS_ADD_DENTRY         = 17,
    8081    RPC_VFS_FS_REMOVE_DENTRY      = 18,
     
    226227
    227228/***********************************************************************************
    228  * [4] undefined slot
    229  **********************************************************************************/
    230 
    231 /***********************************************************************************
    232  * [5] undefined slot
    233  **********************************************************************************/
     229 * [4] The RPC_USER_DIR_CREATE allows a client thread to create an user_dir_t
     230 * structure and the associated array of dirents in a remote cluster containing
     231 * the target directory inode. It is called by the sys_opendir() function.
     232 ***********************************************************************************
     233 * @ cxy        : server cluster identifier.
     234 * @ inode      : [in]   local pointer on inode in server cluster.
     235 * @ dir        : [out]  local pointer on created user_dir structure.
     236 **********************************************************************************/
     237void rpc_user_dir_create_client( cxy_t                 cxy,
     238                                 struct vfs_inode_s  * inode,
     239                                 struct user_dir_s  ** dir );
     240
     241void rpc_user_dir_create_server( xptr_t xp );
     242
     243/***********************************************************************************
     244 * [5] The RPC_USER_DIR_DESTROY allows a client thread to delete an user_dir_t
     245 * structure and the associated array of dirents in a remote cluster containing
     246 * the target directory inode. It is called by the sys_closedir() function.
     247 ***********************************************************************************
     248 * @ cxy        : server cluster identifier.
     249 * @ dir        : [in]  local pointer on created user_dir structure.
     250 **********************************************************************************/
     251void rpc_user_dir_destroy_client( cxy_t               cxy,
     252                                  struct user_dir_s * dir );
     253
     254void rpc_user_dir_destroy_server( xptr_t xp );
    234255
    235256/***********************************************************************************
     
    402423
    403424/***********************************************************************************
    404  * [16] The RPC_VFS_FS_CHILD_INIT calls the vfs_fs_child_init_load_inode()
     425 * [16] The RPC_VFS_FS_GET_DENTRY calls the vfs_fs_get_dentry()
    405426 * function in a remote cluster containing a parent inode directory to scan the
    406427 * associated mapper, find a directory entry identified by its name, and update
    407  * both the child inode and the dentry.
     428 * both the - existing - child inode and dentry.
    408429 ***********************************************************************************
    409430 * @ cxy            : server cluster identifier
     
    413434 * @ error          : [out] error status (0 if success).
    414435 **********************************************************************************/
    415 void rpc_vfs_fs_child_init_client( cxy_t                cxy,
     436void rpc_vfs_fs_get_dentry_client( cxy_t                cxy,
    416437                                   struct vfs_inode_s * parent_inode,
    417438                                   char               * name,
     
    419440                                   error_t            * error );
    420441
    421 void rpc_vfs_fs_child_init_server( xptr_t xp );
     442void rpc_vfs_fs_get_dentry_server( xptr_t xp );
    422443
    423444/***********************************************************************************
Note: See TracChangeset for help on using the changeset viewer.