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_close.c

    r664 r670  
    11/*
    2  * sys_close.c  close an open file
     2 * sys_close.c  kernel function implementing the <close> syscall
    33 *
    4  * Author    Alain Greiner (2016,2017,2018,2019,2020)
     4 * Author       Alain Greiner (2016,2017,2018,2019,2020)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    4040    cxy_t              file_cxy;
    4141    vfs_file_t       * file_ptr;
    42     vfs_inode_type_t   file_type;
     42    vfs_file_type_t   file_type;
    4343
    4444        thread_t  * this    = CURRENT_THREAD;
    4545        process_t * process = this->process;
    4646
    47 #if (DEBUG_SYS_CLOSE || CONFIG_INSTRUMENTATION_SYSCALLS)
     47#if DEBUG_SYS_CLOSE || DEBUG_SYSCALLS_ERROR || CONFIG_INSTRUMENTATION_SYSCALLS
    4848uint64_t     tm_start = hal_get_cycles();
    4949#endif
    5050
    5151#if DEBUG_SYS_CLOSE
    52 if( DEBUG_SYS_CLOSE < tm_start )
     52if( DEBUG_SYS_CLOSE < (uint32_t)tm_start )
    5353printk("\n[%s] thread[%x,%x] enter / fdid %d / cycle %d\n",
    5454__FUNCTION__, process->pid, this->trdid, fdid, (uint32_t)tm_start );
     
    6060
    6161#if DEBUG_SYSCALLS_ERROR
    62 printk("\n[ERROR] in %s : illegal file descriptor index = %d\n",
    63 __FUNCTION__ , fdid );
     62if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start )
     63printk("\n[ERROR] in %s : thread[%x,%x] / illegal file descriptor index = %d\n",
     64__FUNCTION__ , process->pid , this->trdid , fdid );
    6465#endif
    6566                this->errno = EBADFD;
     
    7475
    7576#if DEBUG_SYSCALLS_ERROR
    76 printk("\n[ERROR] in %s : undefined file descriptor %d\n",
    77 __FUNCTION__ , fdid );
     77if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start )
     78printk("\n[ERROR] in %s : thread[%x,%x] / undefined file descriptor %d\n",
     79__FUNCTION__ , process->pid , this->trdid , fdid );
    7880#endif
    7981        this->errno = EBADFD;
     
    8688    file_type = hal_remote_l32( XPTR( file_cxy , &file_ptr->type ) );
    8789
    88     if( file_type == INODE_TYPE_DIR )
     90    if( file_type == FILE_TYPE_DIR )
    8991        {
    9092
    9193#if DEBUG_SYSCALLS_ERROR
    92 printk("\n[ERROR] in %s : file descriptor %d is a directory\n",
    93 __FUNCTION__ , fdid );
     94if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start )
     95printk("\n[ERROR] in %s : thread[%x,%x] / file descriptor %d is a directory\n",
     96__FUNCTION__ , process->pid , this->trdid , fdid );
    9497#endif
    9598                this->errno = EBADFD;
    9699                return -1;
    97100        }
    98     else if( file_type == INODE_TYPE_SOCK )
     101    else if( file_type == FILE_TYPE_SOCK )
    99102    {
    100103        // call the relevant socket function
    101104        error = socket_close( file_xp , fdid );
    102105    }
    103     else if( file_type == INODE_TYPE_FILE )
     106    else if( (file_type == FILE_TYPE_REG) ||
     107             (file_type == FILE_TYPE_FIFO) )
    104108    {
    105109        // call the relevant VFS function
     
    110114           
    111115#if DEBUG_SYSCALLS_ERROR
    112 printk("\n[WARNING] in %s : type (%d) not supported  / fdid %d\n",
    113 __FUNCTION__ , file_type , fdid );
     116if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start )
     117printk("\n[WARNING] in %s : thread[%x,%x] / file_type (%s) unsupported / fdid %d\n",
     118__FUNCTION__ , process->pid , this->trdid , vfs_inode_type_str(file_type) , fdid );
    114119#endif
    115120        error = 0;       
     
    120125
    121126#if DEBUG_SYSCALLS_ERROR
    122 printk("\n[ERROR] in %s : cannot close file descriptor %d\n",
    123 __FUNCTION__ , fdid );
     127if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start )
     128printk("\n[ERROR] in %s : thread[%x,%x] cannot close file descriptor %d\n",
     129__FUNCTION__ , process->pid , this->trdid , fdid );
    124130#endif
    125131                this->errno = error;
Note: See TracChangeset for help on using the changeset viewer.