Ignore:
Timestamp:
Jan 9, 2019, 3:02:51 PM (3 years ago)
Author:
alain
Message:

Introduce sigificant modifs in VFS to support the <ls> command,
and the . and .. directories entries.

File:
1 edited

Legend:

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

    r473 r611  
    11/*
    2  * sys_closedir.c - Close an open directory.
     2 * sys_closedir.c - Close an open VFS directory.
    33 *
    4  * Author    Alain Greiner  (2016, 2017)
     4 * Author    Alain Greiner  (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    2222 */
    2323
     24#include <kernel_config.h>
    2425#include <hal_kernel_types.h>
    2526#include <vfs.h>
     
    2728#include <thread.h>
    2829#include <process.h>
     30#include <remote_dir.h>
    2931#include <errno.h>
    3032#include <syscalls.h>
     
    3436int sys_closedir ( DIR * dirp )
    3537{
    36     printk("\n[ERROR] in %s : not implemented yet\n", __FUNCTION__, dirp );
    37     return -1;
     38    xptr_t         dir_xp;       // extended pointer on remote_dir_t structure
     39
     40        thread_t  * this    = CURRENT_THREAD;  // client thread
     41        process_t * process = this->process;   // client process
     42
     43#if (DEBUG_SYS_CLOSEDIR || CONFIG_INSTRUMENTATION_SYSCALLS)
     44uint64_t     tm_start = hal_get_cycles();
     45#endif
     46
     47#if DEBUG_SYS_CLOSEDIR
     48if( DEBUG_SYS_CLOSEDIR < tm_start )
     49printk("\n[%s] thread[%x,%x] enter for DIR <%x> / cycle %d\n",
     50__FUNCTION__, process->pid, this->trdid, dirp, (uint32_t)tm_start );
     51#endif
     52 
     53    // get extended pointer on kernel remote_dir_t structure from dirp
     54    dir_xp  = remote_dir_from_ident( (intptr_t)dirp );
     55
     56    if( dir_xp == XPTR_NULL )
     57        {
     58
     59#if DEBUG_SYSCALLS_ERROR
     60printk("\n[ERROR] in %s / thread[%x,%x] : DIR pointer %x not registered\n",
     61__FUNCTION__ , process->pid , this->trdid, dirp );
     62#endif
     63                this->errno = EINVAL;
     64                return -1;
     65        }       
     66
     67    // delete kernel remote_dir_t structure
     68    remote_dir_destroy( dir_xp );
     69
     70    hal_fence();
     71
     72#if (DEBUG_SYS_CLOSEDIR || CONFIG_INSTRUMENTATION_SYSCALLS)
     73uint64_t     tm_end = hal_get_cycles();
     74#endif
     75
     76#if DEBUG_SYS_CLOSEDIR
     77if( DEBUG_SYS_CLOSEDIR < tm_end )
     78printk("\n[%s] thread[%x,%x] exit for DIR <%x> / cycle %d\n",
     79__FUNCTION__, process->pid, this->trdid, dirp, (uint32_t)tm_end );
     80#endif
     81 
     82#if CONFIG_INSTRUMENTATION_SYSCALLS
     83hal_atomic_add( &syscalls_cumul_cost[SYS_CLOSEDIR] , tm_end - tm_start );
     84hal_atomic_add( &syscalls_occurences[SYS_CLOSEDIR] , 1 );
     85#endif
     86
     87    return 0;
     88
    3889}  // end sys_closedir()
Note: See TracChangeset for help on using the changeset viewer.