Changeset 683 for trunk/kernel/fs


Ignore:
Timestamp:
Jan 13, 2021, 12:36:17 AM (4 years ago)
Author:
alain
Message:

All modifications required to support the <tcp_chat> application
including error recovery in case of packet loss.A

Location:
trunk/kernel/fs
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/fs/devfs.c

    r673 r683  
    5656xptr_t devfs_ctx_alloc( cxy_t cxy )
    5757{
    58     kmem_req_t    req;
    59 
    60         req.type    = KMEM_KCM;
    61         req.order   = bits_log2( sizeof(devfs_ctx_t) );
    62     req.flags   = AF_KERNEL | AF_ZERO;
    63 
    6458    // allocates devfs context from target cluster
    65         return XPTR( cxy , kmem_remote_alloc( cxy , &req ) );
     59        void * ptr = kmem_remote_alloc( cxy,
     60                                    bits_log2(sizeof(devfs_ctx_t)),
     61                                    AF_ZERO );
     62
     63    if( ptr == NULL ) return XPTR_NULL;
     64        else              return XPTR( cxy , ptr );
    6665}
    6766
     
    9089void devfs_ctx_destroy( xptr_t  devfs_ctx_xp )
    9190{
    92     kmem_req_t    req;
    93 
    9491    // get cluster and local pointer on devfs context
    9592    devfs_ctx_t * devfs_ctx_ptr = GET_PTR( devfs_ctx_xp );
    9693    cxy_t         devfs_ctx_cxy = GET_CXY( devfs_ctx_xp );
    9794
    98     req.type = KMEM_KCM;
    99     req.ptr  = devfs_ctx_ptr;
    100 
    10195    // release devfs context descriptor to remote cluster
    102     kmem_remote_free( devfs_ctx_cxy , &req );
     96    kmem_remote_free( devfs_ctx_cxy,
     97                      devfs_ctx_ptr,
     98                      bits_log2(sizeof(devfs_ctx_t)) );
    10399}
    104100
  • trunk/kernel/fs/fatfs.c

    r673 r683  
    16301630xptr_t  fatfs_ctx_alloc( cxy_t  cxy )
    16311631{
    1632     kmem_req_t    req;
    1633 
    16341632    // allocate memory from remote cluster
    1635         req.type     = KMEM_KCM;
    1636         req.order    = bits_log2( sizeof(fatfs_ctx_t) );
    1637     req.flags    = AF_KERNEL | AF_ZERO;
    1638  
    1639     return XPTR( cxy , kmem_remote_alloc( cxy , &req ) );
     1633    void * ptr = kmem_remote_alloc( cxy,
     1634                                    bits_log2(sizeof(fatfs_ctx_t)),
     1635                                    AF_ZERO );
     1636
     1637    if( ptr == NULL ) return XPTR_NULL;
     1638    else              return XPTR( cxy , ptr );
    16401639
    16411640}  //end faffs_ctx_alloc()
     
    16451644{
    16461645    error_t       error;
    1647     kmem_req_t    req;
    16481646    cxy_t         cxy;             // FATFS context cluster identifier
    16491647    fatfs_ctx_t * fatfs_ctx_ptr;   // local pointer on FATFS context
     
    16671665    // allocate a 512 bytes buffer in remote cluster, used to store
    16681666    // temporarily the BOOT sector, and permanently the FS_INFO sector
    1669         req.type    = KMEM_KCM;
    1670     req.order   = 9;                    // 512 bytes
    1671     req.flags   = AF_KERNEL | AF_ZERO;
    1672         buffer      = kmem_remote_alloc( cxy , &req );
    1673 
     1667        buffer = kmem_remote_alloc( cxy,
     1668                                9,
     1669                                AF_ZERO );
    16741670    if( buffer == NULL )
    16751671    {
     
    18271823void fatfs_ctx_destroy( xptr_t  fatfs_ctx_xp )
    18281824{
    1829     kmem_req_t   req;
    18301825    mapper_t   * fat_mapper;
    18311826    uint8_t    * fs_info_buffer;
     
    18441839    fs_info_buffer = hal_remote_lpt( XPTR( fatfs_ctx_cxy , &fatfs_ctx_ptr->fs_info_buffer ) );
    18451840
    1846     // release FS_INFO buffer
    1847     req.type = KMEM_KCM;
    1848     req.ptr  = fs_info_buffer;
    1849     kmem_remote_free( fatfs_ctx_cxy , &req );
     1841    // release FS_INFO buffer (512 bytes)
     1842    kmem_remote_free( fatfs_ctx_cxy,
     1843                      fs_info_buffer,
     1844                      9 );               
    18501845
    18511846    // release FATFS context descriptor
    1852     req.type = KMEM_KCM;
    1853     req.ptr  = fatfs_ctx_ptr;
    1854     kmem_remote_free( fatfs_ctx_cxy , &req );
     1847    kmem_remote_free( fatfs_ctx_cxy,
     1848                      fatfs_ctx_ptr,
     1849                      bits_log2(sizeof(fatfs_ctx_t)) );
    18551850
    18561851}  // end fatfs_ctx_destroy()
     
    28572852
    28582853    // compute number of pages
    2859     npages = size >> CONFIG_PPM_PAGE_SHIFT;
     2854    npages = size >> CONFIG_PPM_PAGE_ORDER;
    28602855    if( size & CONFIG_PPM_PAGE_MASK ) npages++;
    28612856         
  • trunk/kernel/fs/vfs.c

    r673 r683  
    4848
    4949//////////////////////////////////////////////////////////////////////////////////////////
    50 //           Extern variables         
     50//           Extern global variables         
    5151//////////////////////////////////////////////////////////////////////////////////////////
    5252
     
    5454extern chdev_directory_t  chdev_dir;                  // allocated in kernel_init.c 
    5555extern char *             lock_type_str[];            // allocated in kernel_init.c
     56extern process_t          process_zero;               // allocated in kernel_init.c
    5657 
    5758///////////////////////////////////////////////////////////////////////////////////////////
     
    186187    uint32_t           inum;         // inode identifier (to be allocated)
    187188    vfs_ctx_t        * ctx;          // file system context
    188         kmem_req_t         req;          // request to kernel memory allocator
    189189    error_t            error;
    190190
     
    192192uint32_t       cycle      = (uint32_t)hal_get_cycles();
    193193thread_t *     this       = CURRENT_THREAD;
     194pid_t          pid        = this->process->pid;
     195trdid_t        trdid      = this->trdid;
    194196#endif
    195197
     
    202204
    203205#if DEBUG_VFS_ERROR
    204 if( DEBUG_VFS_ERROR < cycle )
    205 printk("\n[ERROR] in %s : thread[%x,%x] / illegal FS type\n",
    206 __FUNCTION__ , this->process->pid , this->trdid );
     206printk("\n[ERROR] in %s : thread[%x,%x] / illegal FS type / cycle %d\n",
     207__FUNCTION__ , pid , trdid, cycle );
    207208#endif
    208209        return -1;
     
    220221
    221222#if DEBUG_VFS_ERROR
    222 if( DEBUG_VFS_ERROR < cycle )
    223 printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate inum\n",
    224 __FUNCTION__ , this->process->pid , this->trdid );
     223printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate inum / cycle %d\n",
     224__FUNCTION__ , pid , trdid, cycle );
    225225#endif
    226226        return -1;
     
    234234
    235235#if DEBUG_VFS_ERROR
    236 if( DEBUG_VFS_ERROR < cycle )
    237 printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate mapper\n",
    238 __FUNCTION__ , this->process->pid , this->trdid );
     236printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate mapper / cycle %d\n",
     237__FUNCTION__ , pid , trdid, cycle );
    239238#endif
    240239        vfs_ctx_inum_release( XPTR( cxy , ctx ) , inum );
     
    244243    mapper_ptr = GET_PTR( mapper_xp );
    245244
    246     // allocate one page for VFS inode descriptor
    247     // because the embedded "children" xhtab footprint
    248         req.type   = KMEM_PPM;
    249         req.order  = 0;
    250     req.flags  = AF_KERNEL | AF_ZERO;
    251         inode_ptr  = kmem_remote_alloc( cxy , &req );
    252 
     245    // allocate memory for inode descriptor
     246        inode_ptr  = kmem_remote_alloc( cxy,
     247                                    bits_log2(sizeof(vfs_inode_t)),
     248                                    AF_ZERO );
    253249    if( inode_ptr == NULL )
    254250    {
    255251
    256252#if DEBUG_VFS_ERROR
    257 if( DEBUG_VFS_ERROR < cycle )
    258 printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate inode\n",
    259 __FUNCTION__ , this->process->pid , this->trdidi );
     253printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate inode / cycle %d\n",
     254__FUNCTION__ , pid , trdid, cycle );
    260255#endif
    261256        vfs_ctx_inum_release( XPTR( cxy , ctx ) , inum );
     
    297292if( DEBUG_VFS_INODE_CREATE < cycle )
    298293printk("\n[%s] thread[%x,%x] created inode (%x,%x) / ctx %x / fs_type %d / cycle %d\n",
    299 __FUNCTION__, this->process->pid, this->trdid, cxy, inode_ptr, ctx, ctx->type, cycle );
     294__FUNCTION__, pid, trdid, cxy, inode_ptr, ctx, ctx->type, cycle );
    300295#endif
    301296 
     
    318313
    319314    // release memory allocated for inode descriptor
    320         kmem_req_t req;
    321         req.type  = KMEM_PPM;
    322         req.ptr   = inode_ptr;
    323         kmem_remote_free( inode_cxy , &req );
     315        kmem_remote_free( inode_cxy,
     316                      inode_ptr,
     317                      bits_log2(sizeof(vfs_inode_t)) );
    324318
    325319}  // end vfs_inode_destroy()
     
    447441    uint32_t   size   = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->size ) );
    448442
    449 #if DEBUG_VFS_INODE_LOAD_ALL
    450 char       name[CONFIG_VFS_MAX_NAME_LENGTH];
     443#if DEBUG_VFS_INODE_LOAD_ALL || DEBUG_VFS_ERROR
    451444uint32_t   cycle = (uint32_t)hal_get_cycles();
    452445thread_t * this  = CURRENT_THREAD;
     446#endif
     447
     448#if DEBUG_VFS_INODE_LOAD_ALL
     449char name[CONFIG_VFS_MAX_NAME_LENGTH];
    453450vfs_inode_get_name( inode_xp , name );
    454451if( DEBUG_VFS_INODE_LOAD_ALL < cycle )
     
    458455
    459456    // compute number of pages
    460     uint32_t npages = size >> CONFIG_PPM_PAGE_SHIFT;
     457    uint32_t npages = size >> CONFIG_PPM_PAGE_ORDER;
    461458    if( (size & CONFIG_PPM_PAGE_MASK) || (size == 0) ) npages++;
    462459
     
    468465        page_xp = mapper_get_page( XPTR( inode_cxy , mapper ), page_id );
    469466
    470         if( page_xp == XPTR_NULL ) return -1;
     467        if( page_xp == XPTR_NULL )
     468        {
     469
     470#if DEBUG_VFS_ERROR
     471printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate memory for mapper / cycle %d\n",
     472__FUNCTION__, this->process->pid, this->trdid, cycle );
     473#endif
     474            return -1;
     475        }
    471476    }
    472477
     
    534539                           xptr_t        * dentry_xp )
    535540{
    536         kmem_req_t       req;            // request to kernel memory allocator
    537541    vfs_ctx_t      * ctx = NULL;     // context descriptor
    538542    vfs_dentry_t   * dentry_ptr;     // dentry descriptor (to be allocated)
     
    557561
    558562#if DEBUG_VFS_ERROR
    559 if( DEBUG_VFS_ERROR < cycle )
    560 printk("\n[ERROR] in %s : thread[%x,%x] / undefined fs_type %d\n",
    561 __FUNCTION__ , this->process->pid, this->trdid, fs_type );
     563printk("\n[ERROR] in %s : thread[%x,%x] / undefined fs_type %d / cycle %d\n",
     564__FUNCTION__ , this->process->pid, this->trdid, fs_type, cycle );
    562565#endif
    563566        return -1;
     
    570573
    571574    // allocate memory for dentry descriptor
    572         req.type   = KMEM_KCM;
    573         req.order  = bits_log2( sizeof(vfs_dentry_t) );
    574     req.flags  = AF_KERNEL | AF_ZERO;
    575         dentry_ptr = kmem_remote_alloc( cxy , &req );
    576 
     575        dentry_ptr = kmem_remote_alloc( cxy,
     576                                    bits_log2(sizeof(vfs_dentry_t)),
     577                                    AF_ZERO );
    577578    if( dentry_ptr == NULL )
    578579    {
    579580
    580581#if DEBUG_VFS_ERROR
    581 if( DEBUG_VFS_ERROR < cycle )
    582 printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate dentry descriptor\n",
    583 __FUNCTION__ , this->process->pid, this->trdid );
     582printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate dentry descriptor / cycle %d\n",
     583__FUNCTION__ , this->process->pid, this->trdid, cycle );
    584584#endif
    585585        return -1;
     
    616616 
    617617    // release memory allocated to dentry
    618         kmem_req_t req;
    619         req.type  = KMEM_KCM;
    620         req.ptr   = dentry_ptr;
    621         kmem_remote_free( dentry_cxy , &req );
     618        kmem_remote_free( dentry_cxy,
     619                      dentry_ptr,
     620                      bits_log2(sizeof(vfs_dentry_t)) );
    622621
    623622}  // end vfs_dentry_destroy()
     
    634633{
    635634    vfs_file_t   * file_ptr;
    636         kmem_req_t     req;
    637635    uint32_t       type;
    638636    mapper_t     * mapper;
     
    644642    cxy_t         inode_cxy = GET_CXY( inode_xp );
    645643
     644#if DEBUG_VFS_FILE_CREATE || DEBUG_VFS_ERROR
     645thread_t * this  = CURRENT_THREAD;
     646uint32_t   cycle = (uint32_t)hal_get_cycles();
     647#endif
     648
    646649#if DEBUG_VFS_FILE_CREATE
    647 thread_t * this = CURRENT_THREAD;
    648 uint32_t cycle = (uint32_t)hal_get_cycles();
    649650if( DEBUG_VFS_FILE_CREATE < cycle )
    650651printk("\n[%s] thread[%x,%x] enter for inode (%x,%x) / cycle %d\n",
     
    653654
    654655    // allocate memory for new file descriptor
    655         req.type  = KMEM_KCM;
    656         req.order = bits_log2( sizeof(vfs_file_t) );
    657     req.flags = AF_KERNEL | AF_ZERO;
    658         file_ptr  = kmem_remote_alloc( inode_cxy , &req );
    659 
    660     if( file_ptr == NULL ) return -1;
     656        file_ptr  = kmem_remote_alloc( inode_cxy,
     657                                   bits_log2(sizeof(vfs_file_t)),
     658                                   AF_ZERO );
     659
     660    if( file_ptr == NULL )
     661    {
     662
     663#if DEBUG_VFS_ERROR
     664printk("\n[ERROR] in %s : thread[%x,%x] / cannot allocate memory / cycle %d\n",
     665__FUNCTION__ , this->process->pid, this->trdid, cycle );
     666#endif
     667        return -1;
     668    }
    661669
    662670    // get type, ctx, mapper, and buffer from inode descriptor
     
    718726
    719727    // release file descriptor
    720         kmem_req_t req;
    721         req.type  = KMEM_KCM;
    722         req.ptr   = file_ptr;
    723         kmem_remote_free( file_cxy , &req );
     728        kmem_remote_free( file_cxy,
     729                      file_ptr,
     730                      bits_log2(sizeof(vfs_file_t)) );
    724731
    725732#if DEBUG_VFS_FILE_DESTROY
     
    775782    xptr_t         lock_xp;        // extended pointer on Inode Tree lock
    776783
     784#if DEBUG_VFS_OPEN || DEBUG_VFS_ERROR
     785uint32_t    cycle   = (uint32_t)hal_get_cycles();
     786thread_t  * this    = CURRENT_THREAD;
     787pid_t       pid     = this->process->pid;
     788trdid_t     trdid   = this->trdid;
     789#endif
     790
    777791    if( mode != 0 )
    778792    {
    779         printk("\n[ERROR] in %s : the mode parameter is not supported yet\n" );
     793
     794#if DEBUG_VFS_ERROR
     795printk("\n[ERROR] in %s : the mode parameter is not supported yet\n" );
     796#endif
    780797        return -1;
    781798    }
    782 
    783     thread_t  * this    = CURRENT_THREAD;
    784     process_t * process = this->process;
    785799
    786800    // compute lookup working mode
     
    790804    if( (flags & O_EXCL   )      )  lookup_mode |= VFS_LOOKUP_EXCL;
    791805 
    792 #if DEBUG_VFS_OPEN || DEBUG_VFS_ERROR
    793 uint32_t cycle = (uint32_t)hal_get_cycles();
    794 #endif
    795 
    796806#if DEBUG_VFS_OPEN
    797807if( DEBUG_VFS_OPEN < cycle )
    798808printk("\n[%s] thread[%x,%x] enter for <%s> / root_inode (%x,%x) / cycle %d\n",
    799 __FUNCTION__, process->pid, this->trdid, path, GET_CXY(root_xp), GET_PTR(root_xp), cycle );
     809__FUNCTION__, pid, trdid, path, GET_CXY(root_xp), GET_PTR(root_xp), cycle );
    800810#endif
    801811
     
    809819
    810820    // build extended pointer on lock protecting Inode Tree
    811     vfs_root_xp  = process->vfs_root_xp;
     821    vfs_root_xp  = process_zero.vfs_root_xp;
    812822    vfs_root_ptr = GET_PTR( vfs_root_xp );
    813823    vfs_root_cxy = GET_CXY( vfs_root_xp );
     
    831841
    832842#if DEBUG_VFS_ERROR
    833 if( DEBUG_VFS_ERROR < cycle )
    834 printk("\n[ERROR] in %s : thread[%x,%x] cannot get inode <%s>\n",
    835 __FUNCTION__ , process->pid, this->trdid , path );
     843printk("\n[ERROR] in %s : thread[%x,%x] cannot get inode <%s> / cycle %d\n",
     844__FUNCTION__ , pid, trdid , path , cycle );
    836845#endif
    837846        return -1;
     
    843852   
    844853#if (DEBUG_VFS_OPEN & 1)
    845 cycle = (uint32_t)hal_get_cycles();
    846854if( DEBUG_VFS_OPEN < cycle )
    847855printk("\n[%s] thread[%x,%x] found inode(%x,%x) for <%s>\n",
    848 __FUNCTION__, process->pid, this->trdid, inode_cxy, inode_ptr, path );
     856__FUNCTION__, pid, trdid, inode_cxy, inode_ptr, path );
    849857#endif
    850858
     
    852860    error = vfs_file_create( inode_xp , file_attr , &file_xp );
    853861
    854     if( error )  return error;
     862    if( error )
     863    {
     864
     865#if DEBUG_VFS_ERROR
     866printk("\n[ERROR] in %s : thread[%x,%x] cannot create file descriptor for <%s> / cycle %d\n",
     867__FUNCTION__ , pid, trdid , path , cycle );
     868#endif
     869        return error;
     870    }
    855871
    856872#if (DEBUG_VFS_OPEN & 1)
    857 cycle = (uint32_t)hal_get_cycles();
    858873if( DEBUG_VFS_OPEN < cycle )
    859874printk("\n[%s] thread[%x,%x] created file descriptor (%x,%x) for <%s>\n",
    860 __FUNCTION__, process->pid, this->trdid, GET_CXY(file_xp), GET_PTR(file_xp), path );
     875__FUNCTION__, pid, trdid, GET_CXY(file_xp), GET_PTR(file_xp), path );
    861876#endif
    862877
     
    864879    error = process_fd_register( process_xp , file_xp , &file_id );
    865880
    866     if( error ) return error;
     881    if( error )
     882    {
     883
     884#if DEBUG_VFS_ERROR
     885printk("\n[ERROR] in %s : thread[%x,%x] cannot register file descriptor for <%s> / cycle %d\n",
     886__FUNCTION__ , pid, trdid , path , cycle );
     887#endif
     888        return error;
     889    }
    867890
    868891    // get new file descriptor cluster and local pointer
     
    891914if( DEBUG_VFS_OPEN < cycle )
    892915printk("\n[%s] thread[%x,%x] exit for <%s> / fdid %d / file(%x,%x) / cycle %d\n",
    893 __FUNCTION__, process->pid, this->trdid, path, file_id,
     916__FUNCTION__, pid, trdid, path, file_id,
    894917GET_CXY( file_xp ), GET_PTR( file_xp ), cycle );
    895918#endif
     
    9971020
    9981021#if DEBUG_VFS_ERROR
    999 if( DEBUG_VFS_ERROR < cycle )
    1000 printk("\n[ERROR] in %s thread[%x,%x] cannot move data",
    1001 __FUNCTION__, this->process->pid, this->trdid );
     1022printk("\n[ERROR] in %s thread[%x,%x] cannot move data / cycle %d",
     1023__FUNCTION__, this->process->pid, this->trdid, cycle );
    10021024#endif
    10031025        return -1;
     
    10081030
    10091031#if DEBUG_VFS_USER_MOVE
    1010 cycle = (uint32_t)hal_get_cycles();
    10111032if( cycle > DEBUG_VFS_USER_MOVE )
    10121033{
     
    10321053    cxy_t              file_cxy;     // remote file descriptor cluster
    10331054    vfs_file_t       * file_ptr;     // remote file descriptor local pointer
    1034     vfs_file_type_t   inode_type;   // remote file type
    10351055    uint32_t           file_offset;  // current offset in file
    10361056    mapper_t         * mapper_ptr;   // remote mapper local pointer
     
    10411061assert( __FUNCTION__, (file_xp != XPTR_NULL) , "file_xp == XPTR_NULL" );
    10421062
     1063#if DEBUG_VFS_KERNEL_MOVE || DEBUG_VFS_ERROR
     1064uint32_t      cycle      = (uint32_t)hal_get_cycles();
     1065thread_t    * this       = CURRENT_THREAD;
     1066#endif
     1067
    10431068    // get cluster and local pointer on remote file descriptor
    10441069    file_cxy  = GET_CXY( file_xp );
    10451070    file_ptr  = GET_PTR( file_xp );
    1046 
    1047     // get inode type from remote file descriptor
    1048     inode_type = hal_remote_l32( XPTR( file_cxy , &file_ptr->type   ) );
    1049 
    1050 // check inode type
    1051 assert( __FUNCTION__, (inode_type == FILE_TYPE_REG), "bad file type" );
    10521071
    10531072    // get mapper pointers and file offset from file descriptor
     
    10641083    if( error )
    10651084    {
    1066         printk("\n[ERROR] in %s : cannot move data", __FUNCTION__ );
     1085
     1086#if DEBUG_VFS_ERROR
     1087printk("\n[ERROR] in %s : thread[%x,%x] / cannot move data / cycle %d\n",
     1088__FUNCTION__ , this->process->pid , this->trdid , cycle );
     1089#endif
    10671090        return -1;
     1091
    10681092    }
    10691093
    10701094#if DEBUG_VFS_KERNEL_MOVE
    10711095char          name[CONFIG_VFS_MAX_NAME_LENGTH];
    1072 uint32_t      cycle      = (uint32_t)hal_get_cycles();
    1073 thread_t    * this       = CURRENT_THREAD;
    10741096cxy_t         buffer_cxy = GET_CXY( buffer_xp );
    10751097void        * buffer_ptr = GET_PTR( buffer_xp );
     
    11091131assert( __FUNCTION__, (new_offset != NULL )  , "new_offset == NULL" );
    11101132
     1133#if DEBUG_VFS_LSEEK || DEBUG_VFS_ERROR
     1134uint32_t   cycle = (uint32_t)hal_get_cycles();
     1135thread_t * this  = CURRENT_THREAD;
     1136#endif
     1137
    11111138    // get cluster and local pointer on remote file descriptor
    11121139    file_cxy = GET_CXY( file_xp );
     
    11381165    else
    11391166    {
    1140         printk("\n[ERROR] in %s : illegal whence value\n", __FUNCTION__ );
     1167
     1168#if DEBUG_VFS_ERROR
     1169printk("\n[ERROR] in %s : thread[%x,%x] / undefined whence value / cycle %d",
     1170__FUNCTION__ , this->process->pid , this->trdid , cycle );
     1171#endif
    11411172        remote_rwlock_wr_release( lock_xp );
    11421173        return -1;
     
    11911222    cluster_t * cluster = LOCAL_CLUSTER;
    11921223
     1224#if DEBUG_VFS_CLOSE || DEBUG_VFS_ERROR
     1225uint32_t  cycle = (uint32_t)hal_get_cycles();
     1226#endif
     1227
    11931228    // get file name
    11941229    vfs_file_get_name( file_xp , name );
    11951230   
    11961231#if DEBUG_VFS_CLOSE
    1197 uint32_t cycle = (uint32_t)hal_get_cycles();
    11981232if( DEBUG_VFS_CLOSE < cycle )
    11991233printk("\n[%s] thread[%x,%x] enter for <%s> / cycle %d\n",
     
    12151249    if( error )
    12161250    {
    1217         printk("\n[ERROR] in %s : cannot synchronise dirty pages for <%s>\n",
    1218         __FUNCTION__, name );
     1251
     1252#if DEBUG_VFS_ERROR
     1253printk("\n[ERROR] in %s : thread[%x,%x] / cannot synchronise dirty pages for <%s> / cycle %d\n",
     1254__FUNCTION__ , this->process->pid , this->trdid , name , cycle );
     1255#endif
    12191256        return -1;
    12201257    }
     
    12221259#if DEBUG_VFS_CLOSE
    12231260if( DEBUG_VFS_CLOSE < cycle )
    1224 printk("\n[%s] thread[%x,%x] synchronised mapper of <%s> to device\n",
     1261printk("\n[%s] thread[%x,%x] synchronised <%s> mapper to device\n",
    12251262__FUNCTION__, process->pid, this->trdid, name );
    12261263#endif
     
    12591296        if( error )
    12601297        {
    1261             printk("\n[ERROR] in %s : cannot update size in parent\n",
    1262             __FUNCTION__ );
     1298
     1299#if DEBUG_VFS_ERROR
     1300printk("\n[ERROR] in %s : thread[%x,%x] / cannot update size in parent / cycle %d\n",
     1301__FUNCTION__ , this->process->pid , this->trdid , cycle );
     1302#endif
    12631303            return -1;
    12641304        }
     
    12771317        if( error )
    12781318        {
    1279             printk("\n[ERROR] in %s : cannot synchronise parent mapper to device\n",
    1280             __FUNCTION__ );
     1319
     1320#if DEBUG_VFS_ERROR
     1321printk("\n[ERROR] in %s : thread[%x,%x] / cannot synchronise  mapper & device / cycle %d\n",
     1322__FUNCTION__ , this->process->pid , this->trdid , cycle );
     1323#endif
    12811324            return -1;
    12821325        }
     
    13671410    char           last_name[CONFIG_VFS_MAX_NAME_LENGTH];
    13681411
     1412#if DEBUG_VFS_MKDIR || DEBUG_VFS_ERROR
     1413uint32_t  cycle = (uint32_t)hal_get_cycles();
     1414#endif
     1415
    13691416    thread_t  * this    = CURRENT_THREAD;
    13701417    process_t * process = this->process;
     
    13731420char root_name[CONFIG_VFS_MAX_NAME_LENGTH];
    13741421vfs_inode_get_name( root_xp , root_name );
    1375 uint32_t   cycle = (uint32_t)hal_get_cycles();
    13761422if( DEBUG_VFS_MKDIR < cycle )
    13771423printk("\n[%s] thread[%x,%x] enter / root <%s> / path <%s> / cycle %d\n",
     
    13961442    if( error )
    13971443    {
     1444
     1445#if DEBUG_VFS_ERROR
     1446printk("\n[ERROR] in %s : thread[%x,%x] cannot get parent inode for <%s> / cycle %d\n",
     1447__FUNCTION__, process->pid, this->trdid, path , cycle );
     1448#endif
    13981449        remote_rwlock_wr_release( lock_xp );
    1399         printk("\n[ERROR] in %s : cannot get parent inode for <%s>\n",
    1400         __FUNCTION__, path );
    14011450        return -1;
    14021451    }
     
    14231472    if( error )
    14241473    {
     1474
     1475#if DEBUG_VFS_ERROR
     1476printk("\n[ERROR] in %s : thread[%x,%x] cannot create dentry in cluster %x for <%s> / cycle %d\n",
     1477__FUNCTION__, process->pid, this->trdid, parent_cxy, path , cycle );
     1478#endif
    14251479        remote_rwlock_wr_release( lock_xp );
    1426         printk("\n[ERROR] in %s : cannot create new dentry in cluster %x for <%s>\n",
    1427         __FUNCTION__, parent_cxy, path );
    14281480        return -1;
    14291481    }
     
    14571509    if( error )
    14581510    {
     1511
     1512#if DEBUG_VFS_ERROR
     1513printk("\n[ERROR] in %s : thread[%x,%x] cannot create inode in cluster %x for <%s> / cycle %d\n",
     1514__FUNCTION__, process->pid, this->trdid, parent_cxy, path , cycle );
     1515#endif
    14591516        remote_rwlock_wr_release( lock_xp );
    1460         printk("\n[ERROR] in %s : cannot create new inode in cluster %x for <%s>\n",
    1461          __FUNCTION__ , inode_cxy , path );
    14621517        vfs_dentry_destroy( dentry_xp );
    14631518        return -1;
     
    15041559    if( error )
    15051560    {
     1561
     1562#if DEBUG_VFS_ERROR
     1563printk("\n[ERROR] in %s : thread[%x,%x] cannot create <.> & <..> dentries for <%s> / cycle %d\n",
     1564__FUNCTION__, process->pid, this->trdid, path , cycle );
     1565#endif
     1566        vfs_remove_child_from_parent( dentry_xp );
    15061567        remote_rwlock_wr_release( lock_xp );
    1507         printk("\n[ERROR] in %s : cannot create new inode in cluster %x for <%s>\n",
    1508         __FUNCTION__ , inode_cxy , path );
    1509         vfs_dentry_destroy( dentry_xp );
    15101568        return -1;
    15111569    }
     
    15201578    if( error )
    15211579    {
    1522         printk("\n[ERROR] in %s : cannot update parent directory for <%s>\n",
    1523         __FUNCTION__, path );
     1580
     1581#if DEBUG_VFS_ERROR
     1582printk("\n[ERROR] in %s : thread[%x,%x] cannot update parent directory for <%s> / cycle %d\n",
     1583__FUNCTION__, process->pid, this->trdid, path , cycle );
     1584#endif
     1585        vfs_remove_child_from_parent( dentry_xp );
    15241586        return -1;
    15251587    }
     
    15271589#if(DEBUG_VFS_MKDIR & 1)
    15281590if( DEBUG_VFS_MKDIR < cycle )
    1529 printk("\n[%s] thread[%x,%x] updated parent dir (mapper and IOC) for <%s>\n",
     1591printk("\n[%s] thread[%x,%x] created <%s> dir (Inode-Tree, Mapper and IOC)\n",
    15301592__FUNCTION__, process->pid, this->trdid, path );
    15311593#endif
     
    15651627    char           new_name[CONFIG_VFS_MAX_NAME_LENGTH];
    15661628
     1629#if DEBUG_VFS_LINK || DEBUG_VFS_ERROR
     1630uint32_t  cycle = (uint32_t)hal_get_cycles();
     1631#endif
     1632
    15671633    thread_t  * this    = CURRENT_THREAD;
    15681634    process_t * process = this->process;
     
    15731639vfs_inode_get_name( old_root_xp , old_root_name );
    15741640vfs_inode_get_name( new_root_xp , new_root_name );
    1575 uint32_t   cycle = (uint32_t)hal_get_cycles();
    15761641if( DEBUG_VFS_LINK < cycle )
    15771642printk("\n[%s] thread[%x,%x] enter / old_root <%s> / old_path <%s> / "
     
    15981663    if( error )
    15991664    {
     1665
     1666#if DEBUG_VFS_ERROR
     1667printk("\n[ERROR] in %s : thread[%x,%x] cannot get target inode for <%s> / cycle %d\n",
     1668__FUNCTION__, process->pid, this->trdid, old_path , cycle );
     1669#endif
    16001670        remote_rwlock_wr_release( lock_xp );
    1601         printk("\n[ERROR] in %s : cannot get target inode for <%s>\n",
    1602         __FUNCTION__, old_path );
    16031671        return -1;
    16041672    }
     
    16191687    if( error )
    16201688    {
     1689
     1690#if DEBUG_VFS_ERROR
     1691printk("\n[ERROR] in %s : thread[%x,%x] cannot get parent inode for <%s> / cycle %d\n",
     1692__FUNCTION__, process->pid, this->trdid, new_path , cycle );
     1693#endif
    16211694        remote_rwlock_wr_release( lock_xp );
    1622         printk("\n[ERROR] in %s : cannot get parent inode for <%s>\n",
    1623         __FUNCTION__, new_path );
    16241695        return -1;
    16251696    }
     
    16551726        if( error )
    16561727        {
     1728
     1729#if DEBUG_VFS_ERROR
     1730printk("\n[ERROR] in %s : thread[%x,%x] cannot create new dentry for <%s> / cycle %d\n",
     1731__FUNCTION__, process->pid, this->trdid, new_path , cycle );
     1732#endif
    16571733            remote_rwlock_wr_release( lock_xp );
    1658             printk("\n[ERROR] in %s : cannot create new dentry for <%s>\n",
    1659             __FUNCTION__, new_path );
    16601734            return -1;
    16611735        }
     
    16961770        if( error )
    16971771        {
    1698             printk("\n[ERROR] in %s : cannot update new parent directory for <%s>\n",
    1699             __FUNCTION__, new_path );
     1772
     1773#if DEBUG_VFS_ERROR
     1774printk("\n[ERROR] in %s : thread[%x,%x] cannot update parent directory for <%s> / cycle %d\n",
     1775__FUNCTION__, process->pid, this->trdid, new_path , cycle );
     1776#endif
    17001777            return -1;
    17011778        }
     
    17101787    else
    17111788    {
    1712         // release the lock protecting Inode Tree
     1789
     1790#if DEBUG_VFS_ERROR
     1791printk("\n[ERROR] in %s : thread[%x,%x] / unsupported inode type %s / cycle %d\n",
     1792__FUNCTION__, process->pid, this->trdid, vfs_inode_type_str( inode_type ), cycle );
     1793#endif
    17131794        remote_rwlock_wr_release( lock_xp );
    1714 
    1715         printk("\n[ERROR] in %s : unsupported inode type %s\n",
    1716         __FUNCTION__ , vfs_inode_type_str( inode_type ) );
    17171795        return -1;
    17181796    }
     
    17461824    char              parent_name[CONFIG_VFS_MAX_NAME_LENGTH];  // name of parent directory
    17471825
     1826#if DEBUG_VFS_UNLINK || DEBUG_VFS_ERROR
     1827uint32_t  cycle = (uint32_t)hal_get_cycles();
     1828#endif
     1829
    17481830    thread_t  * this    = CURRENT_THREAD;
    17491831    process_t * process = this->process;
    17501832
    17511833#if DEBUG_VFS_UNLINK
    1752 uint32_t   cycle = (uint32_t)hal_get_cycles();
    17531834char root_name[CONFIG_VFS_MAX_NAME_LENGTH];
    17541835vfs_inode_get_name( root_xp , root_name );
     
    17751856    if( error )
    17761857    {
     1858
     1859#if DEBUG_VFS_ERROR
     1860printk("\n[ERROR] in %s : thread[%x,%x] cannot get parent inode for <%s> / cycle %d\n",
     1861__FUNCTION__, process->pid, this->trdid, path , cycle );
     1862#endif
    17771863        remote_rwlock_wr_release( lock_xp );
    1778         printk("\n[ERROR] in %s : cannot get parent inode for <%s> in <%s>\n",
    1779         __FUNCTION__, child_name, path );
    17801864        return -1;
    17811865    }
     
    18241908        if( error )
    18251909        {
    1826             printk("\n[ERROR] in %s : cannot create inode <%s> in Inode Tree\n",
    1827             __FUNCTION__ , child_name );
     1910
     1911#if DEBUG_VFS_ERROR
     1912printk("\n[ERROR] in %s : thread[%x,%x] cannot create node <%s> in Inode_Tree / cycle %d\n",
     1913__FUNCTION__, process->pid, this->trdid, path, cycle );
     1914#endif
     1915            remote_rwlock_wr_release( lock_xp );
    18281916            return -1;
    18291917        }
     
    18391927        if ( error )
    18401928        {
    1841             printk("\n[ERROR] in %s : cannot get entry <%s> in parent <%s> mapper\n",
    1842             __FUNCTION__ , child_name, parent_name );
     1929
     1930#if DEBUG_VFS_ERROR
     1931printk("\n[ERROR] in %s : thread[%x,%x] cannot get dentry  <%s> in parent <%s> mapper / cycle %d\n",
     1932__FUNCTION__, process->pid, this->trdid, child_name, parent_name, cycle );
     1933#endif
     1934            remote_rwlock_wr_release( lock_xp );
    18431935            return -1;
    18441936        }
     
    18611953    }
    18621954
    1863     // At this point the Inode Tree contains the target dentry and child inode
     1955    // At this point the Inode-Tree contains the parent dentry and child inode
    18641956    // we can safely remove this dentry from both the parent mapper, and the Inode Tree.
    18651957
     
    18971989            if( inode_children != 0 )
    18981990            {
     1991
     1992#if DEBUG_VFS_ERROR
     1993printk("\n[ERROR] in %s : thread[%x,%x] cannot remove <%s> inode that has children / cycle %d\n",
     1994__FUNCTION__, process->pid, this->trdid, path, cycle );
     1995#endif
    18991996                remote_rwlock_wr_release( lock_xp );
    1900                 printk("\n[ERROR] in %s : cannot remove <%s> inode that has children\n",
    1901                 __FUNCTION__, path );
    19021997                return -1;
    19031998            }
     
    19082003            if( error )
    19092004            {
     2005
     2006#if DEBUG_VFS_ERROR
     2007printk("\n[ERROR] in %s : thread[%x,%x] cannot update FAT mapper to remove <s> / cycle %d\n",
     2008__FUNCTION__, process->pid, this->trdid, path, cycle );
     2009#endif
    19102010                remote_rwlock_wr_release( lock_xp );
    1911                 printk("\n[ERROR] in %s : cannot update FAT mapper to remove <%s> inode\n",
    1912                 __FUNCTION__ , path );
    19132011                return -1;
    19142012            }
     
    19272025        if( error )
    19282026        {
     2027
     2028#if DEBUG_VFS_ERROR
     2029printk("\n[ERROR] in %s : thread[%x,%x] cannot update parent directory on IOC for <s> / cycle %d\n",
     2030__FUNCTION__, process->pid, this->trdid, path, cycle );
     2031#endif
    19292032            remote_rwlock_wr_release( lock_xp );
    1930             printk("\n[ERROR] in %s : cannot update dentry on device for <%s>\n",
    1931             __FUNCTION__ , path );
    19322033            return -1;
    19332034        }
     
    19792080    else
    19802081    {
     2082
     2083#if DEBUG_VFS_ERROR
     2084printk("\n[ERROR] in %s : thread[%x,%x] unsupported inode type %d for <s> / cycle %d\n",
     2085__FUNCTION__, process->pid, this->trdid, vfs_inode_type_str( inode_type ), path, cycle );
     2086#endif
    19812087        remote_rwlock_wr_release( lock_xp );
    1982         printk("\n[ERROR] in %s : unsupported inode type %s\n",
    1983         __FUNCTION__ , vfs_inode_type_str( inode_type ) );
    19842088        return -1;
    19852089    }
     
    20042108    process_t * process = this->process;
    20052109
     2110#if DEBUG_VFS_STAT || DEBUG_VFS_ERROR
     2111uint32_t  cycle = (uint32_t)hal_get_cycles();
     2112#endif
     2113
    20062114    // build extended pointer on lock protecting Inode Tree (in VFS root inode)
    20072115    vfs_root_xp  = process->vfs_root_xp;
     
    20252133    if( error )
    20262134    {
    2027         printk("\n[ERROR] in %s : cannot found inode <%s>\n",
    2028         __FUNCTION__ , path );
     2135
     2136#if DEBUG_VFS_ERROR
     2137printk("\n[ERROR] in %s : thread[%x,%x] cannot found inode <%s> / cycle %d\n",
     2138__FUNCTION__, process->pid, this->trdid, path, cycle );
     2139#endif
    20292140        return -1;
    20302141    }
     
    20502161
    20512162#if DEBUG_VFS_STAT
    2052 uint32_t cycle  = (uint32_t)hal_get_cycles();
    20532163if( DEBUG_VFS_STAT < cycle )
    2054 printk("\n[%s] thread[%x,%x] set stat %x for inode %x in cluster %x / cycle %d\n"
    2055        " %s / inum %d / size %d\n",
    2056 __FUNCTION__, process->pid, this->trdid, st, inode_ptr, inode_cxy, cycle,
    2057 vfs_inode_type_str( type ), inum, size );
     2164printk("\n[%s] thread[%x,%x] set stat for <%s> / %s / inum %d / size %d / cycle %d\n",
     2165__FUNCTION__, process->pid, this->trdid, path, vfs_inode_type_str( type ), inum, size, cycle );
    20582166#endif
    20592167
     
    20842192    process_t * process = this->process;
    20852193
    2086 #if DEBUG_VFS_CHDIR
    2087 uint32_t cycle = (uint32_t)hal_get_cycles();
    2088 if( DEBUG_VFS_CHDIR < cycle )
    2089 printk("\n[%s] thread[%x,%x] enter for path <%s> / cycle %d\n",
    2090 __FUNCTION__, process->pid, this->trdid, path, cycle );
     2194#if DEBUG_VFS_CHDIR || DEBUG_VFS_ERROR
     2195uint32_t  cycle = (uint32_t)hal_get_cycles();
    20912196#endif
    20922197
     
    21122217    if( error )
    21132218    {
    2114         printk("\n[ERROR] in %s : <%s> not found\n",
    2115         __FUNCTION__, path );
     2219
     2220#if DEBUG_VFS_ERROR
     2221printk("\n[ERROR] in %s : thread[%x,%x] cannot found inode <%s> / cycle %d\n",
     2222__FUNCTION__, process->pid, this->trdid, path, cycle );
     2223#endif
    21162224        return -1;
    21172225    }
     
    21242232    if( inode_type != FILE_TYPE_DIR )
    21252233    {
    2126         printk("\n[ERROR] in %s : <%s> is not a directory\n",
    2127         __FUNCTION__, path );
     2234
     2235#if DEBUG_VFS_ERROR
     2236printk("\n[ERROR] in %s : thread[%x,%x] / <%s> is not a directory / cycle %d\n",
     2237__FUNCTION__, process->pid, this->trdid, path, cycle );
     2238#endif
    21282239        return -1;
    21292240    }
     
    21462257
    21472258#if DEBUG_VFS_CHDIR
    2148 cycle = (uint32_t)hal_get_cycles();
    21492259if( DEBUG_VFS_CHDIR < cycle )
    2150 printk("\n[%s] thread[%x,%x] exit : inode (%x,%x) / &cwd_xp (%x,%x) / cycle %d\n",
    2151 __FUNCTION__, process->pid, this->trdid, inode_cxy, inode_ptr,
    2152 GET_CXY(cwd_xp_xp), GET_PTR(cwd_xp_xp), cycle );
     2260printk("\n[%s] thread[%x,%x] set new cwd <%s> / inode_xp (%x,%x) / cycle %d\n",
     2261__FUNCTION__, process->pid, this->trdid, path, inode_cxy, inode_ptr, cycle );
    21532262#endif
    21542263
     
    21632272{
    21642273    error_t           error;
    2165     xptr_t            inode_xp;     // extended pointer on target inode
    2166     cxy_t             inode_cxy;    // inode cluster identifier       
    2167     vfs_inode_t     * inode_ptr;    // inode local pointer
    2168 
    2169 // check lookup working mode
    2170 assert( __FUNCTION__, (rights == 0), "access rights non implemented yet" );
    2171  
     2274    xptr_t            vfs_root_xp;        // extended pointer on VFS root inode
     2275    vfs_inode_t     * vfs_root_ptr;       // local_pointer on VFS root inode
     2276    cxy_t             vfs_root_cxy;       // VFS root inode cluster identifier
     2277    xptr_t            main_lock_xp;       // extended pointer on lock protecting Inode Tree
     2278    xptr_t            inode_xp;           // extended pointer on target inode
     2279    cxy_t             inode_cxy;          // inode cluster identifier       
     2280    vfs_inode_t     * inode_ptr;          // inode local pointer
     2281    vfs_file_type_t   inode_type;         // inode type   
     2282
     2283    thread_t  * this    = CURRENT_THREAD;
     2284    process_t * process = this->process;
     2285
     2286#if DEBUG_VFS_CHMOD || DEBUG_VFS_ERROR
     2287uint32_t  cycle = (uint32_t)hal_get_cycles();
     2288#endif
     2289
     2290    // build extended pointer on lock protecting Inode Tree (in VFS root inode)
     2291    vfs_root_xp  = process->vfs_root_xp;
     2292    vfs_root_ptr = GET_PTR( vfs_root_xp );
     2293    vfs_root_cxy = GET_CXY( vfs_root_xp );
     2294    main_lock_xp = XPTR( vfs_root_cxy , &vfs_root_ptr->main_lock );
     2295
     2296    // take lock protecting Inode Tree in read mode
     2297    remote_rwlock_rd_acquire( main_lock_xp );
     2298
    21722299    // get extended pointer on target inode
    21732300    error = vfs_lookup( cwd_xp,
     
    21772304                        NULL );
    21782305
    2179     if( error ) return error;
     2306    // release lock protecting Inode Tree in read mode
     2307    remote_rwlock_rd_release( main_lock_xp );
     2308
     2309    if( error )
     2310    {
     2311
     2312#if DEBUG_VFS_ERROR
     2313printk("\n[ERROR] in %s : thread[%x,%x] cannot found inode <%s> / cycle %d\n",
     2314__FUNCTION__, process->pid, this->trdid, path, cycle );
     2315#endif
     2316        return -1;
     2317    }
    21802318
    21812319    // get inode cluster and local pointer
     
    21842322   
    21852323    // get inode type from remote inode
    2186     // inode_type = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->type ) );
     2324    inode_type = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->type ) );
    21872325
    21882326    // TODO finalize implementation
    21892327
    2190 assert( __FUNCTION__, false , "not implemented" );
     2328assert( __FUNCTION__, false , "not fully implemented" );
    21912329
    21922330    // set inode rights in remote inode
    21932331    hal_remote_s32( XPTR( inode_cxy , &inode_ptr->rights ) , rights );
     2332
     2333#if DEBUG_VFS_CHMOD
     2334if( DEBUG_VFS_CHMOD < cycle )
     2335printk("\n[%s] thread[%x,%x] set access rights %x for <%s> / inode_xp (%x,%x) / cycle %d\n",
     2336__FUNCTION__, process->pid, this->trdid, rights, path, inode_cxy, inode_ptr, cycle );
     2337#endif
    21942338
    21952339    return 0;
     
    22122356    thread_t    * this    = CURRENT_THREAD;
    22132357    process_t   * process = this->process;
     2358
     2359#if DEBUG_VFS_MKFIFO || DEBUG_VFS_ERROR
     2360uint32_t  cycle = (uint32_t)hal_get_cycles();
     2361#endif
    22142362
    22152363    // build extended pointer on lock protecting Inode Tree
     
    22302378    if( error )
    22312379    {
    2232         printk("\n[ERROR] in %s : cannot get parent inode for <%s> path\n",
    2233         __FUNCTION__ , path );
     2380
     2381#if DEBUG_VFS_ERROR
     2382printk("\n[ERROR] in %s : thread[%x,%x] cannot found parent inode for <%s> / cycle %d\n",
     2383__FUNCTION__, process->pid, this->trdid, path, cycle );
     2384#endif
     2385        remote_rwlock_wr_release( vfs_lock_xp );
    22342386        return -1;
    22352387    }
     
    22592411    if( error )
    22602412    {
    2261         printk("\n[ERROR] in %s : cannot create fifo inode for <%s> path\n",
    2262         __FUNCTION__ , path );
     2413
     2414#if DEBUG_VFS_ERROR
     2415printk("\n[ERROR] in %s : thread[%x,%x] cannot create fifo inode for <%s> / cycle %d\n",
     2416__FUNCTION__, process->pid, this->trdid, path, cycle );
     2417#endif
     2418        remote_rwlock_wr_release( vfs_lock_xp );
    22632419        return -1;
    22642420    }
     
    22702426    if( pipe == NULL )
    22712427    {
    2272         printk("\n[ERROR] in %s : cannot create pipe for <%s> path\n",
    2273         __FUNCTION__ , path );
     2428
     2429#if DEBUG_VFS_ERROR
     2430printk("\n[ERROR] in %s : thread[%x,%x] cannot create pipe for <%s> / cycle %d\n",
     2431__FUNCTION__, process->pid, this->trdid, path, cycle );
     2432#endif
     2433        vfs_remove_child_from_parent( fifo_dentry_xp );
     2434        remote_rwlock_wr_release( vfs_lock_xp );
    22742435        return -1;
    22752436    }
     
    22822443    // release the lock protecting the Inode-Tree from write mode
    22832444    remote_rwlock_wr_release( vfs_lock_xp );
     2445
     2446#if DEBUG_VFS_MKDIR
     2447if( DEBUG_VFS_MKDIR < cycle )
     2448printk("\n[%s] thread[%x,%x] creared fifo <%s> / inode_xp [%x,%x] / cycle %d\n",
     2449__FUNCTION__, process->pid, this->trdid, path, fifo_cxy, fifo_inode_ptr, cycle );
     2450#endif
    22842451
    22852452    return 0;
     
    27462913
    27472914#if DEBUG_VFS_ERROR 
    2748 if( DEBUG_VFS_ERROR < cycle )
    2749 printk("\n[ERROR] in %s : thread[%x,%x] cannot create inode <%s> in path <%s>\n",
    2750 __FUNCTION__ , process->pid, this->trdid, name, pathname );
     2915printk("\n[ERROR] in %s : thread[%x,%x] cannot create inode <%s> in path <%s> / cycle %d\n",
     2916__FUNCTION__ , process->pid, this->trdid, name, pathname, cycle );
    27512917#endif
    27522918                    return -1;
     
    27772943
    27782944#if DEBUG_VFS_ERROR
    2779 if( DEBUG_VFS_ERROR < cycle )
    2780 printk("\n[ERROR] in %s : thread[%x,%x] cannot add dentry <%s> in parent dir\n",
    2781 __FUNCTION__, process->pid, this->trdid, name );
     2945printk("\n[ERROR] in %s : thread[%x,%x] cannot add dentry <%s> in parent dir / cycle %d\n",
     2946__FUNCTION__, process->pid, this->trdid, name, cycle );
    27822947#endif
    27832948                            vfs_remove_child_from_parent( dentry_xp );
     
    27952960
    27962961#if DEBUG_VFS_ERROR     
    2797 if( DEBUG_VFS_ERROR < cycle )
    2798 printk("\n[ERROR] in %s : thread[%x,%x] cannot found node <%s> in parent for <%s>\n",
    2799 __FUNCTION__ , process->pid, this->trdid, name, pathname );
     2962printk("\n[ERROR] in %s : thread[%x,%x] cannot found node <%s> in parent for <%s> / cycle %d\n",
     2963__FUNCTION__ , process->pid, this->trdid, name, pathname, cycle );
    28002964#endif
    28012965                        vfs_remove_child_from_parent( dentry_xp );
     
    28102974
    28112975#if DEBUG_VFS_ERROR
    2812 if( DEBUG_VFS_ERROR < cycle )
    2813 printk("\n[ERROR] in %s : thread[%x,%x] found an existing node <%s>  %\n",
    2814 __FUNCTION__ , process->pid, this->trdid, pathname );
     2976printk("\n[ERROR] in %s : thread[%x,%x] found an existing node <%s> / cycle %d\n",
     2977__FUNCTION__ , process->pid, this->trdid, pathname, cycle );
    28152978#endif
    28162979                       return -1;
     
    28312994                        {
    28322995#if DEBUG_VFS_ERROR
    2833 if( DEBUG_VFS_ERROR < cycle )
    2834 printk("\n[ERROR] in %s : thread[%x,%x] cannot load <%s> from device\n",
    2835 __FUNCTION__ , process->pid, this->trdid, name );
     2996printk("\n[ERROR] in %s : thread[%x,%x] cannot load <%s> from device / cycle %d\n",
     2997__FUNCTION__ , process->pid, this->trdid, name, cycle );
    28362998#endif
    28372999                            vfs_remove_child_from_parent( dentry_xp );
     
    28643026
    28653027#if DEBUG_VFS_ERROR
    2866 if( DEBUG_VFS_ERROR < cycle )
    2867 printk("\n[ERROR] in %s : thread[%x,%x] found an existing node <%s>\n",
    2868 __FUNCTION__ , process->pid, this->trdid, pathname );
     3028printk("\n[ERROR] in %s : thread[%x,%x] found an existing node <%s> / cycle %d\n",
     3029__FUNCTION__ , process->pid, this->trdid, pathname, cycle );
    28693030#endif
    28703031                return -1;
     
    29463107    xptr_t          children_entry_xp; // extended pointer on dentry "children" field
    29473108
     3109#if DEBUG_VFS_ADD_SPECIAL || DEBUG_VFS_ERROR
     3110uint32_t    cycle   = (uint32_t)hal_get_cycles();
     3111thread_t  * this    = CURRENT_THREAD;
     3112process_t * process = this->process;
     3113#endif
     3114
    29483115#if DEBUG_VFS_ADD_SPECIAL
    2949 uint32_t   cycle = (uint32_t)hal_get_cycles();
    2950 thread_t * this  = CURRENT_THREAD;
    29513116char child_name[CONFIG_VFS_MAX_NAME_LENGTH];
    29523117char parent_name[CONFIG_VFS_MAX_NAME_LENGTH];
     
    29553120if( DEBUG_VFS_ADD_SPECIAL < cycle )
    29563121printk("\n[%s] thread[%x,%x] enter for child <%s> in parent <%s> / cycle %d\n",
    2957 __FUNCTION__, this->process->pid, this->trdid, child_name, parent_name, cycle );
     3122__FUNCTION__, process->pid, this->trdid, child_name, parent_name, cycle );
    29583123#endif
    29593124
     
    29733138    if( error )
    29743139    {
    2975         printk("\n[ERROR] in %s : cannot create dentry <.> in cluster %x\n",
    2976         __FUNCTION__ , child_cxy );
     3140
     3141#if DEBUG_VFS_ERROR
     3142printk("\n[ERROR] in %s : thread[%x,%x] cannot create dentry <.> in cluster %x / cycle %d\n",
     3143__FUNCTION__ , process->pid, this->trdid, child_cxy, cycle );
     3144#endif
    29773145        return -1;
    29783146    }
     
    29823150
    29833151#if(DEBUG_VFS_ADD_SPECIAL & 1)
    2984 cycle = (uint32_t)hal_get_cycles();
    29853152if( DEBUG_VFS_ADD_SPECIAL < cycle )
    29863153printk("\n[%s] thread[%x,%x] created dentry <.> (%x,%x) / cycle %d\n",
    2987 __FUNCTION__, this->process->pid, this->trdid, child_cxy, dentry_ptr, cycle );
     3154__FUNCTION__, process->pid, this->trdid, child_cxy, dentry_ptr, cycle );
    29883155#endif
    29893156
     
    29963163    if( error )
    29973164    {
    2998         printk("\n[ERROR] in %s : cannot register dentry <.> in xhtab\n",
    2999         __FUNCTION__ );
     3165
     3166#if DEBUG_VFS_ERROR
     3167printk("\n[ERROR] in %s : thread[%x,%x] cannot register dentry <.> in xhtab / cycle %d\n",
     3168__FUNCTION__ , process->pid, this->trdid, cycle );
     3169#endif
    30003170        return -1;
    30013171    }
     
    30093179if( DEBUG_VFS_ADD_SPECIAL < cycle )
    30103180printk("\n[%s] thread[%x,%x] linked dentry <.> to parent and child inodes / cycle %d\n",
    3011 __FUNCTION__, this->process->pid, this->trdid, cycle );
     3181__FUNCTION__, process->pid, this->trdid, cycle );
    30123182#endif
    30133183
     
    30203190        if( error )
    30213191        {
    3022             printk("\n[ERROR] in %s : cannot introduce dentry <..> in mapper %x\n",
    3023             __FUNCTION__ );
     3192
     3193#if DEBUG_VFS_ERROR
     3194printk("\n[ERROR] in %s : thread[%x,%x] cannot register dentry <.> in mapper / cycle %d\n",
     3195__FUNCTION__ , process->pid, this->trdid, cycle );
     3196#endif
    30243197            return -1;
    30253198        }
     
    30293202if( DEBUG_VFS_ADD_SPECIAL < cycle )
    30303203printk("\n[%s] thread[%x,%x] registered dentry <.> in child mapper / cycle %d\n",
    3031 __FUNCTION__, this->process->pid, this->trdid, cycle );
     3204__FUNCTION__, process->pid, this->trdid, cycle );
    30323205#endif
    30333206
     
    30413214    if( error )
    30423215    {
    3043         printk("\n[ERROR] in %s : cannot create dentry <..> in cluster %x\n",
    3044         __FUNCTION__ , child_cxy );
     3216
     3217#if DEBUG_VFS_ERROR
     3218printk("\n[ERROR] in %s : thread[%x,%x] cannot create dentry <..> in cluster %x / cycle %d\n",
     3219__FUNCTION__ , process->pid, this->trdid, child_cxy, cycle );
     3220#endif
    30453221        return -1;
    30463222    }
     
    30533229if( DEBUG_VFS_ADD_SPECIAL < cycle )
    30543230printk("\n[%s] thread[%x,%x] created dentry <..> (%x,%x) / cycle %d\n",
    3055 __FUNCTION__, this->process->pid, this->trdid, child_cxy, dentry_ptr, cycle );
     3231__FUNCTION__, process->pid, this->trdid, child_cxy, dentry_ptr, cycle );
    30563232#endif
    30573233
     
    30593235    children_xhtab_xp = XPTR( child_cxy , &child_ptr->children );
    30603236    children_entry_xp = XPTR( child_cxy , &dentry_ptr->children );
     3237
    30613238    error = xhtab_insert( children_xhtab_xp , ".." , children_entry_xp );
     3239
    30623240    if( error )
    30633241    {
    3064         printk("\n[ERROR] in %s : cannot register dentry <..> in xhtab\n",
    3065         __FUNCTION__ );
     3242
     3243#if DEBUG_VFS_ERROR
     3244printk("\n[ERROR] in %s : thread[%x,%x] cannot register dentry <..> in xhtab / cycle %d\n",
     3245__FUNCTION__ , process->pid, this->trdid, cycle );
     3246#endif
    30663247        return -1;
    30673248    }
     
    30773258if( DEBUG_VFS_ADD_SPECIAL < cycle )
    30783259printk("\n[%s] thread[%x,%x] linked dentry <..> to parent and child inodes / cycle %d\n",
    3079 __FUNCTION__, this->process->pid, this->trdid, cycle );
     3260__FUNCTION__, process->pid, this->trdid, cycle );
    30803261#endif
    30813262
     
    30883269        if( error )
    30893270        {
    3090             printk("\n[ERROR] in %s : cannot introduce dentry <..> in mapper %x\n",
    3091             __FUNCTION__ );
     3271
     3272#if DEBUG_VFS_ERROR
     3273printk("\n[ERROR] in %s : thread[%x,%x] cannot register dentry <..> in mapper / cycle %d\n",
     3274__FUNCTION__ , process->pid, this->trdid, cycle );
     3275#endif
    30923276            return -1;
    30933277        }
     
    30973281if( DEBUG_VFS_ADD_SPECIAL < cycle )
    30983282printk("\n[%s] thread[%x,%x] registered dentry <..> in child mapper / cycle %d\n",
    3099 __FUNCTION__, this->process->pid, this->trdid, cycle );
     3283__FUNCTION__, process->pid, this->trdid, cycle );
    31003284#endif
    31013285
     
    31063290if( DEBUG_VFS_ADD_SPECIAL < cycle )
    31073291printk("\n[%s] thread[%x,%x] exit for child <%s> in parent <%s> / cycle %d\n",
    3108 __FUNCTION__, this->process->pid, this->trdid, child_name, parent_name, cycle );
     3292__FUNCTION__, process->pid, this->trdid, child_name, parent_name, cycle );
    31093293#endif
    31103294
     
    31393323
    31403324#if DEBUG_VFS_GET_PATH
    3141 uint32_t cycle = (uint32_t)hal_get_cycles();
     3325uint32_t    cycle   = (uint32_t)hal_get_cycles();
     3326#endif
     3327
     3328#if DEBUG_VFS_GET_PATH
    31423329if( DEBUG_VFS_GET_PATH < cycle )
    31433330printk("\n[%s] thread[%x,%x] enter : inode (%x,%x) / cycle %d\n",
     
    32963483
    32973484#if DEBUG_VFS_ERROR
    3298 if( DEBUG_VFS_ERROR < cycle )
    3299 printk("\n[ERROR] in %s : thread[%x,%x] cannot create dentry <%s> in cluster %x\n",
    3300 __FUNCTION__ , this->process->pid, this->trdid , name , parent_cxy );
     3485printk("\n[ERROR] in %s : thread[%x,%x] cannot create dentry <%s> in cluster %x / cycle %d\n",
     3486__FUNCTION__ , this->process->pid, this->trdid , name , parent_cxy, cycle );
    33013487#endif
    33023488        return -1;
     
    33303516
    33313517#if DEBUG_VFS_ERROR
    3332 if( DEBUG_VFS_ERROR < cycle )
    3333 printk("\n[ERROR] in %s : thread[%x,%x] cannot create inode in cluster %x\n",
    3334 __FUNCTION__ , this->process->pid , this->trdid , child_cxy );
     3518printk("\n[ERROR] in %s : thread[%x,%x] cannot create inode in cluster %x / cycle %d\n",
     3519__FUNCTION__ , this->process->pid , this->trdid , child_cxy, cycle );
    33353520#endif
    33363521 
     
    34283613
    34293614#if DEBUG_VFS_REMOVE_CHILD
    3430 if( DEBUG_VFS_REMOVE_CHILD < cycle )
    34313615printk("\n[%s] thread[%x,%x] enter for dentry[%x,%x] / inode[%x,%x] / cycle %d\n",
    34323616__FUNCTION__, this->process->pid, this->trdid,
     
    34413625    if( error )
    34423626    {
    3443         printk("\n[WARNING] in %s] thread[%x,%x] cannot remove dentry %s from parent dir\n",
    3444         __FUNCTION__, this->process->pid, this->trdid, dentry_name );
    3445     }
    3446 
    3447 #if DEBUG_VFS_REMOVE_CHILD
    3448 cycle = (uint32_t)hal_get_cycles();
     3627        printk("\n[WARNING] in %s : thread[%x,%x] cannot remove dentry <%s> from parent\n",
     3628        __FUNCTION__ , this->process->pid , this->trdid , dentry_name );
     3629    }
     3630
     3631#if(DEBUG_VFS_REMOVE_CHILD & 1)
    34493632if( DEBUG_VFS_REMOVE_CHILD < cycle )
    3450 printk("\n[%s] thread[%x,%x] removed dentry from parent inode / cycle %d\n",
    3451 __FUNCTION__, this->process->pid, this->trdid, cycle );
     3633printk("\n[%s] thread[%x,%x] removed dentry from parent inode\n",
     3634__FUNCTION__, this->process->pid, this->trdid );
    34523635#endif
    34533636
     
    34583641    links = hal_remote_atomic_add( XPTR( child_cxy , &child_inode_ptr->links ) , -1 );
    34593642
    3460 #if DEBUG_VFS_REMOVE_CHILD
    3461 cycle = (uint32_t)hal_get_cycles();
     3643#if(DEBUG_VFS_REMOVE_CHILD & 1)
    34623644if( DEBUG_VFS_REMOVE_CHILD < cycle )
    3463 printk("\n[%s] thread[%x,%x] removed dentry from child inode / cycle %d\n",
    3464 __FUNCTION__, this->process->pid, this->trdid, cycle );
     3645printk("\n[%s] thread[%x,%x] removed dentry from child inode\n",
     3646__FUNCTION__, this->process->pid, this->trdid );
    34653647#endif
    34663648
     
    37233905assert( __FUNCTION__, (array != NULL) , "child pointer is NULL");
    37243906assert( __FUNCTION__, (detailed == false) , "detailed argument not supported\n");
    3725 
    3726     // check inode type
    3727     if( inode->type != FILE_TYPE_DIR )
    3728     {
    3729         printk("\n[ERROR] in %s : target inode is not a directory\n",
    3730         __FUNCTION__ );
    3731         return -1;
    3732     }
     3907assert( __FUNCTION__, (inode->type == FILE_TYPE_DIR), "inode is not a directory\n");
    37333908
    37343909    // get parent inode FS type
  • trunk/kernel/fs/vfs.h

    r673 r683  
    168168 *****************************************************************************************/
    169169
    170 /* this enum define the VFS inode types values                                           */
     170/* this enum define the VFS file types                                                   */
    171171/* WARNING : this enum must be kept consistent with macros in <shared_stat.h> file       */
    172172/*           and with types in <shared_dirent.h> file.                                   */
     
    174174typedef enum   
    175175{
    176     FILE_TYPE_REG   =     0,           /*! regular file                                 */
    177     FILE_TYPE_DIR   =     1,           /*! directory                                    */
    178     FILE_TYPE_FIFO  =     2,           /*! POSIX named fifo                             */
    179     FILE_TYPE_PIPE  =     3,           /*! POSIX anonymous pipe                         */
    180     FILE_TYPE_SOCK  =     4,           /*! POSIX anonymous socket                       */
    181     FILE_TYPE_DEV   =     5,           /*! character device                             */
    182     FILE_TYPE_BLK   =     6,           /*! block device                                 */
    183     FILE_TYPE_SYML  =     7,           /*! symbolic link                                */
     176    FILE_TYPE_REG   =     0,           /*! regular file                                  */
     177    FILE_TYPE_DIR   =     1,           /*! directory                                     */
     178    FILE_TYPE_FIFO  =     2,           /*! POSIX named fifo                              */
     179    FILE_TYPE_PIPE  =     3,           /*! POSIX anonymous pipe                          */
     180    FILE_TYPE_SOCK  =     4,           /*! POSIX anonymous socket                        */
     181    FILE_TYPE_DEV   =     5,           /*! character device                              */
     182    FILE_TYPE_BLK   =     6,           /*! block device                                  */
     183    FILE_TYPE_SYML  =     7,           /*! symbolic link                                 */
    184184}
    185185vfs_file_type_t;
     
    200200        struct vfs_ctx_s      * ctx;        /*! local pointer on FS context.                 */
    201201        vfs_file_attr_t         attr;       /*! file attributes bit vector (see above)       */
    202         vfs_file_type_t        type;       /*! same type as inode                           */
     202        vfs_file_type_t         type;       /*! same type as inode                           */
    203203        uint32_t                offset;     /*! seek position in file                        */
    204204        remote_rwlock_t         lock;       /*! protect offset modifications                 */
     
    285285    uint32_t              inum;          /*! inode identifier (unique in file system)    */
    286286    uint32_t              attr;          /*! inode attributes (see above)                */
    287     vfs_file_type_t      type;          /*! inode type (see above)                      */
     287    vfs_file_type_t       type;          /*! inode type (see vfs_file_t)                 */
    288288    uint32_t              size;          /*! number of bytes                             */
    289289    uint32_t              uid;           /*! user owner identifier                       */
     
    829829/******************************************************************************************
    830830 * This function returns, in the structure pointed by the <st> pointer, various
    831  * informations on the inode identified by the <root_inode_xp> and <patname> arguments.
     831 * informations on the file identified by the <root_inode_xp> and <patname> arguments.
    832832 *
    833833 * TODO : only partially implemented yet (only size and inum fields).
Note: See TracChangeset for help on using the changeset viewer.