Changeset 673 for trunk/kernel/fs


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

Introduce the DEBUG_VFS_ERROR in kernel_config to make
error messges display conditional.

Location:
trunk/kernel/fs
Files:
6 edited

Legend:

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

    r657 r673  
    33 *
    44 * Author   Mohamed Lamine Karaoui (2014,2015)
    5  *          Alain Greiner (2016,2017,2018,2019,2020)
     5 *          Alain Greiner          (2016,2017,2018,2019,2020)
    66 *
    77 * Copyright (c) Sorbonne Universites
     
    124124    // update inode "type" field
    125125    inode = GET_PTR( *devfs_dev_inode_xp );
    126     inode->type = INODE_TYPE_DIR;
     126    inode->type = FILE_TYPE_DIR;
    127127 
    128128    // create dentries <.> and <..> in <dev>
     
    154154    // update inode "type" field
    155155    inode = GET_PTR( *devfs_external_inode_xp );
    156     inode->type = INODE_TYPE_DIR;
     156    inode->type = FILE_TYPE_DIR;
    157157 
    158158    // create dentries <.> and <..> in <external>
     
    201201
    202202    // create <internal> directory
    203     snprintf( node_name , 16 , "internal_%x" , local_cxy );
     203    snprintk( node_name , 16 , "internal_%x" , local_cxy );
    204204
    205205    error = vfs_add_child_in_parent( local_cxy,              // target cluster
     
    212212    // set <internal> inode "type" field
    213213    internal_inode_ptr       = GET_PTR( internal_inode_xp );
    214     internal_inode_ptr->type = INODE_TYPE_DEV;
     214    internal_inode_ptr->type = FILE_TYPE_DEV;
    215215 
    216216    // create dentries <.> and <..> in <internal>
     
    262262        inode_ptr = GET_PTR( inode_xp );
    263263        inode_ptr->extend = chdev_ptr;
    264         inode_ptr->type   = INODE_TYPE_DEV;
     264        inode_ptr->type   = FILE_TYPE_DEV;
    265265       
    266266#if DEBUG_DEVFS_LOCAL_INIT
     
    305305            inode_ptr = GET_PTR( inode_xp );
    306306            inode_ptr->extend = chdev_ptr;
    307             inode_ptr->type   = INODE_TYPE_DEV;
     307            inode_ptr->type   = FILE_TYPE_DEV;
    308308       
    309309#if DEBUG_DEVFS_LOCAL_INIT
     
    341341            inode_ptr = GET_PTR( inode_xp );
    342342            inode_ptr->extend = chdev_ptr;
    343             inode_ptr->type   = INODE_TYPE_DEV;
     343            inode_ptr->type   = FILE_TYPE_DEV;
    344344       
    345345#if DEBUG_DEVFS_LOCAL_INIT
     
    378378            inode_ptr = GET_PTR( inode_xp );
    379379            inode_ptr->extend = chdev_ptr;
    380             inode_ptr->type   = INODE_TYPE_DEV;
     380            inode_ptr->type   = FILE_TYPE_DEV;
    381381       
    382382#if DEBUG_DEVFS_LOCAL_INIT
     
    417417                inode_ptr = GET_PTR( inode_xp );
    418418                inode_ptr->extend = chdev_ptr;
    419                 inode_ptr->type   = INODE_TYPE_DEV;
     419                inode_ptr->type   = FILE_TYPE_DEV;
    420420       
    421421#if DEBUG_DEVFS_LOCAL_INIT
     
    456456                inode_ptr = GET_PTR( inode_xp );
    457457                inode_ptr->extend = chdev_ptr;
    458                 inode_ptr->type   = INODE_TYPE_DEV;
     458                inode_ptr->type   = FILE_TYPE_DEV;
    459459       
    460460#if DEBUG_DEVFS_LOCAL_INIT
     
    495495                inode_ptr = GET_PTR( inode_xp );
    496496                inode_ptr->extend = chdev_ptr;
    497                 inode_ptr->type   = INODE_TYPE_DEV;
     497                inode_ptr->type   = FILE_TYPE_DEV;
    498498       
    499499#if DEBUG_DEVFS_LOCAL_INIT
     
    534534                inode_ptr = GET_PTR( inode_xp );
    535535                inode_ptr->extend = chdev_ptr;
    536                 inode_ptr->type   = INODE_TYPE_DEV;
     536                inode_ptr->type   = FILE_TYPE_DEV;
    537537       
    538538#if DEBUG_DEVFS_LOCAL_INIT
     
    573573                inode_ptr = GET_PTR( inode_xp );
    574574                inode_ptr->extend = chdev_ptr;
    575                 inode_ptr->type   = INODE_TYPE_DEV;
     575                inode_ptr->type   = FILE_TYPE_DEV;
    576576 
    577577#if DEBUG_DEVFS_LOCAL_INIT
     
    612612                inode_ptr = GET_PTR( inode_xp );
    613613                inode_ptr->extend = chdev_ptr;
    614                 inode_ptr->type   = INODE_TYPE_DEV;
     614                inode_ptr->type   = FILE_TYPE_DEV;
    615615       
    616616#if DEBUG_DEVFS_LOCAL_INIT
     
    643643    char             k_buf[CONFIG_TXT_KBUF_SIZE];  // local kernel buffer
    644644
    645 assert( ( file_xp != XPTR_NULL ) , "file_xp == XPTR_NULL" );
     645assert( __FUNCTION__, ( file_xp != XPTR_NULL ) , "file_xp == XPTR_NULL" );
    646646
    647647#if (DEBUG_SYS_READ & 1)
     
    673673
    674674// Only TXT devices are associated to a pseudo-file
    675 assert( ( func == DEV_FUNC_TXT ) , __FUNCTION__, "illegal device func_type");
     675assert( __FUNCTION__, ( func == DEV_FUNC_TXT ) , "illegal device func_type");
    676676
    677677    // initialise number of bytes to move
     
    770770
    771771// detailed argument unused
    772 assert( (detailed == false) , "detailed argument not supported\n");
     772assert( __FUNCTION__, (detailed == false) , "detailed argument not supported\n");
    773773 
    774774    // One loop to scan the target inode xhtab containing the set of dentries
  • trunk/kernel/fs/devfs.h

    r657 r673  
    33 *
    44 * Authors       Mohamed Lamine Karaoui (2014,2015)
    5  *               Alain Greiner (2016,2017,2018,2019,2020)
     5 *               Alain Greiner          (2016,2017,2018,2019,2020)
    66 *
    77 * Copyright (c) 2011,2012 UPMC Sorbonne Universites
  • trunk/kernel/fs/fatfs.c

    r657 r673  
    10981098    error_t    error;
    10991099
    1100 assert( (searched_page_id > first_page_id) ,
     1100assert( __FUNCTION__, (searched_page_id > first_page_id) ,
    11011101"searched_page_id must be larger than first_page_id\n");
    11021102
     
    12391239
    12401240// check arguments
    1241 assert( (mapper_xp != XPTR_NULL) , "mapper pointer is NULL\n" );
    1242 assert( (name      != NULL     ) , "child name is undefined\n" );
     1241assert( __FUNCTION__, (mapper_xp != XPTR_NULL) , "mapper pointer is NULL\n" );
     1242assert( __FUNCTION__, (name      != NULL     ) , "child name is undefined\n" );
    12431243
    12441244#if DEBUG_FATFS_SCAN_DIRECTORY
     
    18821882 
    18831883// check arguments
    1884 assert( (parent_inode_xp != XPTR_NULL) , "parent_inode_xp argument is NULL\n" );
    1885 assert( (dentry_ptr      != NULL)      , "dentry_ptr argument is NULL\n" );
     1884assert( __FUNCTION__, (parent_inode_xp != XPTR_NULL) , "parent_inode_xp argument is NULL\n" );
     1885assert( __FUNCTION__, (dentry_ptr      != NULL)      , "dentry_ptr argument is NULL\n" );
    18861886
    18871887    // get directory inode cluster and local pointer
     
    21532153                    else if (i == 11)                                // ATTR
    21542154                    {
    2155                         if (type == INODE_TYPE_DIR)  buf[i] = 0x10;
     2155                        if (type == FILE_TYPE_DIR)  buf[i] = 0x10;
    21562156                        else                         buf[i] = 0x20;
    21572157                    }
     
    22362236
    22372237// check arguments
    2238 assert( (parent_inode_xp != XPTR_NULL) , "parent_inode_xp argument is NULL\n" );
    2239 assert( (dentry_ptr      != NULL)      , "dentry_ptr argument is NULL\n" );
     2238assert( __FUNCTION__, (parent_inode_xp != XPTR_NULL) , "parent_inode_xp argument is NULL\n" );
     2239assert( __FUNCTION__, (dentry_ptr      != NULL)      , "dentry_ptr argument is NULL\n" );
    22402240
    22412241    // get directory inode cluster and local pointer
     
    23442344
    23452345// check for LFN entry
    2346 assert( (fatfs_get_remote_record( DIR_ATTR, base_xp + offset ) == ATTR_LONG_NAME_MASK ),
     2346assert( __FUNCTION__, (fatfs_get_remote_record( DIR_ATTR, base_xp + offset ) == ATTR_LONG_NAME_MASK ),
    23472347"this directory entry must be a LFN\n");
    23482348
     
    23952395
    23962396// check arguments
    2397 assert( (parent_inode_xp != XPTR_NULL)  , "parent_inode_xp is NULL\n" );
    2398 assert( (dentry_ptr      != NULL ) , "dentry_ptr is NULL\n" );
     2397assert( __FUNCTION__, (parent_inode_xp != XPTR_NULL)  , "parent_inode_xp is NULL\n" );
     2398assert( __FUNCTION__, (dentry_ptr      != NULL ) , "dentry_ptr is NULL\n" );
    23992399
    24002400    // get parent inode cluster and local pointer
     
    24452445
    24462446    // update the child inode "type", "size", and "extend" fields
    2447     vfs_inode_type_t type = (is_dir) ? INODE_TYPE_DIR : INODE_TYPE_FILE;
     2447    vfs_file_type_t type = (is_dir) ? FILE_TYPE_DIR : FILE_TYPE_REG;
    24482448
    24492449    hal_remote_s32( XPTR( child_cxy , &child_inode_ptr->type   ) , type );
     
    24862486
    24872487// check arguments
    2488 assert( (parent_inode_xp != XPTR_NULL) , "parent_inode_xp argument is NULL\n" );
    2489 assert( (dentry_ptr      != NULL)      , "dentry_ptr argument NULL\n" );
     2488assert( __FUNCTION__, (parent_inode_xp != XPTR_NULL) , "parent_inode_xp argument is NULL\n" );
     2489assert( __FUNCTION__, (dentry_ptr      != NULL)      , "dentry_ptr argument NULL\n" );
    24902490
    24912491    // get child inode cluster and local pointer
     
    25742574
    25752575// check arguments
    2576 assert( (parent_inode_xp  != XPTR_NULL) , "parent_inode_xp argument is NULL\n" );
    2577 assert( (dentry_ptr       != NULL)      , "dentry_ptr argument is NULL\n" );
     2576assert( __FUNCTION__, (parent_inode_xp  != XPTR_NULL) , "parent_inode_xp argument is NULL\n" );
     2577assert( __FUNCTION__, (dentry_ptr       != NULL)      , "dentry_ptr argument is NULL\n" );
    25782578
    25792579    // get parent directory cluster ans local pointer
     
    26802680
    26812681// check mapper pointer
    2682 assert( (mapper != NULL) , "mapper is NULL\n");
     2682assert( __FUNCTION__, (mapper != NULL) , "mapper is NULL\n");
    26832683   
    26842684// TODO handle the detailed flag
    2685 assert( (detailed == false), "detailed argument not supported/n");
     2685assert( __FUNCTION__, (detailed == false), "detailed argument not supported/n");
    26862686
    26872687    char       cname[CONFIG_VFS_MAX_NAME_LENGTH];  // name extracted from each dentry
     
    28292829
    28302830// check inode pointer and cluster index
    2831 assert( (inode_xp != XPTR_NULL)          , "inode pointer undefined\n" );
     2831assert( __FUNCTION__, (inode_xp != XPTR_NULL)          , "inode pointer undefined\n" );
    28322832
    28332833#if DEBUG_FATFS_SYNC_INODE
     
    28482848    mapper    = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->mapper ) );
    28492849
    2850 assert( (mapper != NULL) , "mapper pointer is NULL\n" );     
     2850assert( __FUNCTION__, (mapper != NULL) , "mapper pointer is NULL\n" );     
    28512851
    28522852    // get inode type and size
     
    28542854    type = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->type ) );
    28552855
    2856 assert( (type == INODE_TYPE_FILE) , "inode is not a file\n" );     
     2856assert( __FUNCTION__, (type == FILE_TYPE_REG) , "inode is not a file\n" );     
    28572857
    28582858    // compute number of pages
     
    30093009
    30103010// check inode pointer
    3011 assert( (inode_xp != XPTR_NULL) , "inode pointer is NULL\n" );
     3011assert( __FUNCTION__, (inode_xp != XPTR_NULL) , "inode pointer is NULL\n" );
    30123012
    30133013    // get inode cluster and local pointer
     
    30203020
    30213021// check first cluster index
    3022 assert( (first_cluster_id != 0) , "inode extend is NULL\n" );
     3022assert( __FUNCTION__, (first_cluster_id != 0) , "inode extend is NULL\n" );
    30233023
    30243024#if DEBUG_FATFS_RELEASE_INODE
  • trunk/kernel/fs/ramfs.c

    r623 r673  
    5050    // update inode type field
    5151    inode_ptr = GET_PTR( inode_xp );
    52     inode_ptr->type = INODE_TYPE_DIR;
     52    inode_ptr->type = FILE_TYPE_DIR;
    5353}
    5454
  • trunk/kernel/fs/vfs.c

    r657 r673  
    22 * vfs.c - Virtual File System implementation.
    33 *
    4  * Author  Mohamed Lamine Karaoui (2015)
    5  *         Alain Greiner (2016,2017,2018,2019,2020)
     4 * Author  Mohamed Lamine Karaoui (2014,2015)
     5 *         Alain Greiner          (2016,2017,2018,2019,2020)
    66 *
    77 * Copyright (c) UPMC Sorbonne Universites
     
    3838#include <thread.h>
    3939#include <chdev.h>
     40#include <pipe.h>
    4041#include <process.h>
    4142#include <cluster.h>
     
    155156//////////////////////////////////////////////////////////////////////////////////////////
    156157
    157 const char * vfs_inode_type_str( vfs_inode_type_t type )
     158const char * vfs_inode_type_str( vfs_file_type_t type )
    158159{
    159160    switch ( type )
    160161    {
    161         case INODE_TYPE_FILE: return "FILE";
    162         case INODE_TYPE_DIR:  return "DIR ";
    163         case INODE_TYPE_FIFO: return "FIFO";
    164         case INODE_TYPE_PIPE: return "PIPE";
    165         case INODE_TYPE_SOCK: return "SOCK";
    166         case INODE_TYPE_DEV:  return "DEV ";
    167         case INODE_TYPE_BLK:  return "BLK ";
    168         case INODE_TYPE_SYML: return "SYML";
     162        case FILE_TYPE_REG: return "FILE";
     163        case FILE_TYPE_DIR:  return "DIR ";
     164        case FILE_TYPE_FIFO: return "FIFO";
     165        case FILE_TYPE_PIPE: return "PIPE";
     166        case FILE_TYPE_SOCK: return "SOCK";
     167        case FILE_TYPE_DEV:  return "DEV ";
     168        case FILE_TYPE_BLK:  return "BLK ";
     169        case FILE_TYPE_SYML: return "SYML";
    169170        default:              return "undefined";
    170171    }
     
    188189    error_t            error;
    189190
     191#if DEBUG_VFS_INODE_CREATE || DEBUG_VFS_ERROR
     192uint32_t       cycle      = (uint32_t)hal_get_cycles();
     193thread_t *     this       = CURRENT_THREAD;
     194#endif
     195
    190196    // check fs type and get pointer on context
    191197    if     ( fs_type == FS_TYPE_FATFS ) ctx = &fs_context[FS_TYPE_FATFS];
     
    194200    else
    195201    {
    196         printk("\n[ERROR] in %s : illegal FS type\n", __FUNCTION__ );
     202
     203#if DEBUG_VFS_ERROR
     204if( DEBUG_VFS_ERROR < cycle )
     205printk("\n[ERROR] in %s : thread[%x,%x] / illegal FS type\n",
     206__FUNCTION__ , this->process->pid , this->trdid );
     207#endif
    197208        return -1;
    198209    }
    199210
    200211// check inode descriptor contained in one page
    201 assert( (sizeof(vfs_inode_t) <= CONFIG_PPM_PAGE_SIZE),
     212assert( __FUNCTION__, (sizeof(vfs_inode_t) <= CONFIG_PPM_PAGE_SIZE),
    202213"inode descriptor must fit in one page" );
    203214
     
    207218    if( error )
    208219    {
    209         printk("\n[ERROR] in %s : cannot allocate inum\n", __FUNCTION__ );
     220
     221#if DEBUG_VFS_ERROR
     222if( DEBUG_VFS_ERROR < cycle )
     223printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate inum\n",
     224__FUNCTION__ , this->process->pid , this->trdid );
     225#endif
    210226        return -1;
    211227    }
     
    216232    if( mapper_xp == XPTR_NULL )
    217233    {
    218         printk("\n[ERROR] in %s : cannot allocate mapper\n", __FUNCTION__ );
     234
     235#if DEBUG_VFS_ERROR
     236if( DEBUG_VFS_ERROR < cycle )
     237printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate mapper\n",
     238__FUNCTION__ , this->process->pid , this->trdid );
     239#endif
    219240        vfs_ctx_inum_release( XPTR( cxy , ctx ) , inum );
    220241        return -1;
     
    232253    if( inode_ptr == NULL )
    233254    {
    234         printk("\n[ERROR] in %s : cannot allocate inode descriptor\n", __FUNCTION__ );
     255
     256#if DEBUG_VFS_ERROR
     257if( DEBUG_VFS_ERROR < cycle )
     258printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate inode\n",
     259__FUNCTION__ , this->process->pid , this->trdidi );
     260#endif
    235261        vfs_ctx_inum_release( XPTR( cxy , ctx ) , inum );
    236262        mapper_destroy( mapper_xp );
     
    242268 
    243269    // initialize inode descriptor
    244     hal_remote_s32( XPTR( cxy , &inode_ptr->type   ) , INODE_TYPE_FILE );  // default value
     270    hal_remote_s32( XPTR( cxy , &inode_ptr->type   ) , FILE_TYPE_REG );  // default value
    245271    hal_remote_s32( XPTR( cxy , &inode_ptr->inum   ) , inum ); 
    246272    hal_remote_s32( XPTR( cxy , &inode_ptr->attr   ) , attr ); 
     
    269295
    270296#if DEBUG_VFS_INODE_CREATE
    271 uint32_t       cycle      = (uint32_t)hal_get_cycles();
    272 thread_t *     this       = CURRENT_THREAD;
    273297if( DEBUG_VFS_INODE_CREATE < cycle )
    274298printk("\n[%s] thread[%x,%x] created inode (%x,%x) / ctx %x / fs_type %d / cycle %d\n",
     
    287311    cxy_t         inode_cxy = GET_CXY( inode_xp );
    288312
     313    // get local pointer on mapper
     314    mapper_t    * mapper_ptr = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->mapper ));
     315
    289316    // release memory allocated for mapper
    290     mapper_destroy( XPTR( inode_cxy , &inode_ptr->mapper ) );
     317    mapper_destroy( XPTR( inode_cxy , mapper_ptr ) );
    291318
    292319    // release memory allocated for inode descriptor
     
    458485void vfs_inode_display( xptr_t inode_xp )
    459486{
    460     assert( (inode_xp != XPTR_NULL), "inode pointer is NULL");
     487    assert( __FUNCTION__, (inode_xp != XPTR_NULL), "inode pointer is NULL");
    461488
    462489    char  name[CONFIG_VFS_MAX_NAME_LENGTH];
     
    468495    vfs_inode_t * inode_ptr = GET_PTR( inode_xp );
    469496
    470     vfs_inode_type_t type    = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->type ) );
     497    vfs_file_type_t type    = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->type ) );
    471498    uint32_t         attr    = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->attr ) );
    472499    uint32_t         size    = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->size ) );
     
    511538    vfs_dentry_t   * dentry_ptr;     // dentry descriptor (to be allocated)
    512539
    513 #if DEBUG_VFS_DENTRY_CREATE
     540#if DEBUG_VFS_DENTRY_CREATE || DEBUG_VFS_ERROR
    514541thread_t * this  = CURRENT_THREAD;
    515542uint32_t   cycle = (uint32_t)hal_get_cycles();
     543#endif
     544
     545#if DEBUG_VFS_DENTRY_CREATE
    516546if( DEBUG_VFS_DENTRY_CREATE < cycle )
    517547printk("\n[%s] thread[%x,%x] enters for <%s> /  fs_type %x / cycle %d\n",
     
    525555    else
    526556    {
    527         printk("\n[ERROR] in %s undefined fs_type %d\n", __FUNCTION__, fs_type );
     557
     558#if DEBUG_VFS_ERROR
     559if( DEBUG_VFS_ERROR < cycle )
     560printk("\n[ERROR] in %s : thread[%x,%x] / undefined fs_type %d\n",
     561__FUNCTION__ , this->process->pid, this->trdid, fs_type );
     562#endif
    528563        return -1;
    529564    }
     
    542577    if( dentry_ptr == NULL )
    543578    {
    544         printk("\n[ERROR] in %s : cannot allocate dentry descriptor\n",
    545         __FUNCTION__ );
     579
     580#if DEBUG_VFS_ERROR
     581if( DEBUG_VFS_ERROR < cycle )
     582printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate dentry descriptor\n",
     583__FUNCTION__ , this->process->pid, this->trdid );
     584#endif
    546585        return -1;
    547586    }
     
    594633                         xptr_t   * file_xp )
    595634{
    596     vfs_file_t  * file_ptr;
    597         kmem_req_t    req;
    598     uint32_t      type;
    599     mapper_t    * mapper;
    600     vfs_ctx_t   * ctx;
     635    vfs_file_t   * file_ptr;
     636        kmem_req_t     req;
     637    uint32_t       type;
     638    mapper_t     * mapper;
     639    pipe_t       * pipe;
     640    vfs_ctx_t    * ctx;
    601641
    602642    // get inode cluster and local pointer
     
    607647thread_t * this = CURRENT_THREAD;
    608648uint32_t cycle = (uint32_t)hal_get_cycles();
    609 if( DEBUG_VFS_OPEN < cycle )
     649if( DEBUG_VFS_FILE_CREATE < cycle )
    610650printk("\n[%s] thread[%x,%x] enter for inode (%x,%x) / cycle %d\n",
    611651__FUNCTION__, this->process->pid, this->trdid, inode_cxy, inode_ptr, cycle );
     
    620660    if( file_ptr == NULL ) return -1;
    621661
    622     // get type, ctx and mapper from inode descriptor
     662    // get type, ctx, mapper, and buffer from inode descriptor
    623663    type   = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->type ) );
    624664    ctx    = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->ctx ) );
    625665    mapper = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->mapper ) );
     666    pipe   = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->pipe ) );
    626667
    627668    // initializes new file descriptor
    628669    hal_remote_s32( XPTR( inode_cxy , &file_ptr->type     ) , type );
    629670    hal_remote_s32( XPTR( inode_cxy , &file_ptr->attr     ) , attr );
     671    hal_remote_spt( XPTR( inode_cxy , &file_ptr->ctx      ) , ctx );
    630672    hal_remote_s32( XPTR( inode_cxy , &file_ptr->offset   ) , 0 );
    631     hal_remote_s32( XPTR( inode_cxy , &file_ptr->refcount ) , 1 );
    632673    hal_remote_spt( XPTR( inode_cxy , &file_ptr->inode    ) , inode_ptr );
    633     hal_remote_spt( XPTR( inode_cxy , &file_ptr->ctx      ) , ctx );
    634674    hal_remote_spt( XPTR( inode_cxy , &file_ptr->mapper   ) , mapper );
     675    hal_remote_spt( XPTR( inode_cxy , &file_ptr->pipe     ) , pipe );
    635676
    636677    remote_rwlock_init( XPTR( inode_cxy , &file_ptr->lock ), LOCK_VFS_FILE );
     
    639680
    640681#if DEBUG_VFS_FILE_CREATE
    641 cycle = (uint32_t)hal_get_cycles();
    642 if( DEBUG_VFS_OPEN < cycle )
    643 printk("\n[%s] thread[%x,%x] created file (%x,%x) %x\n",
    644 __FUNCTION__, this->process->pid, this->trdid, inode_cxy, file_ptr, cycle );
     682if( (DEBUG_VFS_FILE_CREATE < cycle) && (type == FILE_TYPE_REG))
     683{
     684    char name[CONFIG_VFS_MAX_NAME_LENGTH];
     685    vfs_file_get_name( XPTR( inode_cxy , file_ptr ) , name );
     686    printk("\n[%s] thread[%x,%x] created file (%x,%x) / %s (%s)\n",
     687    __FUNCTION__, this->process->pid, this->trdid,
     688    inode_cxy, file_ptr, vfs_inode_type_str(type), name );
     689}
     690if( (DEBUG_VFS_FILE_CREATE < cycle) && (type != FILE_TYPE_REG))
     691{
     692    printk("\n[%s] thread[%x,%x] created file (%x,%x) / %s\n",
     693    __FUNCTION__, this->process->pid, this->trdid,
     694    inode_cxy, file_ptr, vfs_inode_type_str(type) );
     695}
    645696#endif
    646697
     
    655706    vfs_file_t * file_ptr = GET_PTR( file_xp );
    656707    cxy_t        file_cxy = GET_CXY( file_xp );
     708
     709#if DEBUG_VFS_FILE_DESTROY
     710char name[CONFIG_VFS_MAX_NAME_LENGTH];
     711vfs_file_get_name( file_xp , name );
     712thread_t * this = CURRENT_THREAD;
     713uint32_t cycle = (uint32_t)hal_get_cycles();
     714if( DEBUG_VFS_FILE_DESTROY < cycle )
     715printk("\n[%s] thread[%x,%x] enter / file_ptr %x / file_cxy %x / <%s> / cycle %d\n",
     716__FUNCTION__, this->process->pid, this->trdid, file_ptr, file_cxy, name, cycle );
     717#endif
    657718
    658719    // release file descriptor
     
    662723        kmem_remote_free( file_cxy , &req );
    663724
    664 #if DEBUG_VFS_CLOSE
    665 char name[CONFIG_VFS_MAX_NAME_LENGTH];
    666 vfs_file_get_name( file_xp , name );
    667 thread_t * this = CURRENT_THREAD;
    668 uint32_t cycle = (uint32_t)hal_get_cycles();
    669 if( DEBUG_VFS_CLOSE < cycle )
    670 printk("\n[%s] thread[%x,%x] deleted file <%s> in cluster %x / cycle %d\n",
    671 __FUNCTION__, this->process->pid, this->trdid, name, file_cxy, cycle );
     725#if DEBUG_VFS_FILE_DESTROY
     726cycle = (uint32_t)hal_get_cycles();
     727if( DEBUG_VFS_FILE_DESTROY < cycle )
     728printk("\n[%s] thread[%x,%x] exit for <%s> / cycle %d\n",
     729__FUNCTION__, this->process->pid, this->trdid, file_ptr, file_cxy, name, cycle );
    672730#endif
    673731
    674732}  // end vfs_file_destroy()
    675 
    676 
    677 ////////////////////////////////////////
    678 void vfs_file_count_up( xptr_t file_xp )
    679 {
    680     // get file cluster and local pointer
    681     cxy_t        file_cxy = GET_CXY( file_xp );
    682     vfs_file_t * file_ptr = GET_PTR( file_xp );
    683 
    684     // atomically increment count
    685     hal_remote_atomic_add( XPTR( file_cxy , &file_ptr->refcount ) , 1 );
    686 }
    687 
    688 //////////////////////////////////////////
    689 void vfs_file_count_down( xptr_t file_xp )
    690 {
    691     // get file cluster and local pointer
    692     cxy_t        file_cxy = GET_CXY( file_xp );
    693     vfs_file_t * file_ptr = GET_PTR( file_xp );
    694 
    695     // atomically decrement count
    696     hal_remote_atomic_add( XPTR( file_cxy , &file_ptr->refcount ) , -1 );
    697 }
    698733
    699734///////////////////////////////////////
     
    755790    if( (flags & O_EXCL   )      )  lookup_mode |= VFS_LOOKUP_EXCL;
    756791 
     792#if DEBUG_VFS_OPEN || DEBUG_VFS_ERROR
     793uint32_t cycle = (uint32_t)hal_get_cycles();
     794#endif
     795
    757796#if DEBUG_VFS_OPEN
    758 uint32_t cycle = (uint32_t)hal_get_cycles();
    759797if( DEBUG_VFS_OPEN < cycle )
    760798printk("\n[%s] thread[%x,%x] enter for <%s> / root_inode (%x,%x) / cycle %d\n",
     
    791829    if( error )
    792830    {
    793         printk("\n[ERROR] in %s : cannot get inode <%s>\n",
    794         __FUNCTION__ , path );
     831
     832#if DEBUG_VFS_ERROR
     833if( DEBUG_VFS_ERROR < cycle )
     834printk("\n[ERROR] in %s : thread[%x,%x] cannot get inode <%s>\n",
     835__FUNCTION__ , process->pid, this->trdid , path );
     836#endif
    795837        return -1;
    796838    }
     
    824866    if( error ) return error;
    825867
     868    // get new file descriptor cluster and local pointer
     869    cxy_t        file_cxy = GET_CXY( file_xp );
     870    vfs_file_t * file_ptr = GET_PTR( file_xp );
     871
     872    //get file type
     873    uint32_t file_type = hal_remote_l32( XPTR( file_cxy , &file_ptr->type ));
     874
     875    // link the client thead to the pipe for a FIFO type
     876    if( file_type == FILE_TYPE_FIFO )
     877    {
     878        // get local pointer on attached pipe
     879        pipe_t * pipe = hal_remote_lpt( XPTR( file_cxy , &file_ptr->pipe ));
     880
     881        // build extended pointer on client thread
     882        xptr_t thread_xp = XPTR( local_cxy , this );
     883
     884        // update pipe descriptor
     885        if( flags & O_RDONLY ) hal_remote_s64( XPTR(file_cxy,&pipe->reader_xp) , thread_xp );
     886        if( flags & O_WRONLY ) hal_remote_s64( XPTR(file_cxy,&pipe->writer_xp) , thread_xp );
     887    }
     888
    826889#if DEBUG_VFS_OPEN
    827890cycle = (uint32_t)hal_get_cycles();
     
    849912    mapper_t         * mapper;         // local pointer on file mapper
    850913    vfs_inode_t      * inode;          // local pointer on file inode
    851     vfs_inode_type_t   type;           // inode type
     914    vfs_file_type_t   type;           // inode type
    852915    uint32_t           offset;         // current offset in file
    853916    uint32_t           size;           // current file size
     
    856919
    857920// check argument
    858 assert( (file_xp != XPTR_NULL), "file_xp == XPTR_NULL" );
     921assert( __FUNCTION__, (file_xp != XPTR_NULL), "file_xp == XPTR_NULL" );
    859922
    860923    // get cluster and local pointer on remote file descriptor
     
    870933   
    871934// check inode type
    872 assert( (type == INODE_TYPE_FILE), "bad inode type" );
     935assert( __FUNCTION__, (type == FILE_TYPE_REG), "bad inode type" );
     936
     937#if DEBUG_VFS_USER_MOVE || DEBUG_VFS_ERROR
     938uint32_t      cycle      = (uint32_t)hal_get_cycles();
     939thread_t    * this       = CURRENT_THREAD;
     940#endif
    873941
    874942#if DEBUG_VFS_USER_MOVE
    875943char          name[CONFIG_VFS_MAX_NAME_LENGTH];
    876 uint32_t      cycle      = (uint32_t)hal_get_cycles();
    877 thread_t    * this       = CURRENT_THREAD;
    878944vfs_inode_get_name( XPTR( file_cxy , inode ) , name );
    879945if( cycle > DEBUG_VFS_USER_MOVE )
     
    929995    if( error )
    930996    {
    931         printk("\n[ERROR] in %s : cannot move data", __FUNCTION__ );
     997
     998#if DEBUG_VFS_ERROR
     999if( DEBUG_VFS_ERROR < cycle )
     1000printk("\n[ERROR] in %s thread[%x,%x] cannot move data",
     1001__FUNCTION__, this->process->pid, this->trdid );
     1002#endif
    9321003        return -1;
    9331004    }
     
    9611032    cxy_t              file_cxy;     // remote file descriptor cluster
    9621033    vfs_file_t       * file_ptr;     // remote file descriptor local pointer
    963     vfs_inode_type_t   inode_type;   // remote file type
     1034    vfs_file_type_t   inode_type;   // remote file type
    9641035    uint32_t           file_offset;  // current offset in file
    9651036    mapper_t         * mapper_ptr;   // remote mapper local pointer
     
    9681039
    9691040// check argument
    970 assert( (file_xp != XPTR_NULL) , "file_xp == XPTR_NULL" );
     1041assert( __FUNCTION__, (file_xp != XPTR_NULL) , "file_xp == XPTR_NULL" );
    9711042
    9721043    // get cluster and local pointer on remote file descriptor
     
    9781049
    9791050// check inode type
    980 assert( (inode_type == INODE_TYPE_FILE), "bad file type" );
     1051assert( __FUNCTION__, (inode_type == FILE_TYPE_REG), "bad file type" );
    9811052
    9821053    // get mapper pointers and file offset from file descriptor
     
    10351106
    10361107// check arguments
    1037 assert( (file_xp != XPTR_NULL) , "file_xp == XPTR_NULL" );
    1038 assert( (new_offset != NULL )  , "new_offset == NULL" );
     1108assert( __FUNCTION__, (file_xp != XPTR_NULL) , "file_xp == XPTR_NULL" );
     1109assert( __FUNCTION__, (new_offset != NULL )  , "new_offset == NULL" );
    10391110
    10401111    // get cluster and local pointer on remote file descriptor
     
    11141185
    11151186// check argument
    1116 assert( (file_xp != XPTR_NULL) , "file_xp is XPTR_NULL" );
     1187assert( __FUNCTION__, (file_xp != XPTR_NULL) , "file_xp is XPTR_NULL" );
    11171188
    11181189    thread_t  * this    = CURRENT_THREAD;
     
    12411312        xptr_t entry_xp = XPTR( process_cxy , &process_ptr->fd_array.array[file_id] );
    12421313        hal_remote_s64( entry_xp , XPTR_NULL );
    1243         vfs_file_count_down( file_xp );
    12441314        hal_fence();
    12451315    }   
     
    13091379#endif
    13101380
    1311     // build extended pointer on lock protecting Inode Tree (in VFS root inode)
     1381    // build extended pointer on lock protecting Inode-Tree (in VFS root inode)
    13121382    vfs_root_xp  = process->vfs_root_xp;
    13131383    vfs_root_ptr = GET_PTR( vfs_root_xp );
     
    13981468
    13991469    // update inode "type" field
    1400     hal_remote_s32( XPTR( inode_cxy , &inode_ptr->type ) , INODE_TYPE_DIR );
     1470    hal_remote_s32( XPTR( inode_cxy , &inode_ptr->type ) , FILE_TYPE_DIR );
    14011471   
    14021472#if(DEBUG_VFS_MKDIR & 1)
     
    15761646
    15771647    ///////////////////////////////////////////////////////////////////////
    1578     if( (inode_type == INODE_TYPE_FILE) || (inode_type == INODE_TYPE_DIR) )
     1648    if( (inode_type == FILE_TYPE_REG) || (inode_type == FILE_TYPE_DIR) )
    15791649    {
    15801650        // 1. create one new dentry
     
    16661736    vfs_inode_t     * inode_ptr;          // target inode local pointer
    16671737    uint32_t          inode_links;        // target inode links count
    1668     vfs_inode_type_t  inode_type;         // target inode type
     1738    vfs_file_type_t  inode_type;         // target inode type
    16691739    uint32_t          inode_children;     // target inode number of children
    16701740    xptr_t            dentry_xp;          // extended pointer on dentry to unlink
     
    18051875
    18061876    ///////////////////////////////////////////////////////////////////////
    1807     if( (inode_type == INODE_TYPE_FILE) || (inode_type == INODE_TYPE_DIR) )
     1877    if( (inode_type == FILE_TYPE_REG) || (inode_type == FILE_TYPE_DIR) ) 
    18081878    {
    18091879
     
    18141884vfs_inode_type_str(inode_type), inode_links );
    18151885#endif
    1816 
    1817         // 1. Release clusters allocated to target inode
     1886        // 1. Release space allocated to inode on IOC device
    18181887        //    and synchronize the FAT on IOC device if last link.
    18191888        if( inode_links == 1 )
     
    18341903            }
    18351904
    1836             // release clusters on IOC device
     1905            // release space on IOC device
    18371906            error = vfs_fs_release_inode( inode_xp );
    18381907
     
    18691938__FUNCTION__, process->pid, this->trdid, path );
    18701939#endif
    1871         // 3. remove dentry from Inode Tree (and associated chils inode when last link)
     1940        // 3. remove dentry from Inode Tree (and associated child inode when last link)
    18721941        vfs_remove_child_from_parent( dentry_xp );
    18731942
     
    18761945
    18771946#if DEBUG_VFS_UNLINK
     1947if( DEBUG_VFS_UNLINK < cycle )
     1948printk("\n[%s] thread[%x,%x] exit / removed <%s> inode from Inode Tree / cycle %d\n",
     1949__FUNCTION__, process->pid, this->trdid, path, cycle );
     1950#endif
     1951        return 0;
     1952    }
     1953    ////////////////////////////////////////
     1954    else if( inode_type == FILE_TYPE_FIFO )
     1955    {
     1956        // 1. destroy the associated pipe
     1957        pipe_t * pipe    = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->pipe ));
     1958        pipe_destroy( XPTR( inode_cxy , pipe ) );
     1959
     1960#if(DEBUG_VFS_UNLINK & 1)
     1961if( DEBUG_VFS_UNLINK < cycle )
     1962printk("\n[%s] thread[%x,%x] released <%s> pipe\n",
     1963__FUNCTION__, process->pid, this->trdid, path );
     1964#endif
     1965
     1966        // 2. remove dentry from Inode Tree (and associated child inode when last link)
     1967        vfs_remove_child_from_parent( dentry_xp );
     1968
     1969        // release the lock protecting Inode Tree
     1970        remote_rwlock_wr_release( lock_xp );
     1971
     1972#if DEBUG_VFS_UNLINK
    18781973if( DEBUG_VFS_UNLINK < cycle )
    18791974printk("\n[%s] thread[%x,%x] exit / removed <%s> inode from Inode Tree / cycle %d\n",
     
    19752070    cxy_t             inode_cxy;          // target inode cluster identifier       
    19762071    vfs_inode_t     * inode_ptr;          // target inode local pointer
    1977     vfs_inode_type_t  inode_type;         // target inode type
     2072    vfs_file_type_t  inode_type;         // target inode type
    19782073    xptr_t            vfs_root_xp;        // extended pointer on VFS root inode
    19792074    vfs_inode_t     * vfs_root_ptr;       // local_pointer on VFS root inode
     
    20272122    inode_type = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->type ) );
    20282123
    2029     if( inode_type != INODE_TYPE_DIR )
     2124    if( inode_type != FILE_TYPE_DIR )
    20302125    {
    20312126        printk("\n[ERROR] in %s : <%s> is not a directory\n",
     
    20732168
    20742169// check lookup working mode
    2075 assert( (rights == 0), "access rights non implemented yet" );
     2170assert( __FUNCTION__, (rights == 0), "access rights non implemented yet" );
    20762171 
    20772172    // get extended pointer on target inode
     
    20932188    // TODO finalize implementation
    20942189
    2095 assert( false , "not implemented" );
     2190assert( __FUNCTION__, false , "not implemented" );
    20962191
    20972192    // set inode rights in remote inode
     
    20992194
    21002195    return 0;
    2101 }
    2102 
    2103 ///////////////////////////////////
    2104 error_t vfs_mkfifo( xptr_t   cwd_xp,
     2196
     2197}   // end vfs_chmod()
     2198
     2199/////////////////////////////////////
     2200error_t vfs_mkfifo( xptr_t   root_xp,
    21052201                    char   * path,
    2106                     uint32_t rights )
    2107 {
    2108     assert( false , "not implemented %l %x %x", cwd_xp, path, rights );
     2202                    uint32_t mode )
     2203{
     2204    error_t       error;
     2205    xptr_t        parent_inode_xp;         // extended pointer on parent inode in path
     2206    xptr_t        fifo_dentry_xp;          // extended pointer on created dentry
     2207    xptr_t        fifo_inode_xp;           // extended pointer on created inode
     2208    cxy_t         fifo_cxy;                // selected cluster for fifo inode
     2209
     2210    char          fifo_name[CONFIG_VFS_MAX_NAME_LENGTH];
     2211
     2212    thread_t    * this    = CURRENT_THREAD;
     2213    process_t   * process = this->process;
     2214
     2215    // build extended pointer on lock protecting Inode Tree
     2216    xptr_t        vfs_root_xp  = process->vfs_root_xp;
     2217    vfs_inode_t * vfs_root_ptr = GET_PTR( vfs_root_xp );
     2218    cxy_t         vfs_root_cxy = GET_CXY( vfs_root_xp );
     2219    xptr_t        vfs_lock_xp  = XPTR( vfs_root_cxy , &vfs_root_ptr->main_lock );
     2220
     2221    // take the lock protecting the Inode-Tree in write mode
     2222    remote_rwlock_wr_acquire( vfs_lock_xp );
     2223
     2224    // 1. get extended pointer on parent inode and fifo name from vfs
     2225    error = vfs_lookup( root_xp,
     2226                        path,
     2227                        VFS_LOOKUP_PARENT,
     2228                        &parent_inode_xp,
     2229                        fifo_name );
     2230    if( error )
     2231    {
     2232        printk("\n[ERROR] in %s : cannot get parent inode for <%s> path\n",
     2233        __FUNCTION__ , path );
     2234        return -1;
     2235    }
     2236
     2237    // get parent inode cluster and local pointer
     2238    cxy_t         parent_cxy = GET_CXY( parent_inode_xp );
     2239    vfs_inode_t * parent_ptr = GET_PTR( parent_inode_xp );
     2240
     2241    // 2. select a cluster for new fifo inode
     2242    fifo_cxy = cluster_random_select();
     2243
     2244    // get parent inode FS type
     2245    vfs_ctx_t    * ctx_ptr = hal_remote_lpt( XPTR( parent_cxy , &parent_ptr->ctx ) );
     2246    vfs_fs_type_t  fs_type = hal_remote_l32( XPTR( parent_cxy , &ctx_ptr->type ) );
     2247
     2248    // 3. insert a new inode and dentry in Inode-Tree
     2249    error = vfs_add_child_in_parent( fifo_cxy,
     2250                                     fs_type,
     2251                                     parent_inode_xp,
     2252                                     fifo_name,           
     2253                                     &fifo_dentry_xp,   
     2254                                     &fifo_inode_xp );
     2255   
     2256    // get fifo inode local pointer
     2257    vfs_inode_t * fifo_inode_ptr = GET_PTR( fifo_inode_xp );
     2258
     2259    if( error )
     2260    {
     2261        printk("\n[ERROR] in %s : cannot create fifo inode for <%s> path\n",
     2262        __FUNCTION__ , path );
     2263        return -1;
     2264    }
     2265
     2266    // 4. allocate memory for a pipe descriptor, for the
     2267    //    remote_buf_t descriptor, and for the associated data buffer
     2268    pipe_t * pipe = pipe_create( fifo_cxy,
     2269                                 CONFIG_PIPE_BUF_SIZE );
     2270    if( pipe == NULL )
     2271    {
     2272        printk("\n[ERROR] in %s : cannot create pipe for <%s> path\n",
     2273        __FUNCTION__ , path );
     2274        return -1;
     2275    }
     2276
     2277    // 5. update fifo_inode "type", "pipe", and "rights" fields
     2278    hal_remote_s32( XPTR( fifo_cxy , &fifo_inode_ptr->type ) , FILE_TYPE_FIFO );
     2279    hal_remote_s32( XPTR( fifo_cxy , &fifo_inode_ptr->rights ) , mode );
     2280    hal_remote_spt( XPTR( fifo_cxy , &fifo_inode_ptr->pipe ) , pipe   );
     2281
     2282    // release the lock protecting the Inode-Tree from write mode
     2283    remote_rwlock_wr_release( vfs_lock_xp );
     2284
    21092285    return 0;
    2110 }
     2286
     2287}   // end vfs_mkfifo()
    21112288
    21122289
     
    21262303    cxy_t              inode_cxy;
    21272304    vfs_inode_t      * inode_ptr;
    2128     vfs_inode_type_t   inode_type;
     2305    vfs_file_type_t   inode_type;
    21292306    uint32_t           inode_size;
    21302307    uint32_t           inode_attr;
     
    21592336                                        "                              " };  // level 15
    21602337
    2161 assert( (inode_xp != XPTR_NULL) , "inode_xp cannot be NULL" );
    2162 assert( (name_xp  != XPTR_NULL) , "name_xp cannot be NULL" );
    2163 assert( (indent < 16)           , "depth cannot be larger than 15" );
     2338assert( __FUNCTION__, (inode_xp != XPTR_NULL) , "inode_xp cannot be NULL" );
     2339assert( __FUNCTION__, (name_xp  != XPTR_NULL) , "name_xp cannot be NULL" );
     2340assert( __FUNCTION__, (indent < 16)           , "depth cannot be larger than 15" );
    21642341   
    21652342    // get current inode cluster and local pointer
     
    21872364    // scan directory entries when current inode is a directory
    21882365    // don't scan the the "." and ".." directories to break loops
    2189     if( (inode_type == INODE_TYPE_DIR) &&
     2366    if( (inode_type == FILE_TYPE_DIR) &&
    21902367        (strcmp( name , "." ) != 0)    &&
    21912368        (strcmp( name , ".." ) != 0) )
     
    24492626
    24502627// check pathname / root_xp consistency
    2451 assert( ((pathname[0] != '/') || (root_xp == process->vfs_root_xp)),
     2628assert( __FUNCTION__, ((pathname[0] != '/') || (root_xp == process->vfs_root_xp)),
    24522629"root inode must be VFS root for path <%s>", pathname );
    24532630
     2631#if DEBUG_VFS_LOOKUP || DEBUG_VFS_ERROR
     2632uint32_t cycle = (uint32_t)hal_get_cycles();
     2633#endif
     2634
    24542635#if DEBUG_VFS_LOOKUP
    2455 uint32_t cycle = (uint32_t)hal_get_cycles();
    24562636char     root_name[CONFIG_VFS_MAX_NAME_LENGTH];
    24572637vfs_inode_get_name( root_xp , root_name );
     
    25642744                if( error )
    25652745                {
    2566                     printk("\n[ERROR] in %s : cannot create inode <%s> in path <%s>\n",
    2567                     __FUNCTION__ , name, pathname );
     2746
     2747#if DEBUG_VFS_ERROR 
     2748if( DEBUG_VFS_ERROR < cycle )
     2749printk("\n[ERROR] in %s : thread[%x,%x] cannot create inode <%s> in path <%s>\n",
     2750__FUNCTION__ , process->pid, this->trdid, name, pathname );
     2751#endif
    25682752                    return -1;
    25692753                }
     
    25752759#if (DEBUG_VFS_LOOKUP & 1)
    25762760if( DEBUG_VFS_LOOKUP < cycle )
    2577 printk("\n[%s] thread[%x,%x] created missing inode <%s> in cluster %x\n",
     2761printk("\n[%s] thread[%x,%x] created dentry/inode <%s> in cluster %x\n",
    25782762__FUNCTION__, process->pid, this->trdid, name, child_cxy );
    25792763#endif
     
    25912775                        if ( error )
    25922776                        {
    2593                             printk("\n[ERROR] in %s : cannot add dentry <%s> in parent dir\n",
    2594                             __FUNCTION__, name );
     2777
     2778#if DEBUG_VFS_ERROR
     2779if( DEBUG_VFS_ERROR < cycle )
     2780printk("\n[ERROR] in %s : thread[%x,%x] cannot add dentry <%s> in parent dir\n",
     2781__FUNCTION__, process->pid, this->trdid, name );
     2782#endif
    25952783                            vfs_remove_child_from_parent( dentry_xp );
    25962784                            return -1;
     
    26012789printk("\n[%s] thread[%x,%x] child <%s> not found in parent mapper => created it\n",
    26022790__FUNCTION__, process->pid, this->trdid, name );
    2603 vfs_inode_display( child_xp );
    26042791#endif
    26052792                    }
    26062793                    else                   // not last or not create => error
    26072794                    {                       
    2608                         printk("\n[ERROR] in %s : <%s> node not found in parent for <%s>\n",
    2609                         __FUNCTION__ , name , pathname );
     2795
     2796#if DEBUG_VFS_ERROR     
     2797if( DEBUG_VFS_ERROR < cycle )
     2798printk("\n[ERROR] in %s : thread[%x,%x] cannot found node <%s> in parent for <%s>\n",
     2799__FUNCTION__ , process->pid, this->trdid, name, pathname );
     2800#endif
    26102801                        vfs_remove_child_from_parent( dentry_xp );
    26112802                        return -1;
     
    26172808                    if( last && create && excl )
    26182809                    {
    2619                         printk("\n[ERROR] in %s : node already exist <%s>\n",
    2620                         __FUNCTION__, name );
     2810
     2811#if DEBUG_VFS_ERROR
     2812if( DEBUG_VFS_ERROR < cycle )
     2813printk("\n[ERROR] in %s : thread[%x,%x] found an existing node <%s>  %\n",
     2814__FUNCTION__ , process->pid, this->trdid, pathname );
     2815#endif
    26212816                       return -1;
    26222817                    }
     
    26292824                    // load child mapper from device if child is a directory (prefetch)
    26302825                    uint32_t type = hal_remote_l32( XPTR( child_cxy , &child_ptr->type ) );
    2631                     if( type == INODE_TYPE_DIR )
     2826                    if( type == FILE_TYPE_DIR )
    26322827                    {
    26332828                        error = vfs_inode_load_all_pages( child_xp );
     
    26352830                        if ( error )
    26362831                        {
    2637                             printk("\n[ERROR] in %s : cannot load <%s> from device\n",
    2638                             __FUNCTION__ , name );
     2832#if DEBUG_VFS_ERROR
     2833if( DEBUG_VFS_ERROR < cycle )
     2834printk("\n[ERROR] in %s : thread[%x,%x] cannot load <%s> from device\n",
     2835__FUNCTION__ , process->pid, this->trdid, name );
     2836#endif
    26392837                            vfs_remove_child_from_parent( dentry_xp );
    26402838                            return -1;
     
    26642862            if( last && create && excl )
    26652863            {
    2666                 printk("\n[ERROR] in %s : node <%s> already exist\n",
    2667                 __FUNCTION__, name );
     2864
     2865#if DEBUG_VFS_ERROR
     2866if( DEBUG_VFS_ERROR < cycle )
     2867printk("\n[ERROR] in %s : thread[%x,%x] found an existing node <%s>\n",
     2868__FUNCTION__ , process->pid, this->trdid, pathname );
     2869#endif
    26682870                return -1;
    26692871            }
     
    26762878        // if( error )
    26772879        // {
    2678         //     printk("\n[ERROR] in %s : thread %x / permission denied for %s\n",
    2679         //     __FUNCTION__ , this , name );
    2680         //     return EACCES;
     2880        //     #if DEBUG_VFS_ERROR
     2881        //     if( DEBUG_VFS_ERROR < cycle )
     2882        //     printk("\n[ERROR] in %s : thread[%x,%x] / permission denied for <%s>\n",
     2883        //     __FUNCTION__ , process->pid, this->trdid , pathname );
     2884        //     #endif
     2885        //
     2886        //     return -1;
    26812887        // }
    26822888
     
    29833189
    29843190// check buffer overflow
    2985 assert( (index >= 0) , "kernel buffer too small" );
     3191assert( __FUNCTION__, (index >= 0) , "kernel buffer too small" );
    29863192
    29873193            }
     
    30093215
    30103216// check buffer overflow
    3011 assert( (index >= 0) , "kernel buffer too small" );
     3217assert( __FUNCTION__, (index >= 0) , "kernel buffer too small" );
    30123218
    30133219            // update pathname
     
    30673273    parent_inode_ptr = GET_PTR( parent_inode_xp );
    30683274
     3275#if DEBUG_VFS_ADD_CHILD || DEBUG_VFS_ERROR
     3276uint32_t cycle = (uint32_t)hal_get_cycles();
     3277thread_t * this = CURRENT_THREAD;
     3278#endif
     3279
    30693280#if DEBUG_VFS_ADD_CHILD
    30703281char parent_name[CONFIG_VFS_MAX_NAME_LENGTH];
    30713282vfs_inode_get_name( parent_inode_xp , parent_name );
    3072 uint32_t cycle = (uint32_t)hal_get_cycles();
    3073 thread_t * this = CURRENT_THREAD;
    30743283if( DEBUG_VFS_ADD_CHILD < cycle )
    30753284printk("\n[%s] thread[%x,%x] enter / child <%s> / parent <%s> / cycle %d\n",
     
    30853294    if( error )
    30863295    {
    3087         printk("\n[ERROR] in %s : cannot create dentry <%s> in cluster %x\n",
    3088         __FUNCTION__ , name , parent_cxy );
     3296
     3297#if DEBUG_VFS_ERROR
     3298if( DEBUG_VFS_ERROR < cycle )
     3299printk("\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 );
     3301#endif
    30893302        return -1;
    30903303    }
     
    31153328    if( error )
    31163329    {
    3117         printk("\n[ERROR] in %s : cannot create inode in cluster %x\n",
    3118                __FUNCTION__ , child_cxy );
     3330
     3331#if DEBUG_VFS_ERROR
     3332if( DEBUG_VFS_ERROR < cycle )
     3333printk("\n[ERROR] in %s : thread[%x,%x] cannot create inode in cluster %x\n",
     3334__FUNCTION__ , this->process->pid , this->trdid , child_cxy );
     3335#endif
    31193336 
    31203337        vfs_dentry_destroy( new_dentry_xp );
     
    31843401    vfs_inode_t  * parent_inode_ptr;   // local pointer on parent inode
    31853402    uint32_t       links;              // number of child inode parents
     3403    error_t        error;
     3404
     3405#if DEBUG_VFS_REMOVE_CHILD
     3406uint32_t   cycle = (uint32_t)hal_get_cycles();
     3407#endif
    31863408
    31873409    char dentry_name[CONFIG_VFS_MAX_NAME_LENGTH];
    31883410   
     3411    thread_t * this  = CURRENT_THREAD;
     3412
    31893413    // get parent cluster and dentry local pointer
    31903414    parent_cxy = GET_CXY( dentry_xp );
     
    32033427    child_inode_ptr  = GET_PTR( child_inode_xp );
    32043428
     3429#if DEBUG_VFS_REMOVE_CHILD
     3430if( DEBUG_VFS_REMOVE_CHILD < cycle )
     3431printk("\n[%s] thread[%x,%x] enter for dentry[%x,%x] / inode[%x,%x] / cycle %d\n",
     3432__FUNCTION__, this->process->pid, this->trdid,
     3433parent_cxy, dentry_ptr, child_cxy, child_inode_ptr, cycle );
     3434#endif
     3435
    32053436    // remove dentry from parent_inode
    3206     xhtab_remove( XPTR( parent_cxy , &parent_inode_ptr->children ),
    3207                   dentry_name,
    3208                   XPTR( parent_cxy , &dentry_ptr->children ) );
     3437    error = xhtab_remove( XPTR( parent_cxy , &parent_inode_ptr->children ),
     3438                          dentry_name,
     3439                          XPTR( parent_cxy , &dentry_ptr->children ) );
     3440
     3441    if( error )
     3442    {
     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
     3448cycle = (uint32_t)hal_get_cycles();
     3449if( DEBUG_VFS_REMOVE_CHILD < cycle )
     3450printk("\n[%s] thread[%x,%x] removed dentry from parent inode / cycle %d\n",
     3451__FUNCTION__, this->process->pid, this->trdid, cycle );
     3452#endif
    32093453
    32103454    // remove dentry from child_inode
    32113455    xlist_unlink( XPTR( parent_cxy , &dentry_ptr->parents ) );
     3456
     3457    // get and update number of parents dentries
    32123458    links = hal_remote_atomic_add( XPTR( child_cxy , &child_inode_ptr->links ) , -1 );
     3459
     3460#if DEBUG_VFS_REMOVE_CHILD
     3461cycle = (uint32_t)hal_get_cycles();
     3462if( DEBUG_VFS_REMOVE_CHILD < cycle )
     3463printk("\n[%s] thread[%x,%x] removed dentry from child inode / cycle %d\n",
     3464__FUNCTION__, this->process->pid, this->trdid, cycle );
     3465#endif
    32133466
    32143467    // delete dentry descriptor
    32153468    vfs_dentry_destroy( dentry_xp );
    32163469
     3470#if DEBUG_VFS_REMOVE_CHILD
     3471cycle = (uint32_t)hal_get_cycles();
     3472if( DEBUG_VFS_REMOVE_CHILD < cycle )
     3473printk("\n[%s] thread[%x,%x] deleted dentry descriptor / cycle %d\n",
     3474__FUNCTION__, this->process->pid, this->trdid, cycle );
     3475#endif
     3476
    32173477    // delete child_inode descriptor if last link
    3218     if( links == 1 )  vfs_inode_destroy( child_inode_xp );
    3219 
     3478    if( links == 1 )
     3479    {
     3480        vfs_inode_destroy( child_inode_xp );
     3481
     3482#if DEBUG_VFS_REMOVE_CHILD
     3483cycle = (uint32_t)hal_get_cycles();
     3484if( DEBUG_VFS_REMOVE_CHILD < cycle )
     3485printk("\n[%s] thread[%x,%x] deleted child inode descriptor / cycle %d\n",
     3486__FUNCTION__, this->process->pid, this->trdid, cycle );
     3487#endif
     3488
     3489    }
    32203490}  // end vfs_remove_child_from_parent()
    32213491
     
    32333503    error_t error = 0;
    32343504
    3235 assert( (inode_xp   != XPTR_NULL) , "inode_xp argument is NULL" );
    3236 assert( (dentry_ptr != NULL     ) , "dentry_ptr argument is NULL" );
     3505assert( __FUNCTION__, (inode_xp   != XPTR_NULL) , "inode_xp argument is NULL" );
     3506assert( __FUNCTION__, (dentry_ptr != NULL     ) , "dentry_ptr argument is NULL" );
    32373507
    32383508    vfs_inode_t * inode_ptr = GET_PTR( inode_xp );
     
    32423512    mapper_t * mapper = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->mapper ) );
    32433513
    3244 assert( (mapper != NULL) , "mapper pointer is NULL")       
     3514assert( __FUNCTION__, (mapper != NULL) , "mapper pointer is NULL");       
    32453515
    32463516    // get FS type
     
    32623532    else
    32633533    {
    3264         assert( false , "undefined file system type" );
     3534        assert( __FUNCTION__, false , "undefined file system type" );
    32653535    }
    32663536
     
    32753545    error_t error = 0;
    32763546
    3277 assert( (inode_xp   != XPTR_NULL) , "inode_xp argument is NULL" );
    3278 assert( (dentry_ptr != NULL     ) , "dentry_ptr argument is NULL" );
     3547assert( __FUNCTION__, (inode_xp   != XPTR_NULL) , "inode_xp argument is NULL" );
     3548assert( __FUNCTION__, (dentry_ptr != NULL     ) , "dentry_ptr argument is NULL" );
    32793549
    32803550    vfs_inode_t * inode_ptr = GET_PTR( inode_xp );
     
    32843554    mapper_t * mapper = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->mapper ) );
    32853555
    3286 assert( (mapper != NULL) , "mapper pointer is NULL")       
     3556assert( __FUNCTION__, (mapper != NULL) , "mapper pointer is NULL");       
    32873557
    32883558    // get FS type
     
    33053575    else
    33063576    {
    3307         assert( false , "undefined file system type" );
     3577        assert( __FUNCTION__, false , "undefined file system type" );
    33083578    }
    33093579
     
    33183588    error_t error = 0;
    33193589
    3320 assert( (inode_xp   != XPTR_NULL) , "inode_xp argument is NULL" );
    3321 assert( (dentry_ptr != NULL     ) , "dentry_ptr argument is NULL" );
     3590assert( __FUNCTION__, (inode_xp   != XPTR_NULL) , "inode_xp argument is NULL" );
     3591assert( __FUNCTION__, (dentry_ptr != NULL     ) , "dentry_ptr argument is NULL" );
    33223592
    33233593    vfs_inode_t * inode_ptr = GET_PTR( inode_xp );
     
    33273597    mapper_t * mapper = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->mapper ) );
    33283598
    3329 assert( (mapper != NULL) , "mapper pointer is NULL")       
     3599assert( __FUNCTION__, (mapper != NULL) , "mapper pointer is NULL");
    33303600
    33313601    // get FS type
     
    33393609    else if( fs_type == FS_TYPE_RAMFS )
    33403610    {
    3341         assert( false , "should not be called for RAMFS" );
     3611        assert( __FUNCTION__, false , "should not be called for RAMFS" );
    33423612    }
    33433613    else if( fs_type == FS_TYPE_DEVFS )
    33443614    {
    3345         assert( false , "should not be called for DEVFS" );
     3615        assert( __FUNCTION__, false , "should not be called for DEVFS" );
    33463616    }
    33473617    else
    33483618    {
    3349         assert( false , "undefined file system type" );
     3619        assert( __FUNCTION__, false , "undefined file system type" );
    33503620    }
    33513621
     
    33603630    error_t error = 0;
    33613631
    3362 assert( (inode_xp   != XPTR_NULL) , "inode_xp argument is NULL" );
    3363 assert( (dentry_ptr != NULL     ) , "dentry_ptr argument is NULL" );
     3632assert( __FUNCTION__, (inode_xp   != XPTR_NULL) , "inode_xp argument is NULL" );
     3633assert( __FUNCTION__, (dentry_ptr != NULL     ) , "dentry_ptr argument is NULL" );
    33643634
    33653635    vfs_inode_t * inode_ptr = GET_PTR( inode_xp );
     
    33693639    mapper_t * mapper = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->mapper ) );
    33703640
    3371 assert( (mapper != NULL) , "mapper pointer is NULL")       
     3641assert( __FUNCTION__, (mapper != NULL) , "mapper pointer is NULL");
    33723642
    33733643    // get FS type
     
    33813651    else if( fs_type == FS_TYPE_RAMFS )
    33823652    {
    3383         assert( false , "should not be called for RAMFS" );
     3653        assert( __FUNCTION__, false , "should not be called for RAMFS" );
    33843654    }
    33853655    else if( fs_type == FS_TYPE_DEVFS )
    33863656    {
    3387         assert( false , "should not be called for DEVFS" );
     3657        assert( __FUNCTION__, false , "should not be called for DEVFS" );
    33883658    }
    33893659    else
    33903660    {
    3391         assert( false , "undefined file system type" );
     3661        assert( __FUNCTION__, false , "undefined file system type" );
    33923662    }
    33933663
     
    34023672    error_t error = 0;
    34033673
    3404 assert( (inode_xp   != XPTR_NULL) , "inode_xp argument is NULL" );
    3405 assert( (dentry_ptr != NULL     ) , "dentry_ptr argument is NULL" );
     3674assert( __FUNCTION__, (inode_xp   != XPTR_NULL) , "inode_xp argument is NULL" );
     3675assert( __FUNCTION__, (dentry_ptr != NULL     ) , "dentry_ptr argument is NULL" );
    34063676
    34073677    vfs_inode_t * inode_ptr = GET_PTR( inode_xp );
     
    34113681    mapper_t * mapper = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->mapper ) );
    34123682
    3413 assert( (mapper != NULL) , "mapper pointer is NULL")       
     3683assert( __FUNCTION__, (mapper != NULL) , "mapper pointer is NULL");
    34143684
    34153685    // get FS type
     
    34233693    else if( fs_type == FS_TYPE_RAMFS )
    34243694    {
    3425         assert( false , "should not be called for RAMFS" );
     3695        assert( __FUNCTION__, false , "should not be called for RAMFS" );
    34263696    }
    34273697    else if( fs_type == FS_TYPE_DEVFS )
    34283698    {
    3429         assert( false , "should not be called for DEVFS" );
     3699        assert( __FUNCTION__, false , "should not be called for DEVFS" );
    34303700    }
    34313701    else
    34323702    {
    3433         assert( false , "undefined file system type" );
     3703        assert( __FUNCTION__, false , "undefined file system type" );
    34343704    }
    34353705
     
    34503720
    34513721// check arguments
    3452 assert( (inode != NULL) , "parent pointer is NULL");
    3453 assert( (array != NULL) , "child pointer is NULL");
    3454 assert( (detailed == false) , "detailed argument not supported\n");
     3722assert( __FUNCTION__, (inode != NULL) , "parent pointer is NULL");
     3723assert( __FUNCTION__, (array != NULL) , "child pointer is NULL");
     3724assert( __FUNCTION__, (detailed == false) , "detailed argument not supported\n");
    34553725
    34563726    // check inode type
    3457     if( inode->type != INODE_TYPE_DIR )
     3727    if( inode->type != FILE_TYPE_DIR )
    34583728    {
    34593729        printk("\n[ERROR] in %s : target inode is not a directory\n",
     
    34783748    else if( fs_type == FS_TYPE_RAMFS )
    34793749    {
    3480         assert( false , "should not be called for RAMFS" );
     3750        assert( __FUNCTION__, false , "should not be called for RAMFS" );
    34813751    }
    34823752    else if( fs_type == FS_TYPE_DEVFS )
     
    34923762    else
    34933763    {
    3494         assert( false , "undefined file system type" );
     3764        assert( __FUNCTION__, false , "undefined file system type" );
    34953765    }
    34963766
     
    35043774    error_t error = 0;
    35053775
    3506 assert( (inode_xp != XPTR_NULL) , "inode_xp argument is NULL");
     3776assert( __FUNCTION__, (inode_xp != XPTR_NULL) , "inode_xp argument is NULL");
    35073777
    35083778    vfs_inode_t * inode_ptr = GET_PTR( inode_xp );
     
    35123782    mapper_t * mapper = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->mapper ) );
    35133783
    3514 assert( (mapper != NULL) , "mapper pointer is NULL")       
     3784assert( __FUNCTION__, (mapper != NULL) , "mapper pointer is NULL");
    35153785
    35163786    // get FS type
     
    35243794    else if( fs_type == FS_TYPE_RAMFS )
    35253795    {
    3526         assert( false , "should not be called for RAMFS" );
     3796        assert( __FUNCTION__, false , "should not be called for RAMFS" );
    35273797    }
    35283798    else if( fs_type == FS_TYPE_DEVFS )
    35293799    {
    3530         assert( false , "should not be called for DEVFS" );
     3800        assert( __FUNCTION__, false , "should not be called for DEVFS" );
    35313801    }
    35323802    else
    35333803    {
    3534         assert( false , "undefined file system type" );
     3804        assert( __FUNCTION__, false , "undefined file system type" );
    35353805    }
    35363806
     
    35513821    else if( fs_type == FS_TYPE_RAMFS )
    35523822    {
    3553         assert( false , "should not be called for RAMFS" );
     3823        assert( __FUNCTION__, false , "should not be called for RAMFS" );
    35543824    }
    35553825    else if( fs_type == FS_TYPE_DEVFS )
    35563826    {
    3557         assert( false , "should not be called for DEVFS" );
     3827        assert( __FUNCTION__, false , "should not be called for DEVFS" );
    35583828    }
    35593829    else
    35603830    {
    3561         assert( false , "undefined file system type" );
     3831        assert( __FUNCTION__, false , "undefined file system type" );
    35623832    }
    35633833
     
    35713841    error_t error = 0;
    35723842
    3573 assert( (inode_xp  != XPTR_NULL) , "inode_xp argument is NULL")       
     3843assert( __FUNCTION__, (inode_xp  != XPTR_NULL) , "inode_xp argument is NULL");
    35743844
    35753845    vfs_inode_t * inode_ptr = GET_PTR( inode_xp );
     
    35793849    mapper_t * mapper = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->mapper ) );
    35803850
    3581 assert( (mapper != NULL) , "mapper pointer is NULL")       
     3851assert( __FUNCTION__, (mapper != NULL) , "mapper pointer is NULL");
    35823852
    35833853    // get FS type from mapper
     
    35913861    else if( fs_type == FS_TYPE_RAMFS )
    35923862    {
    3593         assert( false , "should not be called for RAMFS" );
     3863        assert( __FUNCTION__, false , "should not be called for RAMFS" );
    35943864    }
    35953865    else if( fs_type == FS_TYPE_DEVFS )
    35963866    {
    3597         assert( false , "should not be called for DEVFS" );
     3867        assert( __FUNCTION__, false , "should not be called for DEVFS" );
    35983868    }
    35993869    else
    36003870    {
    3601         assert( false , "undefined file system type" );
     3871        assert( __FUNCTION__, false , "undefined file system type" );
    36023872    }
    36033873
     
    36123882    error_t error = 0;
    36133883
    3614 assert( (page_xp != XPTR_NULL) , "page pointer is NULL" );
     3884assert( __FUNCTION__, (page_xp != XPTR_NULL) , "page pointer is NULL" );
    36153885
    36163886    page_t * page_ptr = GET_PTR( page_xp );
     
    36203890    mapper_t * mapper = hal_remote_lpt( XPTR( page_cxy , &page_ptr->mapper ) );
    36213891
    3622 assert( (mapper != NULL) , "no mapper for page" );
     3892assert( __FUNCTION__, (mapper != NULL) , "no mapper for page" );
    36233893
    36243894    // get FS type
     
    36323902    else if( fs_type == FS_TYPE_RAMFS )
    36333903    {
    3634         assert( false , "should not be called for RAMFS\n" );
     3904        assert( __FUNCTION__, false , "should not be called for RAMFS\n" );
    36353905    }
    36363906    else if( fs_type == FS_TYPE_DEVFS )
    36373907    {
    3638         assert( false , "should not be called for DEVFS\n" );
     3908        assert( __FUNCTION__, false , "should not be called for DEVFS\n" );
    36393909    }
    36403910    else
    36413911    {
    3642         assert( false , "undefined file system type" );
     3912        assert( __FUNCTION__, false , "undefined file system type" );
    36433913    }
    36443914
  • trunk/kernel/fs/vfs.h

    r657 r673  
    33 *
    44 * Author  Mohamed Lamine Karaoui (2014,2015)
    5  *         Alain Greiner (2016,2017,2018,2019,2020)
     5 *         Alain Greiner          (2016,2017,2018,2019,2020)
    66 *
    77 * Copyright (c) UPMC Sorbonne Universites
     
    4949struct vfs_ctx_s;
    5050struct vfs_file_s;
    51 
     51struct remote_buf_s;
    5252struct mapper_s;
    5353struct process_s;
     
    6666#define VFS_LOOKUP_CREATE   0x10     /* file must be created if missing                  */
    6767#define VFS_LOOKUP_EXCL     0x20     /* file cannot previously exist                     */
     68
     69
     70
    6871
    6972/******************************************************************************************
     
    105108}
    106109vfs_ctx_t;
     110
     111/******************************************************************************************
     112 *        These functions access / modify  a VFS context.
     113 *****************************************************************************************/
     114
     115/******************************************************************************************
     116 * This function initialises a (statically allocated) VFS context in cluster identified
     117 * by the <cxy> argument.
     118 * It is called by the kernel_init() function.
     119 ******************************************************************************************
     120 * @ cxy            : target cluster identifier.
     121 * @ fs_type        : file system type.
     122 * @ total_clusters : total number of clusters on device.
     123 * @ cluster_size   : cluster size on device (bytes).
     124 * @ vfs_root_xp    : extended pointer on VFS root inode.
     125 * @ extend         : fs_type_specific extension.
     126 *****************************************************************************************/
     127void vfs_ctx_init( cxy_t           cxy,
     128                   vfs_fs_type_t   type,
     129                       uint32_t        total_clusters,
     130                       uint32_t        cluster_size,
     131                       xptr_t          vfs_root_xp,
     132                   void          * extend );
     133
     134/******************************************************************************************
     135 * This function allocates an inode identifier from the local cluster inum allocator.
     136 * The inum respects a fixed format:
     137 * - the 16 MSB bits contain the cluster identifier : cxy
     138 * - the 16 LSB bits contains the local inode identifier  : lid
     139 ******************************************************************************************
     140 * @ ctx_xp   : [in]  extended pointer on file system context.
     141 * @ inum     : [out] buffer for allocated inode identifier.
     142 * @ return 0 if success / return non-zero if error.
     143 *****************************************************************************************/
     144error_t vfs_ctx_inum_alloc( xptr_t     ctx_xp,
     145                            uint32_t * inum );
     146
     147/******************************************************************************************
     148 * This function release an inode identifier.                                 
     149 ******************************************************************************************
     150 * @ ctx_xp   : [in] extended pointer on file system context.
     151 * @ inum     : [in] released inode identifier.
     152 *****************************************************************************************/
     153void vfs_ctx_inum_release( xptr_t      ctx_xp,
     154                           uint32_t    inum );
     155
     156
     157
     158
     159
     160
     161/******************************************************************************************
     162 * This file structure describes an open file/directory for a given process.
     163 * It is not replicated, and is dynamically allocated in the cluster that contains
     164 * the associated inode / socket / pipe , when a thread makes an open(), opendir(),
     165 * socket(), or pipe() system call. It cannot exist a <file> structure without a
     166 * a <mapper>, <socket>, or <pipe> structure (depending on type) in same cluster.
     167 * It can exist a <file> structure without an <inode> (for PIPE and SOCK types).
     168 *****************************************************************************************/
     169
     170/* this enum define the VFS inode types values                                           */
     171/* WARNING : this enum must be kept consistent with macros in <shared_stat.h> file       */
     172/*           and with types in <shared_dirent.h> file.                                   */
     173
     174typedef enum   
     175{
     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                                */
     184}
     185vfs_file_type_t;
     186
     187typedef enum
     188{
     189    FD_ATTR_READ_ENABLE    = 0x01,     /*! read access possible                          */
     190    FD_ATTR_WRITE_ENABLE   = 0x02,     /*! write access possible                         */
     191    FD_ATTR_APPEND         = 0x04,     /*! append on each write                          */
     192    FD_ATTR_CLOSE_EXEC     = 0x08,     /*! close file on exec                            */
     193    FD_ATTR_SYNC           = 0x10,     /*! synchronise FS on each write                  */
     194    FD_ATTR_IS_DIR         = 0x20,     /*! this is a directory                           */
     195}
     196vfs_file_attr_t;
     197
     198typedef struct vfs_file_s
     199{
     200        struct vfs_ctx_s      * ctx;        /*! local pointer on FS context.                 */
     201        vfs_file_attr_t         attr;       /*! file attributes bit vector (see above)       */
     202        vfs_file_type_t        type;       /*! same type as inode                           */
     203        uint32_t                offset;     /*! seek position in file                        */
     204        remote_rwlock_t         lock;       /*! protect offset modifications                 */
     205        struct vfs_inode_s    * inode;      /*! local pointer on associated inode            */
     206        struct mapper_s       * mapper;     /*! associated mapper (REG or DIR types only)    */
     207    struct socket_s       * socket;     /*! associated socket (SOCK type only)           */
     208    struct pipe_s         * pipe;       /*! associated pipe (FIFO or PIPE types only)    */
     209        void                  * extend;     /*! FS specific extension                        */
     210}
     211vfs_file_t;
     212
     213/******************************************************************************************
     214 *        These low-level functions access / modify a VFS file descriptor
     215 *****************************************************************************************/
     216
     217/******************************************************************************************
     218 * This function allocates memory and initializes a new file descriptor in the
     219 * cluster defined by the <inode_xp> argument.
     220 * It can be called by any thread running in any cluster.
     221 ******************************************************************************************
     222 * @ inode_xp  : [in]  extended pointer on associated inode.
     223 * @ attr      : [in]  file descriptor attributes.
     224 * @ file_xp   : [out] buffer for extended pointer on created file descriptor.
     225 * @ return 0 if success / return ENOMEM if error.
     226 *****************************************************************************************/
     227error_t vfs_file_create( xptr_t        inode_xp,
     228                         uint32_t      attr,
     229                         xptr_t      * file_xp ); 
     230
     231/******************************************************************************************
     232 * This function releases memory allocated to file descriptor identified
     233 * by the <file_xp> argument.
     234 * It can be called by any thread running in any cluster.
     235 ******************************************************************************************
     236 * @ file_xp  : [in] extended pointer on file descriptor.
     237 *****************************************************************************************/
     238void vfs_file_destroy( xptr_t  file_xp ); 
     239
     240/******************************************************************************************
     241 * This debug function copies the name of a the file identified by <file_xp>
     242 * argument to a local buffer identified by the <name> argument.
     243 * The local buffer size must be at least CONFIG_VFS_MAX_NAME_LENGTH.
     244 *****************************************************************************************
     245 * @ ionde_xp  : [in] extended pointer on the remote inode.
     246 * @ name      : [out] local string.
     247 ***************************************************************************************/
     248void vfs_file_get_name( xptr_t inode_xp,
     249                        char * name );
     250
     251
     252
    107253
    108254/******************************************************************************************
     
    124270 *****************************************************************************************/
    125271
    126 /* this enum define the VFS inode types values                                           */
    127 /* WARNING : this enum must be kept consistent with macros in <shared_stat.h> file       */
    128 /*           and with types in <shared_dirent.h> file.                                   */
    129 
    130 typedef enum   
    131 {
    132     INODE_TYPE_FILE  =     0,           /*! regular file                                 */
    133     INODE_TYPE_DIR   =     1,           /*! directory                                    */
    134     INODE_TYPE_FIFO  =     2,           /*! POSIX named pipe                             */
    135     INODE_TYPE_PIPE  =     3,           /*! POSIX anonymous pipe                         */
    136     INODE_TYPE_SOCK  =     4,           /*! POSIX socket                                 */
    137     INODE_TYPE_DEV   =     5,           /*! character device                             */
    138     INODE_TYPE_BLK   =     6,           /*! block device                                 */
    139     INODE_TYPE_SYML  =     7,           /*! symbolic link                                */
    140 }
    141 vfs_inode_type_t;
    142 
    143272/* this enum define the VFS inode attributes values */
    144273
     
    153282typedef struct vfs_inode_s
    154283{
    155     struct vfs_ctx_s * ctx;              /*! local pointer on FS context                 */
    156     uint32_t           inum;             /*! inode identifier (unique in file system)    */
    157     uint32_t           attr;             /*! inode attributes (see above)                */
    158     vfs_inode_type_t   type;             /*! inode type (see above)                      */
    159     uint32_t           size;             /*! number of bytes                             */
    160     uint32_t           uid;              /*! user owner identifier                       */
    161     uint32_t           gid;              /*! group owner identifier                      */
    162     uint32_t           rights;           /*! access rights                               */
    163     xlist_entry_t      parents;          /*! root of list of parents dentries            */
    164     uint32_t           links;            /*! number of parent dentries (hard links)      */
    165     xhtab_t            children;         /*! embedded xhtab of children dentries         */
    166     remote_rwlock_t    size_lock;        /*! protect read/write to size                  */
    167     remote_rwlock_t    main_lock;        /*! protect inode tree traversal and modifs     */
    168     struct mapper_s  * mapper;           /*! associated file cache                       */
    169     void             * extend;           /*! fs_type_specific inode extension            */
     284    struct vfs_ctx_s    * ctx;           /*! local pointer on FS context                 */
     285    uint32_t              inum;          /*! inode identifier (unique in file system)    */
     286    uint32_t              attr;          /*! inode attributes (see above)                */
     287    vfs_file_type_t      type;          /*! inode type (see above)                      */
     288    uint32_t              size;          /*! number of bytes                             */
     289    uint32_t              uid;           /*! user owner identifier                       */
     290    uint32_t              gid;           /*! group owner identifier                      */
     291    uint32_t              rights;        /*! access rights                               */
     292    xlist_entry_t         parents;       /*! root of list of parents dentries            */
     293    uint32_t              links;         /*! number of parent dentries (hard links)      */
     294    xhtab_t               children;      /*! embedded xhtab of children dentries         */
     295    remote_rwlock_t       size_lock;     /*! protect read/write to size                  */
     296    remote_rwlock_t       main_lock;     /*! protect inode tree traversal and modifs     */
     297    struct mapper_s     * mapper;        /*! associated file (REG or DIR types only)     */
     298    struct remote_buf_s * pipe;          /*! associated pipe (FIFO type only)            */
     299    void                * extend;        /*! fs_type_specific inode extension            */
    170300}
    171301vfs_inode_t;
     
    191321#define VFS_IWOTH      0x0000002
    192322#define VFS_IXOTH      0x0000001
     323
     324/******************************************************************************************
     325 *        These low-level functions access / modify a VFS inode descriptor
     326 *****************************************************************************************/
     327
     328/******************************************************************************************
     329 * This function returns a printable string for the inode type.
     330 *****************************************************************************************/
     331const char * vfs_inode_type_str( vfs_file_type_t type );
     332
     333/******************************************************************************************
     334 * This function allocates memory in cluster identified by the <cxy> argument
     335 * for an inode descriptor and for the associated mapper, and partially initialise
     336 * this inode from arguments values.
     337 * It does NOT link it to the Inode Tree, as this is done by add_child_in_parent().
     338 * It can be called by any thread running in any cluster.
     339 ******************************************************************************************
     340 * @ cxy        : [in]  target cluster identifier
     341 * @ fs_type    : [in]  file system type.
     342 * @ attr       : [in]  inode attributes.
     343 * @ rights     : [in]  inode access rights.
     344 * @ uid        : [in]  user owner ID.
     345 * @ gid        : [in]  group owner ID.
     346 * @ inode_xp   : [out] buffer for extended pointer on created inode.
     347 * @ return 0 if success / return -1 if error.
     348 *****************************************************************************************/
     349error_t vfs_inode_create( cxy_t             cxy,
     350                          vfs_fs_type_t     fs_type,
     351                          uint32_t          attr,
     352                          uint32_t          rights,
     353                          uid_t             uid,
     354                          gid_t             gid,
     355                          xptr_t          * inode_xp );
     356
     357/******************************************************************************************
     358 * This function releases memory allocated to an inode descriptor, including
     359 * all memory allocated to the mapper (both mapper descriptor and radix tree).
     360 * The mapper should not contain any dirty page (should be synchronized before deletion).
     361 * It can be called by any thread running in any cluster.
     362 ******************************************************************************************
     363 * @ inode_xp  : extended pointer on inode descriptor.
     364 *****************************************************************************************/
     365void vfs_inode_destroy( xptr_t  inode_xp ); 
     366
     367/******************************************************************************************
     368 * This function returns the <size> of a file/dir from a remote inode,
     369 * taking the remote_rwlock protecting <size> in READ_MODE.
     370 * It can be called by any thread running in any cluster.
     371 *****************************************************************************************
     372 * @ inode_xp  : extended pointer on the remote inode.
     373 * @ return the current size.
     374 *****************************************************************************************/
     375uint32_t vfs_inode_get_size( xptr_t inode_xp );
     376
     377/******************************************************************************************
     378 * This function updates the "size" field of a remote inode identified by <inode_xp>.
     379 * It takes the rwlock protecting the file size in WRITE_MODE, and set the "size" field
     380 * when the current size is smaller than the requested <size> argument.
     381 * It can be called by any thread running in any cluster.
     382 *****************************************************************************************
     383 * @ inode_xp  : extended pointer on the remote inode.
     384 * @ size      : requested size value.
     385 *****************************************************************************************/
     386void vfs_inode_update_size( xptr_t   inode_xp,
     387                            uint32_t size );
     388
     389/******************************************************************************************
     390 * This function takes the main lock of a remote inode identified by the <inode_xp>.
     391 * This lock protect all inode fields, including the children dentries.
     392 * It can be called by any thread running in any cluster.
     393 *****************************************************************************************
     394 * @ inode_xp  : extended pointer on the remote inode.
     395 *****************************************************************************************/
     396void vfs_inode_lock( xptr_t inode_xp );
     397
     398/******************************************************************************************
     399 * This function releases the main lock of a remote inode identified by <inode_xp>.
     400 * This lock protect all inode fiels, including the children dentries.
     401 * It can be called by any thread running in any cluster.
     402 *****************************************************************************************
     403 * @ inode_xp  : extended pointer on the remote inode.
     404 *****************************************************************************************/
     405void vfs_inode_unlock( xptr_t inode_xp );
     406
     407/******************************************************************************************
     408 * This debug function copies the name of a remote inode identified by the <inode_xp>
     409 * argument to a local buffer identified by the <name> argument.
     410 * The local buffer size must be at least CONFIG_VFS_MAX_NAME_LENGTH.
     411 * It can be called by any thread running in any cluster.
     412 ******************************************************************************************
     413 * @ inode_xp  : extended pointer on the remote inode.
     414 * @ name      : local buffer pointer.
     415 *****************************************************************************************/
     416void vfs_inode_get_name( xptr_t inode_xp,
     417                         char * name );
     418
     419/******************************************************************************************
     420 * This function accesses successively all pages of a file identified by the <inode_xp>,
     421 * argument, to force misses, and load all pages into mapper.
     422 * The target inode can be a directory or a file, but this function is mainly used
     423 * to prefetch a complete directory to the mapper.
     424 * This function does NOT take any lock.
     425 * It can be called by any thread running in any cluster.
     426 ******************************************************************************************
     427 * @ inode_xp  : extended pointer on inode.
     428 * @ return 0 if success / return -1 if device access failure.
     429 *****************************************************************************************/
     430error_t vfs_inode_load_all_pages( xptr_t inode_xp );
     431
     432/******************************************************************************************
     433 * This debug function display the curren state of an inode descriptor.
     434 * It can be called by any thread running in any cluster.
     435 *****************************************************************************************/
     436void vfs_inode_display( xptr_t inode_xp );
     437
     438
     439
     440
     441
    193442
    194443/******************************************************************************************
     
    215464
    216465/******************************************************************************************
    217  * This file structure describes an open file/directory for a given process.
    218  * It is not replicated, and is dynamically allocated in the cluster that contains
    219  * the inode, when a thread makes an open() or opendir() system call.
    220  * It cannot exist a file structure without an inode structure in same cluster.
    221  * As the fd_array (containing extended pointers on the open file descriptors)
    222  * is replicated in all process descriptors, we need a references counter.
    223  *****************************************************************************************/
    224 
    225 typedef enum
    226 {
    227     FD_ATTR_READ_ENABLE    = 0x01,     /*! read access possible                          */
    228     FD_ATTR_WRITE_ENABLE   = 0x02,     /*! write access possible                         */
    229     FD_ATTR_APPEND         = 0x04,     /*! append on each write                          */
    230     FD_ATTR_CLOSE_EXEC     = 0x08,     /*! close file on exec                            */
    231     FD_ATTR_SYNC           = 0x10,     /*! synchronise FS on each write                  */
    232     FD_ATTR_IS_DIR         = 0x20,     /*! this is a directory                           */
    233 }
    234 vfs_file_attr_t;
    235 
    236 typedef struct vfs_file_s
    237 {
    238         struct vfs_ctx_s      * ctx;        /*! local pointer on FS context.                 */
    239         vfs_file_attr_t         attr;       /*! file attributes bit vector (see above)       */
    240         vfs_inode_type_t        type;       /*! same type as inode                           */
    241         uint32_t                offset;     /*! seek position in file                        */
    242         uint32_t                refcount;   /*! all pointers on this file descriptor         */
    243         remote_rwlock_t         lock;       /*! protect offset modifications                 */
    244         struct mapper_s       * mapper;     /*! associated file cache                        */
    245         struct vfs_inode_s    * inode;      /*! local pointer on associated inode            */
    246     struct socket_s       * socket;     /*! local pointer on associated socket           */
    247         void                  * extend;     /*! FS specific extension                        */
    248 }
    249 vfs_file_t;
    250 
    251 
    252 /******************************************************************************************
    253  *        These functions access / modify  a VFS context.
    254  *****************************************************************************************/
    255 
    256 /******************************************************************************************
    257  * This function initialises a (statically allocated) VFS context in cluster identified
    258  * by the <cxy> argument.
    259  * It is called by the kernel_init() function.
    260  ******************************************************************************************
    261  * @ cxy            : target cluster identifier.
    262  * @ fs_type        : file system type.
    263  * @ total_clusters : total number of clusters on device.
    264  * @ cluster_size   : cluster size on device (bytes).
    265  * @ vfs_root_xp    : extended pointer on VFS root inode.
    266  * @ extend         : fs_type_specific extension.
    267  *****************************************************************************************/
    268 void vfs_ctx_init( cxy_t           cxy,
    269                    vfs_fs_type_t   type,
    270                        uint32_t        total_clusters,
    271                        uint32_t        cluster_size,
    272                        xptr_t          vfs_root_xp,
    273                    void          * extend );
    274 
    275 /******************************************************************************************
    276  * This function allocates an inode identifier from the local cluster inum allocator.
    277  * The inum respects a fixed format:
    278  * - the 16 MSB bits contain the cluster identifier : cxy
    279  * - the 16 LSB bits contains the local inode identifier  : lid
    280  ******************************************************************************************
    281  * @ ctx_xp   : [in]  extended pointer on file system context.
    282  * @ inum     : [out] buffer for allocated inode identifier.
    283  * @ return 0 if success / return non-zero if error.
    284  *****************************************************************************************/
    285 error_t vfs_ctx_inum_alloc( xptr_t     ctx_xp,
    286                             uint32_t * inum );
    287 
    288 /******************************************************************************************
    289  * This function release an inode identifier.                                 
    290  ******************************************************************************************
    291  * @ ctx_xp   : [in] extended pointer on file system context.
    292  * @ inum     : [in] released inode identifier.
    293  *****************************************************************************************/
    294 void vfs_ctx_inum_release( xptr_t      ctx_xp,
    295                            uint32_t    inum );
    296 
    297 
    298 
    299 /******************************************************************************************
    300  *        These low-level functions access / modify a VFS inode descriptor
    301  *****************************************************************************************/
    302 
    303 /******************************************************************************************
    304  * This function returns a printable string for the inode type.
    305  *****************************************************************************************/
    306 const char * vfs_inode_type_str( vfs_inode_type_t type );
    307 
    308 /******************************************************************************************
    309  * This function allocates memory in cluster identified by the <cxy> argument
    310  * for an inode descriptor and for the associated mapper, and partially initialise
    311  * this inode from arguments values.
    312  * It does NOT link it to the Inode Tree, as this is done by add_child_in_parent().
    313  * It can be called by any thread running in any cluster.
    314  ******************************************************************************************
    315  * @ cxy        : [in]  target cluster identifier
    316  * @ fs_type    : [in]  file system type.
    317  * @ attr       : [in]  inode attributes.
    318  * @ rights     : [in]  inode access rights.
    319  * @ uid        : [in]  user owner ID.
    320  * @ gid        : [in]  group owner ID.
    321  * @ inode_xp   : [out] buffer for extended pointer on created inode.
    322  * @ return 0 if success / return -1 if error.
    323  *****************************************************************************************/
    324 error_t vfs_inode_create( cxy_t             cxy,
    325                           vfs_fs_type_t     fs_type,
    326                           uint32_t          attr,
    327                           uint32_t          rights,
    328                           uid_t             uid,
    329                           gid_t             gid,
    330                           xptr_t          * inode_xp );
    331 
    332 /******************************************************************************************
    333  * This function releases memory allocated to an inode descriptor, including
    334  * all memory allocated to the mapper (both mapper descriptor and radix tree).
    335  * The mapper should not contain any dirty page (should be synchronized before deletion).
    336  * It can be called by any thread running in any cluster.
    337  ******************************************************************************************
    338  * @ inode_xp  : extended pointer on inode descriptor.
    339  *****************************************************************************************/
    340 void vfs_inode_destroy( xptr_t  inode_xp ); 
    341 
    342 /******************************************************************************************
    343  * This function returns the <size> of a file/dir from a remote inode,
    344  * taking the remote_rwlock protecting <size> in READ_MODE.
    345  * It can be called by any thread running in any cluster.
    346  *****************************************************************************************
    347  * @ inode_xp  : extended pointer on the remote inode.
    348  * @ return the current size.
    349  *****************************************************************************************/
    350 uint32_t vfs_inode_get_size( xptr_t inode_xp );
    351 
    352 /******************************************************************************************
    353  * This function updates the "size" field of a remote inode identified by <inode_xp>.
    354  * It takes the rwlock protecting the file size in WRITE_MODE, and set the "size" field
    355  * when the current size is smaller than the requested <size> argument.
    356  * It can be called by any thread running in any cluster.
    357  *****************************************************************************************
    358  * @ inode_xp  : extended pointer on the remote inode.
    359  * @ size      : requested size value.
    360  *****************************************************************************************/
    361 void vfs_inode_update_size( xptr_t   inode_xp,
    362                             uint32_t size );
    363 
    364 /******************************************************************************************
    365  * This function takes the main lock of a remote inode identified by the <inode_xp>.
    366  * This lock protect all inode fields, including the children dentries.
    367  * It can be called by any thread running in any cluster.
    368  *****************************************************************************************
    369  * @ inode_xp  : extended pointer on the remote inode.
    370  *****************************************************************************************/
    371 void vfs_inode_lock( xptr_t inode_xp );
    372 
    373 /******************************************************************************************
    374  * This function releases the main lock of a remote inode identified by <inode_xp>.
    375  * This lock protect all inode fiels, including the children dentries.
    376  * It can be called by any thread running in any cluster.
    377  *****************************************************************************************
    378  * @ inode_xp  : extended pointer on the remote inode.
    379  *****************************************************************************************/
    380 void vfs_inode_unlock( xptr_t inode_xp );
    381 
    382 /******************************************************************************************
    383  * This debug function copies the name of a remote inode identified by the <inode_xp>
    384  * argument to a local buffer identified by the <name> argument.
    385  * The local buffer size must be at least CONFIG_VFS_MAX_NAME_LENGTH.
    386  * It can be called by any thread running in any cluster.
    387  ******************************************************************************************
    388  * @ inode_xp  : extended pointer on the remote inode.
    389  * @ name      : local buffer pointer.
    390  *****************************************************************************************/
    391 void vfs_inode_get_name( xptr_t inode_xp,
    392                          char * name );
    393 
    394 /******************************************************************************************
    395  * This function accesses successively all pages of a file identified by the <inode_xp>,
    396  * argument, to force misses, and load all pages into mapper.
    397  * The target inode can be a directory or a file, but this function is mainly used
    398  * to prefetch a complete directory to the mapper.
    399  * This function does NOT take any lock.
    400  * It can be called by any thread running in any cluster.
    401  ******************************************************************************************
    402  * @ inode_xp  : extended pointer on inode.
    403  * @ return 0 if success / return -1 if device access failure.
    404  *****************************************************************************************/
    405 error_t vfs_inode_load_all_pages( xptr_t inode_xp );
    406 
    407 /******************************************************************************************
    408  * This debug function display the curren state of an inode descriptor.
    409  * It can be called by any thread running in any cluster.
    410  *****************************************************************************************/
    411 void vfs_inode_display( xptr_t inode_xp );
    412 
    413 /******************************************************************************************
    414466 *        These low-level functions access / modify a VFS dentry descriptor
    415467 *****************************************************************************************/
     
    442494
    443495
    444 /******************************************************************************************
    445  *        These low-level functions access / modify a VFS file descriptor
    446  *****************************************************************************************/
    447 
    448 /******************************************************************************************
    449  * This function allocates memory and initializes a new file descriptor in the
    450  * cluster defined by the <inode_xp> argument.
    451  * It can be called by any thread running in any cluster.
    452  ******************************************************************************************
    453  * @ inode_xp  : [in]  extended pointer on associated inode.
    454  * @ attr      : [in]  file descriptor attributes.
    455  * @ file_xp   : [out] buffer for extended pointer on created file descriptor.
    456  * @ return 0 if success / return ENOMEM if error.
    457  *****************************************************************************************/
    458 error_t vfs_file_create( xptr_t        inode_xp,
    459                          uint32_t      attr,
    460                          xptr_t      * file_xp ); 
    461 
    462 /******************************************************************************************
    463  * This function releases memory allocated to file descriptor identified
    464  * by the <file_xp> argument.
    465  * It can be called by any thread running in any cluster.
    466  ******************************************************************************************
    467  * @ file_xp  : [in] extended pointer on file descriptor.
    468  *****************************************************************************************/
    469 void vfs_file_destroy( xptr_t  file_xp ); 
    470 
    471 /******************************************************************************************
    472  * These functions increment (resp. decrement) the count field in a remote file
    473  * descriptor, using a remote_atomic access.
    474  *****************************************************************************************
    475  * @ file_xp  : extended pointer on file descriptor.
    476  *****************************************************************************************/
    477 void vfs_file_count_up  ( xptr_t   file_xp );
    478 void vfs_file_count_down( xptr_t   file_xp );
    479 
    480 /******************************************************************************************
    481  * This debug function copies the name of a the file identified by <file_xp>
    482  * argument to a local buffer identified by the <name> argument.
    483  * The local buffer size must be at least CONFIG_VFS_MAX_NAME_LENGTH.
    484  *****************************************************************************************
    485  * @ ionde_xp  : [in] extended pointer on the remote inode.
    486  * @ name      : [out] local string.
    487  ***************************************************************************************/
    488 void vfs_file_get_name( xptr_t inode_xp,
    489                         char * name );
     496
     497
    490498
    491499
     
    532540 *   the missing dentry/inode couple, from informations found in the parent directory.
    533541 * - If this directory entry does not exist on IOC, it returns an error.
    534  * - If the the file identified by the pathname does not exist on IOC but the
     542 * - If the file identified by the pathname does not exist on IOC but the
    535543 *   flag CREATE is set, the inode is created. It returns an error otherwise.
    536544 * - If the the file identified by the pathname exist on device, but both flags EXCL
     
    539547 *   inode, and copies in <last_name> buffer a string containing the last name in path.
    540548 *
    541  * WARNING : The remote_rwlock protecting the Inode Tree must be taken by the caller.
     549 * WARNING : The lock protecting the Inode Tree must be taken in read mode by the caller.
    542550 *
    543551 * TODO the access rights are not checked yet.
     
    558566/******************************************************************************************
    559567 * This function creates a new couple dentry/inode, and insert it in the Inode-Tree.
    560  * Only the distributed Inode Tree is modified: it does NOT modify the parent mapper,
     568 * Only the distributed Inode-Tree is modified: it does NOT modify the parent mapper,
    561569 * and does NOT update the FS on IOC device.
    562  * It set the inode type to the default INODE_TYPE_FILE value
     570 * It set the inode type to the default FILE_TYPE_REG value.
    563571 * It can be executed by any thread running in any cluster (can be different from both
    564572 * the child cluster and the parent cluster).
    565573 * The new child inode and the parent inode can have different FS types.
    566  * [Implementation note]
     574 *
     575 * WARNING : The lock protecting the Inode Tree must be taken in write mode by the caller.
     576 ******************************************************************************************
     577 * Implementation note
    567578 * As there are cross-references between inode and dentry, this function implements
    568579 * a five steps scenario :
     
    591602
    592603/******************************************************************************************
    593  * This function removes a remote dentry from the Inode-Tree.
     604 * This function removes a remote dentry and the associated inode from the Inode-Tree.
    594605 * - It removes the dentry from the parent inode xhtab ("children" field), and from the
    595606 *   child inode xlist ("parents" field).
     
    601612 * It can be executed by any thread running in any cluster (can be different from both
    602613 * the inode cluster and the dentry cluster).
     614 *
     615 * WARNING : The lock protecting the Inode Tree must be taken in write mode by the caller.
    603616 ******************************************************************************************
    604617 * @ dentry_xp   : extended pointer on removed dentry.
     
    613626 * This function is called by all functions creating a brand new directory : vfs_mkdir(),
    614627 * devfs_global_init(), and devfs_local_init().
     628 *
     629 * WARNING : The lock protecting the Inode Tree must be taken in write mode by the caller.
    615630 ******************************************************************************************
    616631 * @ child_xp    : extended pointer on new directory inode.
     
    624639 * This recursive function diplays a complete inode/dentry sub-tree.
    625640 * Any inode can be selected as the sub-tree root.
    626  * WARNING : this function is not protected against a concurrent inode/dentry removal...
     641 *
     642 * TODO : this function should be protected against a concurrent Inode-Tree change.
    627643 ******************************************************************************************
    628644 * @ inode_xp   : extended pointer on sub-tree root inode.
     
    632648/******************************************************************************************
    633649 * This function mount a given file system type for a given process
    634  * TODO non implemented yet [AG].     
     650 * TODO non implemented [AG].     
    635651 *****************************************************************************************/
    636652error_t vfs_mount_fs_root( struct device_s  * device,
     
    829845
    830846/******************************************************************************************
    831  * This function  creates a new directory as defined by the <root_xp> & <path> arguments.
    832  * TODO not implemented yet...
     847 * This function  creates a new inode/dentry couple for a new directory, and registers it
     848 * in the Inode Tree, as defined by the <root_xp>,  <path>, and <mode> arguments.
    833849 ******************************************************************************************
    834850 * @ root_xp  : extended pointer on the path root directory.
     
    855871 * This function change the access rigths for the file/directory identified by the
    856872 * <root_xp> and <path> arguments as defined by the <mode> argument value.
     873 * TODO not implemented yet
    857874 ******************************************************************************************
    858875 * @ root_xp  : extended pointer on the path root directory.
     
    866883
    867884/******************************************************************************************
    868  * This function creates a named FIFO file.
    869  * TODO not implemented yet                                                         
     885 * This function creates a new inode/dentry couple of FIFO type, and registers it
     886 * in the Inode Tree as specified by the <root_xp>, <path>, and <mode> arguments.
    870887 ******************************************************************************************
    871  * @ root_xp  : extended pointer on the path root directory.
    872  * @ path     : pathname (absolute or relative to CWD).
    873  * @ mode     : access rights new value.
     888 * @ root_xp  : [in] extended pointer on the root directory in path.
     889 * @ path     : [in] pathname (absolute or relative to CWD).
     890 * @ mode     : [in] access rights new value.
    874891 *****************************************************************************************/
    875892error_t vfs_mkfifo( xptr_t       root_xp,
Note: See TracChangeset for help on using the changeset viewer.