Changeset 612 for trunk/kernel/syscalls


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/syscalls
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/syscalls/sys_closedir.c

    r611 r612  
    2828#include <thread.h>
    2929#include <process.h>
    30 #include <remote_dir.h>
     30#include <user_dir.h>
    3131#include <errno.h>
    3232#include <syscalls.h>
     
    3636int sys_closedir ( DIR * dirp )
    3737{
    38     xptr_t         dir_xp;       // extended pointer on remote_dir_t structure
     38    xptr_t         dir_xp;       // extended pointer on user_dir_t structure
     39    user_dir_t   * dir_ptr;      // lcal pointer on user_dir_t structure
     40    cxy_t          dir_cxy;      // cluster identifier (inode cluster)
    3941
    4042        thread_t  * this    = CURRENT_THREAD;  // client thread
     
    5153#endif
    5254 
    53     // get extended pointer on kernel remote_dir_t structure from dirp
    54     dir_xp  = remote_dir_from_ident( (intptr_t)dirp );
     55    // get extended pointer on kernel user_dir_t structure from dirp
     56    dir_xp  = user_dir_from_ident( (intptr_t)dirp );
    5557
    5658    if( dir_xp == XPTR_NULL )
     
    6567        }       
    6668
    67     // delete kernel remote_dir_t structure
    68     remote_dir_destroy( dir_xp );
     69    // get cluster and localpointer for user_dir_t structure
     70    dir_ptr = GET_PTR( dir_xp );
     71    dir_cxy = GET_CXY( dir_xp );
     72   
     73    // delete both user_dir_t structure and dirent array
     74    if( dir_cxy == local_cxy )
     75    {
     76        user_dir_destroy( dir_ptr );
     77    }
     78    else
     79    {
     80        rpc_user_dir_destroy_client( dir_cxy,
     81                                     dir_ptr );
     82    }
    6983
    7084    hal_fence();
  • trunk/kernel/syscalls/sys_display.c

    r611 r612  
    5252    else if( type == DISPLAY_DQDT              ) return "DQDT";
    5353    else if( type == DISPLAY_BUSYLOCKS         ) return "BUSYLOCKS";
     54    else if( type == DISPLAY_MAPPER            ) return "MAPPER";
     55    else                                         return "undefined";
    5456}
    5557#endif
  • trunk/kernel/syscalls/sys_opendir.c

    r611 r612  
    11/*
    2  * sys_opendir.c - Open a VFS directory.
     2 * sys_opendir.c - Open an user accessible VFS directory.
    33 *
    44 * Author        Alain Greiner (2016,2017,2018)
     
    2727#include <thread.h>
    2828#include <process.h>
    29 #include <remote_dir.h>
     29#include <user_dir.h>
    3030#include <printk.h>
    3131#include <errno.h>
     
    4545    cxy_t          inode_cxy;              // directory inode cluster
    4646    uint32_t       inode_type;             // to check directory inode type
    47     xptr_t         dir_xp;                 // extended pointer on remote_dir_t
    48     remote_dir_t * dir_ptr;                // local pointer on remote_dir_t
    49     cxy_t          dir_cxy;                // remote_dir_t cluster identifier
     47    user_dir_t   * dir_ptr;                // local pointer on user_dir_t
    5048    vseg_t       * vseg;                   // for user space checking
    5149    intptr_t       ident;                  // dirent array pointer in user space                 
     
    145143        }
    146144   
    147     // allocate, initialize, and register a new remote_dir_t structure
    148     // in the calling process reference cluster
    149     dir_xp  = remote_dir_create( inode_xp );
    150     dir_ptr = GET_PTR( dir_xp );
    151     dir_cxy = GET_CXY( dir_xp );
     145    // create a new user_dir_t structure in inode cluster
     146    // and get the user space pointer on dirent array
     147    if( inode_cxy == local_cxy )
     148    {
     149        dir_ptr = user_dir_create( inode_ptr );
     150    }
     151    else
     152    {
     153        rpc_user_dir_create_client( inode_cxy,
     154                                    inode_ptr,
     155                                    &dir_ptr );
     156    }
    152157
    153     if( dir_xp == XPTR_NULL )
     158    if( dir_ptr == NULL )
    154159        {
    155160
    156161#if DEBUG_SYSCALLS_ERROR
    157 printk("\n[ERROR] in %s / thread[%x,%x] : cannot create remote_dir for <%s>\n",
     162printk("\n[ERROR] in %s / thread[%x,%x] : cannot create user_dir for <%s>\n",
    158163__FUNCTION__ , process->pid , this->trdid , kbuf );
    159164#endif
     
    162167        }
    163168   
    164     // get ident from remote_dir structure
    165     ident = (intptr_t)hal_remote_lpt( XPTR( dir_cxy , &dir_ptr->ident ) );
     169    // get ident from user_dir structure
     170    ident = (intptr_t)hal_remote_lpt( XPTR( inode_cxy , &dir_ptr->ident ) );
    166171
    167172    // set ident value in user buffer
  • trunk/kernel/syscalls/sys_readdir.c

    r611 r612  
    3030#include <vfs.h>
    3131#include <process.h>
    32 #include <remote_dir.h>
     32#include <user_dir.h>
    3333#include <syscalls.h>
    3434#include <shared_syscalls.h>
     
    4040    error_t         error;
    4141    vseg_t        * vseg;               // for user space checking of buffer
    42     xptr_t          dir_xp;             // extended pointer on remote_dir_t structure
    43     remote_dir_t  * dir_ptr;            // local pointer on remote_dir_t structure
    44     cxy_t           dir_cxy;            // remote_dir_t stucture cluster identifier
     42    xptr_t          dir_xp;             // extended pointer on user_dir structure
     43    user_dir_t    * dir_ptr;            // local pointer on user_dir structure
     44    cxy_t           dir_cxy;            // user_dir stucture cluster identifier
    4545    struct dirent * direntp;            // dirent pointer in user space 
    4646    uint32_t        entries;            // total number of dirent entries
     
    7575        }       
    7676
    77     // get pointers on remote_dir_t structure from dirp
    78     dir_xp  = remote_dir_from_ident( (intptr_t)dirp );
     77    // get pointers on user_dir structure from dirp
     78    dir_xp  = user_dir_from_ident( (intptr_t)dirp );
    7979    dir_ptr = GET_PTR( dir_xp );
    8080    dir_cxy = GET_CXY( dir_xp );
     
    9191        }       
    9292
    93     // get "current" and "entries_nr" values from remote_dir_t structure
     93    // get "current" and "entries_nr" values from user_dir_t structure
    9494    current = hal_remote_l32( XPTR( dir_cxy , &dir_ptr->current ) );
    9595    entries = hal_remote_l32( XPTR( dir_cxy , &dir_ptr->entries ) );
     
    114114    hal_copy_to_uspace( buffer, &direntp , sizeof(void *) );
    115115
    116     // update current index in "remote_dir_t" structure
     116    // update current index in user_dir structure
    117117    hal_remote_atomic_add( XPTR( dir_cxy , &dir_ptr->current ) , 1 );
    118118
Note: See TracChangeset for help on using the changeset viewer.