Ignore:
Timestamp:
Nov 19, 2020, 11:45:52 PM (4 years ago)
Author:
alain
Message:

1) Introduce up to 4 command lines arguments in the KSH "load" command.
These arguments are transfered to the user process through the
argc/argv mechanism, using the user space "args" vseg.

2) Introduce the named and anonymous "pipes", for inter-process communication
through the pipe() and mkfifo() syscalls.

3) Introduce the "chat" application to validate the two above mechanisms.

4) Improve printk() and assert() fonctions in printk.c.

File:
1 edited

Legend:

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

    r637 r670  
    3939               uint32_t   mode )
    4040{
     41    vseg_t       * vseg;
    4142    error_t        error;
    4243    xptr_t         file_xp;                 // extended pointer on vfs_file_t
    4344    uint32_t       file_id;                 // file descriptor index
    44     xptr_t         root_inode_xp;           // extended pointer on path root inode
     45    xptr_t         root_inode_xp;           // extended pointer on root inode
    4546
    4647    char           kbuf[CONFIG_VFS_MAX_PATH_LENGTH];
     
    4950    process_t    * process  = this->process;
    5051
    51 #if (DEBUG_SYS_OPEN || CONFIG_INSTRUMENTATION_SYSCALLS)
     52#if DEBUG_SYS_OPEN || DEBUG_SYSCALLS_ERROR || CONFIG_INSTRUMENTATION_SYSCALLS
    5253uint64_t     tm_start = hal_get_cycles();
    5354#endif
     
    5859
    5960#if DEBUG_SYSCALLS_ERROR
    60 printk("\n[ERROR] in %s : file descriptor array full for process %x\n",
    61 __FUNCTION__ , process->pid );
     61if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start )
     62printk("\n[ERROR] in %s : file descriptor array full for thread[%x,%x]\n",
     63__FUNCTION__ , process->pid , this->trdid );
    6264#endif
    6365        this->errno = ENFILE;
    6466        return -1;
    6567    }
     68
     69    // check pathname in user space
     70    if( vmm_get_vseg( process, (intptr_t)pathname , &vseg ) )
     71        {
     72
     73#if DEBUG_SYSCALLS_ERROR
     74if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start )
     75printk("\n[ERROR] in %s : user buffer unmapped %x for thread[%x,%x]\n",
     76__FUNCTION__ , (intptr_t)pathname , process->pid, this->trdid );
     77#endif
     78                this->errno = EINVAL;
     79        return -1;
     80        }
    6681
    6782    // check pathname length
     
    7085
    7186#if DEBUG_SYSCALLS_ERROR
    72 printk("\n[ERROR] in %s : pathname too long\n", __FUNCTION__ );
     87if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start )
     88printk("\n[ERROR] in %s : pathname too long for thread[%x,%x]\n",
     89__FUNCTION__ , process->pid , this->trdid );
    7390#endif
    7491        this->errno = ENFILE;
     
    7794
    7895    // copy pathname in kernel space
    79     hal_strcpy_from_uspace( XPTR( local_cxy , kbuf ) , pathname , CONFIG_VFS_MAX_PATH_LENGTH );
    80 
     96    hal_strcpy_from_uspace( XPTR( local_cxy , kbuf ),
     97                            pathname,
     98                            CONFIG_VFS_MAX_PATH_LENGTH );
    8199#if DEBUG_SYS_OPEN
    82100if( DEBUG_SYS_OPEN < tm_start )
     
    86104 
    87105    // get cluster and local pointer on reference process
    88     xptr_t      ref_xp  = process->ref_xp;
    89     process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );
    90     cxy_t       ref_cxy = GET_CXY( ref_xp );
     106    xptr_t      owner_xp  = process->owner_xp;
     107    process_t * owner_ptr = GET_PTR( owner_xp );
     108    cxy_t       owner_cxy = GET_CXY( owner_xp );
    91109
    92     // compute root inode for path
    93     if( kbuf[0] == '/' )                        // absolute path
     110    // get extended pointer on root inode in path
     111    if( kbuf[0] == '/' )                            // absolute path
    94112    {
    95113        // use extended pointer on VFS root inode
    96114        root_inode_xp = process->vfs_root_xp;
    97115    }
    98     else                                        // relative path
     116    else                                            // relative path
    99117    {
    100118        // use extended pointer on CWD inode
    101         root_inode_xp = hal_remote_l64( XPTR( ref_cxy , &ref_ptr->cwd_xp ) );
     119        root_inode_xp = hal_remote_l64( XPTR( owner_cxy , &owner_ptr->cwd_xp ) );
    102120    }
    103121
     
    105123    error = vfs_open( root_inode_xp,
    106124                      kbuf,
    107                       ref_xp,
     125                      owner_xp,
    108126                      flags,
    109127                      mode,
     
    113131    if( error )
    114132    {
    115         printk("\n[ERROR] in %s : cannot create file descriptor for %s\n",
    116         __FUNCTION__ , kbuf );
     133
     134#if DEBUG_SYSCALLS_ERROR
     135if( DEBUG_SYSCALLS_ERROR < tm_start )
     136printk("\n[ERROR] in %s : thread[%x,%x] cannot create file descriptor for %s\n",
     137__FUNCTION__ , process->pid , this->trdid , kbuf );
     138#endif
    117139        this->errno = ENFILE;
    118140        return -1;
Note: See TracChangeset for help on using the changeset viewer.