Changeset 623 for trunk/kernel/fs


Ignore:
Timestamp:
Mar 6, 2019, 4:37:15 PM (3 years ago)
Author:
alain
Message:

Introduce three new types of vsegs (KCODE,KDATA,KDEV)
to map the kernel vsegs in the process VSL and GPT.
This now used by both the TSAR and the I86 architectures.

Location:
trunk/kernel/fs
Files:
6 edited

Legend:

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

    r614 r623  
    33 *
    44 * Author   Mohamed Lamine Karaoui (2014,2015)
    5  *          Alain Greiner (2016,2017)
     5 *          Alain Greiner (2016,2017,2018,2019)
    66 *
    77 * Copyright (c) Sorbonne Universites
     
    9191                        xptr_t * devfs_external_inode_xp )
    9292{
    93     error_t  error;
    94     xptr_t   unused_xp;   // required by vfs_add_child_in_parent()
     93    error_t       error;
     94    xptr_t        unused_xp;   // required by vfs_add_child_in_parent()
     95    vfs_inode_t * inode;
    9596
    9697    // create DEVFS "dev" inode in cluster 0
    9798    error = vfs_add_child_in_parent( 0,                // cxy
    98                                      INODE_TYPE_DIR,
    9999                                     FS_TYPE_DEVFS,
    100100                                     root_inode_xp,
     
    103103                                     devfs_dev_inode_xp );
    104104
     105    // update inode "type" field
     106    inode = GET_PTR( *devfs_dev_inode_xp );
     107    inode->type = INODE_TYPE_DIR;
     108 
    105109    // create dentries <.> and <..> in <dev>
    106110    error |= vfs_add_special_dentries( *devfs_dev_inode_xp,
    107111                                       root_inode_xp );
    108112
    109 // check success
    110 assert( (error == 0) , "cannot create <dev>\n" );
     113    if( error )
     114    {
     115        printk("\n[PANIC] in %s : cannot create <dev> directory\n", __FUNCTION__ );
     116        hal_core_sleep();
     117    }
    111118
    112119#if DEBUG_DEVFS_GLOBAL_INIT
     
    120127    // create DEVFS "external" inode in cluster 0
    121128    error = vfs_add_child_in_parent( 0,               // cxy
    122                                      INODE_TYPE_DIR,
    123129                                     FS_TYPE_DEVFS,
    124130                                     *devfs_dev_inode_xp,
     
    127133                                     devfs_external_inode_xp );
    128134
     135    // update inode "type" field
     136    inode = GET_PTR( *devfs_external_inode_xp );
     137    inode->type = INODE_TYPE_DIR;
     138 
    129139    // create dentries <.> and <..> in <external>
    130140    error |= vfs_add_special_dentries( *devfs_external_inode_xp,
    131141                                       *devfs_dev_inode_xp );
    132142
    133 // check success
    134 assert( (error == 0) , "cannot create <external>\n" );
     143    if( error )
     144    {
     145        printk("\n[PANIC] in %s : cannot create <external> directory\n", __FUNCTION__ );
     146        hal_core_sleep();
     147    }
    135148
    136149#if DEBUG_DEVFS_GLOBAL_INIT
     
    153166    chdev_t     * chdev_ptr;
    154167    xptr_t        inode_xp;
    155     cxy_t         inode_cxy;
    156168    vfs_inode_t * inode_ptr;
    157169    uint32_t      channel;
     
    171183
    172184    error = vfs_add_child_in_parent( local_cxy,
    173                                      INODE_TYPE_DIR,
    174185                                     FS_TYPE_DEVFS,
    175186                                     devfs_dev_inode_xp,
     
    178189                                     devfs_internal_inode_xp );
    179190
     191    // set inode "type" field
     192    inode_ptr = GET_PTR( *devfs_internal_inode_xp );
     193    inode_ptr->type = INODE_TYPE_DEV;
     194 
    180195    // create dentries <.> and <..> in <internal>
    181196    error |= vfs_add_special_dentries( *devfs_internal_inode_xp,
    182197                                       devfs_dev_inode_xp );
    183198
    184 // check success
    185 assert( (error == 0) , "cannot create <external>\n" );
     199    if( error )
     200    {
     201        printk("\n[PANIC] in %s : cannot create <internal> directory\n", __FUNCTION__ );
     202        hal_core_sleep();
     203    }
    186204
    187205#if DEBUG_DEVFS_LOCAL_INIT
     
    199217        chdev_cxy = GET_CXY( chdev_xp );
    200218
    201 assert( (chdev_cxy == local_cxy ), "illegal MMC chdev in cluster %x\n", local_cxy );
     219        if( chdev_cxy != local_cxy )
     220        {
     221            printk("\n[PANIC] in %s : illegal MMC chdev in cluster %x\n",
     222            __FUNCTION__, local_cxy );
     223            hal_core_sleep();
     224        }
    202225
    203226        error = vfs_add_child_in_parent( local_cxy,
    204                                          INODE_TYPE_DEV,
    205227                                         FS_TYPE_DEVFS,
    206228                                         *devfs_internal_inode_xp,
     
    209231                                         &inode_xp );
    210232
    211 assert( (error == 0) , "cannot create MMC inode\n" );
    212 
    213         // update child inode "extend" field
    214         inode_cxy = GET_CXY( inode_xp );
     233        if( error )
     234        {
     235            printk("\n[PANIC] in %s : cannot create MMC inode in cluster %x\n",
     236            __FUNCTION__, local_cxy );
     237            hal_core_sleep();
     238        }
     239
     240        // update child inode "extend" and "type" fields
    215241        inode_ptr = GET_PTR( inode_xp );
    216         hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr );
     242        inode_ptr->extend = chdev_ptr;
     243        inode_ptr->type   = INODE_TYPE_DEV;
    217244       
    218245#if DEBUG_DEVFS_LOCAL_INIT
     
    234261            chdev_cxy = GET_CXY( chdev_xp );
    235262
    236 assert( (chdev_cxy == local_cxy ), "illegal DMA chdev in cluster %x\n", local_cxy );
     263            if( chdev_cxy != local_cxy )
     264            {
     265                printk("\d[PANIC] in %s : illegal DMA chdev in cluster %x\n",
     266                __FUNCTION__, local_cxy );
     267                hal_core_sleep();
     268            }
    237269
    238270            error = vfs_add_child_in_parent( local_cxy,
    239                                              INODE_TYPE_DEV,
    240271                                             FS_TYPE_DEVFS,
    241272                                             *devfs_internal_inode_xp,
     
    243274                                             &unused_xp,
    244275                                             &inode_xp );
    245 
    246 assert( (error == 0) , "cannot create DMA inode\n" );
    247 
    248             // update child inode "extend" field
    249             inode_cxy = GET_CXY( inode_xp );
     276            if( error )
     277            {
     278                printk("\n[PANIC] in %s : cannot create DMA inode in cluster %x\n",
     279                __FUNCTION__, local_cxy );
     280                hal_core_sleep();
     281            }
     282
     283            // update child inode "extend" and "type" fields
    250284            inode_ptr = GET_PTR( inode_xp );
    251             hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr );
     285            inode_ptr->extend = chdev_ptr;
     286            inode_ptr->type   = INODE_TYPE_DEV;
    252287       
    253288#if DEBUG_DEVFS_LOCAL_INIT
     
    270305        {
    271306            error = vfs_add_child_in_parent( local_cxy,
    272                                              INODE_TYPE_DEV,
    273307                                             FS_TYPE_DEVFS,
    274308                                             devfs_external_inode_xp,
     
    276310                                             &unused_xp,
    277311                                             &inode_xp );
    278 
    279 assert( (error == 0) , "cannot create IOB inode\n" );
    280 
    281             // update child inode "extend" field
    282             inode_cxy = GET_CXY( inode_xp );
     312            if( error )
     313            {
     314                printk("\n[PANIC] in %s : cannot create IOB inode in cluster %x\n",
     315                __FUNCTION__, local_cxy );
     316                hal_core_sleep();
     317            }
     318
     319            // update child inode "extend" and "type" fields
    283320            inode_ptr = GET_PTR( inode_xp );
    284             hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr );
     321            inode_ptr->extend = chdev_ptr;
     322            inode_ptr->type   = INODE_TYPE_DEV;
    285323       
    286324#if DEBUG_DEVFS_LOCAL_INIT
     
    303341        {
    304342            error = vfs_add_child_in_parent( local_cxy,
    305                                              INODE_TYPE_DEV,
    306343                                             FS_TYPE_DEVFS,
    307344                                             devfs_external_inode_xp,
     
    310347                                             &inode_xp );
    311348
    312 assert( (error == 0) , "cannot create PIC inode\n" );
     349            if( error )
     350            {
     351                printk("\n[PANIC] in %s : cannot create PIC inode in cluster %x\n",
     352                __FUNCTION__, local_cxy );
     353                hal_core_sleep();
     354            }
    313355
    314356            // update child inode "extend" field
    315             inode_cxy = GET_CXY( inode_xp );
    316357            inode_ptr = GET_PTR( inode_xp );
    317             hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr );
     358            inode_ptr->extend = chdev_ptr;
     359            inode_ptr->type   = INODE_TYPE_DEV;
    318360       
    319361#if DEBUG_DEVFS_LOCAL_INIT
     
    338380            {
    339381                error = vfs_add_child_in_parent( local_cxy,
    340                                                  INODE_TYPE_DEV,
    341382                                                 FS_TYPE_DEVFS,
    342383                                                 devfs_external_inode_xp,
     
    345386                                                 &inode_xp );
    346387
    347 assert( (error == 0) , "cannot create TXT_RX inode\n" );
    348 
    349                 // update child inode "extend" field
    350                 inode_cxy = GET_CXY( inode_xp );
     388                if( error )
     389                {
     390                    printk("\n[PANIC] in %s : cannot create TXT_RX inode in cluster %x\n",
     391                    __FUNCTION__, local_cxy );
     392                    hal_core_sleep();
     393                }
     394
     395                // update child inode "extend" and "type" fields
    351396                inode_ptr = GET_PTR( inode_xp );
    352                 hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr );
     397                inode_ptr->extend = chdev_ptr;
     398                inode_ptr->type   = INODE_TYPE_DEV;
    353399       
    354400#if DEBUG_DEVFS_LOCAL_INIT
     
    374420            {
    375421                error = vfs_add_child_in_parent( local_cxy,
    376                                                  INODE_TYPE_DEV,
    377422                                                 FS_TYPE_DEVFS,
    378423                                                 devfs_external_inode_xp,
     
    380425                                                 &unused_xp,
    381426                                                 &inode_xp );
    382 
    383 assert( (error == 0) , "cannot create TXT_TX inode\n" );
    384 
    385                 // update child inode "extend" field
    386                 inode_cxy = GET_CXY( inode_xp );
     427                if( error )
     428                {
     429                    printk("\n[PANIC] in %s : cannot create TXT_TX inode in cluster %x\n",
     430                    __FUNCTION__, local_cxy );
     431                    hal_core_sleep();
     432                }
     433
     434                // update child inode "extend" and "type" fields
    387435                inode_ptr = GET_PTR( inode_xp );
    388                 hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr );
     436                inode_ptr->extend = chdev_ptr;
     437                inode_ptr->type   = INODE_TYPE_DEV;
    389438       
    390439#if DEBUG_DEVFS_LOCAL_INIT
     
    410459            {
    411460                error = vfs_add_child_in_parent( local_cxy,
    412                                                  INODE_TYPE_DEV,
    413461                                                 FS_TYPE_DEVFS,
    414462                                                 devfs_external_inode_xp,
     
    416464                                                 &unused_xp,
    417465                                                 &inode_xp );
    418 
    419 assert( (error == 0) , "cannot create IOC inode\n" );
    420 
    421                 // update child inode "extend" field
    422                 inode_cxy = GET_CXY( inode_xp );
     466                if( error )
     467                {
     468                    printk("\n[PANIC] in %s : cannot create IOC inode in cluster %x\n",
     469                    __FUNCTION__, local_cxy );
     470                    hal_core_sleep();
     471                }
     472
     473                // update child inode "extend" and "type" fields
    423474                inode_ptr = GET_PTR( inode_xp );
    424                 hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr );
     475                inode_ptr->extend = chdev_ptr;
     476                inode_ptr->type   = INODE_TYPE_DEV;
    425477       
    426478#if DEBUG_DEVFS_LOCAL_INIT
     
    446498            {
    447499                error = vfs_add_child_in_parent( local_cxy,
    448                                                  INODE_TYPE_DEV,
    449500                                                 FS_TYPE_DEVFS,
    450501                                                 devfs_external_inode_xp,
     
    452503                                                 &unused_xp,
    453504                                                 &inode_xp );
    454 
    455 assert( (error == 0) , "cannot create FBF inode\n" );
    456 
    457                 // update child inode "extend" field
    458                 inode_cxy = GET_CXY( inode_xp );
     505                if( error )
     506                {
     507                    printk("\n[PANIC] in %s : cannot create FBF inode in cluster %x\n",
     508                    __FUNCTION__, local_cxy );
     509                    hal_core_sleep();
     510                }
     511
     512                // update child inode "extend" and "type" fields
    459513                inode_ptr = GET_PTR( inode_xp );
    460                 hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr );
     514                inode_ptr->extend = chdev_ptr;
     515                inode_ptr->type   = INODE_TYPE_DEV;
    461516       
    462517#if DEBUG_DEVFS_LOCAL_INIT
     
    482537            {
    483538                error = vfs_add_child_in_parent( local_cxy,
    484                                                  INODE_TYPE_DEV,
    485539                                                 FS_TYPE_DEVFS,
    486540                                                 devfs_external_inode_xp,
     
    488542                                                 &unused_xp,
    489543                                                 &inode_xp );
    490 
    491 assert( (error == 0) , "cannot create NIC_RX inode\n" );
    492 
    493                 // update child inode "extend" field
    494                 inode_cxy = GET_CXY( inode_xp );
     544                if( error )
     545                {
     546                    printk("\n[PANIC] in %s : cannot create NIC_RX inode in cluster %x\n",
     547                    __FUNCTION__, local_cxy );
     548                    hal_core_sleep();
     549                }
     550
     551                // update child inode "extend" and "type" fields
    495552                inode_ptr = GET_PTR( inode_xp );
    496                 hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr );
     553                inode_ptr->extend = chdev_ptr;
     554                inode_ptr->type   = INODE_TYPE_DEV;
    497555 
    498556#if DEBUG_DEVFS_LOCAL_INIT
     
    518576            {
    519577                error = vfs_add_child_in_parent( local_cxy,
    520                                                  INODE_TYPE_DEV,
    521578                                                 FS_TYPE_DEVFS,
    522579                                                 devfs_external_inode_xp,
     
    524581                                                 &unused_xp,
    525582                                                 &inode_xp );
    526 
    527 assert( (error == 0) , "cannot create NIC_TX inode\n" );
    528 
    529                 // update child inode "extend" field
    530                 inode_cxy = GET_CXY( inode_xp );
     583                if( error )
     584                {
     585                    printk("\n[PANIC] in %s : cannot create NIC_TX inode in cluster %x\n",
     586                    __FUNCTION__, local_cxy );
     587                    hal_core_sleep();
     588                }
     589
     590                // update child inode "extend" and "type" fields
    531591                inode_ptr = GET_PTR( inode_xp );
    532                 hal_remote_spt( XPTR( inode_cxy , &inode_ptr->extend ) , chdev_ptr );
     592                inode_ptr->extend = chdev_ptr;
     593                inode_ptr->type   = INODE_TYPE_DEV;
    533594       
    534595#if DEBUG_DEVFS_LOCAL_INIT
  • trunk/kernel/fs/fatfs.c

    r614 r623  
    793793#if (DEBUG_FATFS_CTX_INIT & 0x1)
    794794if( DEBUG_FATFS_CTX_INIT < cycle )
    795 {
    796     uint32_t   line;
    797     uint32_t   byte = 0;
    798     printk("\n***** %s : FAT boot record\n", __FUNCTION__ );
    799     for ( line = 0 ; line < 32 ; line++ )
    800     {
    801         printk(" %X | %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x |\n",
    802                byte,
    803                buffer[byte+ 0],buffer[byte+ 1],buffer[byte+ 2],buffer[byte+ 3],
    804                buffer[byte+ 4],buffer[byte+ 5],buffer[byte+ 6],buffer[byte+ 7],
    805                buffer[byte+ 8],buffer[byte+ 9],buffer[byte+10],buffer[byte+11],
    806                buffer[byte+12],buffer[byte+13],buffer[byte+14],buffer[byte+15] );
    807 
    808          byte += 16;
    809     }
    810 }
     795putb( "boot record", buffer , 256 );
    811796#endif
    812797
     
    960945assert( (inode != NULL) , "inode pointer is NULL\n" );
    961946assert( (dentry != NULL) , "dentry pointer is NULL\n" );
    962 assert( (inode->type == INODE_TYPE_DIR) , "inode is not a directory\n" );
    963947assert( (inode->mapper != NULL ) , "mapper pointer is NULL\n" );
    964948 
     
    13591343}  // end fatfs_remove_dentry
    13601344
    1361 /////////////////////////////////////////////////////
    1362 error_t fatfs_get_dentry( vfs_inode_t * parent_inode,
    1363                           char        * name,
    1364                           xptr_t        child_inode_xp )
     1345
     1346//////////////////////////////////////////////////////////////////////////////////////////////
     1347// This static function scan the pages of a mapper containing a FAT32 directory, identified
     1348// by the <mapper> argument, to find the directory entry identified by the <name> argument,
     1349// and return a pointer on the directory entry, described as and array of 32 bytes, and the
     1350// incex of this entry in the FAT32 mapper, seen as an array of 32 bytes entries.
     1351// It is called by the fatfs_new_dentry() and fatfs_update_dentry() functions.
     1352// It must be called by a thread running in the cluster containing the mapper.
     1353//////////////////////////////////////////////////////////////////////////////////////////////
     1354// @ mapper    : [in]  local pointer on directory mapper.
     1355// @ name      : [in]  searched directory entry name.
     1356// @ entry     : [out] buffer for the pointer on the 32 bytes directory entry (when found).
     1357// @ index     : [out] buffer for the directory entry index in mapper.
     1358// @ return 0 if found / return 1 if not found / return -1 if mapper access error.
     1359//////////////////////////////////////////////////////////////////////////////////////////////
     1360error_t fatfs_scan_directory( mapper_t *  mapper,
     1361                              char     *  name,
     1362                              uint8_t  ** entry,
     1363                              uint32_t *  index )
    13651364{
    13661365    // Two embedded loops to scan the directory mapper:
     
    13681367    // - scan the directory entries in each 4 Kbytes page
    13691368
    1370 #if DEBUG_FATFS_GET_DENTRY
     1369// check parent_inode and child_inode
     1370assert( (mapper != NULL) , "mapper pointer is NULL\n" );
     1371assert( (name   != NULL ), "child name is undefined\n" );
     1372assert( (entry  != NULL ), "entry buffer undefined\n" );
     1373
     1374#if DEBUG_FATFS_SCAN_DIRECTORY
    13711375char       parent_name[CONFIG_VFS_MAX_NAME_LENGTH];
    13721376uint32_t   cycle = (uint32_t)hal_get_cycles();
    13731377thread_t * this  = CURRENT_THREAD;
    1374 vfs_inode_get_name( XPTR( local_cxy , parent_inode ) , parent_name );
    1375 if( DEBUG_FATFS_GET_DENTRY < cycle )
    1376 printk("\n[%s]  thread[%x,%x] enter for child <%s> in parent <%s> / cycle %d\n",
     1378vfs_inode_get_name( XPTR( local_cxy , mapper->inode ) , parent_name );
     1379if( DEBUG_FATFS_SCAN_DIRECTORY < cycle )
     1380printk("\n[%s]  thread[%x,%x] enter to search child <%s> in parent <%s> / cycle %d\n",
    13771381__FUNCTION__, this->process->pid, this->trdid, name , parent_name , cycle );
    13781382#endif
    13791383
    1380 // check parent_inode and child_inode
    1381 assert( (parent_inode != NULL) , "parent_inode is NULL\n" );
    1382 assert( (child_inode_xp != XPTR_NULL ) , "child_inode is XPTR_NULL\n" );
    1383 
    1384     mapper_t * mapper    = parent_inode->mapper;
    1385     xptr_t     mapper_xp = XPTR( local_cxy , mapper );
    1386 
    1387 // check parent mapper
    1388 assert( (mapper != NULL) , "parent mapper is NULL\n");
    1389    
    1390     char       cname[CONFIG_VFS_MAX_NAME_LENGTH];  // name extracter from each directory entry
     1384    char       cname[CONFIG_VFS_MAX_NAME_LENGTH];  // name extracted from each directory entry
    13911385
    13921386    char       lfn1[16];         // buffer for one partial cname
    13931387    char       lfn2[16];         // buffer for one partial cname
    13941388    char       lfn3[16];         // buffer for one partial cname
     1389    xptr_t     mapper_xp;        // extended pointer on mapper descriptor
    13951390    xptr_t     page_xp;          // extended pointer on page descriptor
    13961391    xptr_t     base_xp;          // extended pointer on page base
     
    14001395    uint32_t   seq;              // sequence index
    14011396    uint32_t   lfn       = 0;    // LFN entries number
    1402     uint32_t   size      = 0;    // searched file/dir size (bytes)
    1403     uint32_t   cluster   = 0;    // searched file/dir cluster index
    1404     uint32_t   is_dir    = 0;    // searched file/dir type
    1405     int32_t    found     = 0;    // not found (0) / name found (1) / end of dir (-1)
     1397    int32_t    found     = 0;    // not yet = 0 / success = 1 / not found = 2 / error = -1
    14061398    uint32_t   page_id   = 0;    // page index in mapper
    1407     uint32_t   dentry_id = 0;    // directory entry index
    14081399    uint32_t   offset    = 0;    // byte offset in page
    14091400
    1410     // scan the parent directory mapper
     1401    mapper_xp = XPTR( local_cxy , mapper );
     1402
     1403    // scan the mapper pages
    14111404    while ( found == 0 )
    14121405    {
     
    14141407        page_xp = mapper_remote_get_page( mapper_xp , page_id );
    14151408
    1416         if( page_xp == XPTR_NULL) return EIO;
     1409        if( page_xp == XPTR_NULL)
     1410        {
     1411            found = -1;
     1412        }
    14171413
    14181414        // get page base
     
    14201416        base    = (uint8_t *)GET_PTR( base_xp );
    14211417
    1422 #if (DEBUG_FATFS_GET_DENTRY & 0x1)
    1423 if( DEBUG_FATFS_GET_DENTRY < cycle )
     1418#if (DEBUG_FATFS_SCAN_DIRECTORY & 0x1)
     1419if( DEBUG_FATFS_SCAN_DIRECTORY < cycle )
    14241420mapper_display_page( mapper_xp , page_id , 256 );
    14251421#endif
     
    14321428            if (ord == NO_MORE_ENTRY)                 // no more entry => break
    14331429            {
    1434                 found = -1;
     1430                found = 2;
    14351431            }
    14361432            else if ( ord == FREE_ENTRY )             // free entry => skip
     
    14771473                if ( strcmp( name , cname ) == 0 )
    14781474                {
    1479                     cluster = (fatfs_get_record( DIR_FST_CLUS_HI , base + offset , 1 ) << 16) |
    1480                               (fatfs_get_record( DIR_FST_CLUS_LO , base + offset , 1 )      ) ;
    1481                     dentry_id = ((page_id<<12) + offset)>>5;
    1482                     is_dir    = ((attr & ATTR_DIRECTORY) == ATTR_DIRECTORY);
    1483                     size      = fatfs_get_record( DIR_FILE_SIZE , base + offset , 1 );
     1475                    *entry = base + offset;
     1476                    *index = ((page_id<<12) + offset)>>5;
    14841477                    found     = 1;
    14851478                }
     
    14941487    }  // end loop on pages
    14951488
    1496     // analyse the result of scan
    1497 
    1498     if ( found == -1 )  // found end of directory => failure
    1499     {
     1489    if( found == 1 )
     1490    {
     1491
     1492#if DEBUG_FATFS_SCAN_DIRECTORY
     1493cycle = (uint32_t)hal_get_cycles();
     1494if( DEBUG_FATFS_SCAN_DIRECTORY < cycle )
     1495printk("\n[%s]  thread[%x,%x] exit / found child <%s> in <%s>\n",
     1496__FUNCTION__, this->process->pid, this->trdid, name, parent_name );
     1497#endif
     1498        return 0;
     1499    }
     1500    else if( found == 2 )
     1501    {
     1502
     1503#if DEBUG_FATFS_SCAN_DIRECTORY
     1504cycle = (uint32_t)hal_get_cycles();
     1505if( DEBUG_FATFS_SCAN_DIRECTORY < cycle )
     1506printk("\n[%s]  thread[%x,%x] exit / child <%s> in <%s> not found\n",
     1507__FUNCTION__, this->process->pid, this->trdid, name, parent_name );
     1508#endif
     1509        return 1;
     1510    }
     1511    else
     1512    {
     1513        printk("\n[ERROR] in %s : cannot get page %d from mapper\n",
     1514        __FUNCTION__, page_id );
     1515
     1516        return -1;
     1517    }
     1518}  // end fatfs_scan_directory()
     1519
     1520
     1521
     1522/////////////////////////////////////////////////////
     1523error_t fatfs_new_dentry( vfs_inode_t * parent_inode,
     1524                          char        * name,
     1525                          xptr_t        child_inode_xp )
     1526{
     1527    uint8_t  * entry;    // pointer on FAT32 directory entry (array of 32 bytes)
     1528    uint32_t   index;    // index of FAT32 directory entry in mapper
     1529    mapper_t * mapper;   // pointer on directory mapper
     1530    uint32_t   cluster;  // directory entry cluster
     1531    uint32_t   size;     // directory entry size
     1532    bool_t     is_dir;   // directory entry type (file/dir)
     1533    error_t    error;
     1534
     1535// check arguments
     1536assert( (parent_inode != NULL)         , "parent_inode is NULL\n" );
     1537assert( (name         != NULL)         , "name is NULL\n" );
     1538assert( (child_inode_xp != XPTR_NULL ) , "child_inode is XPTR_NULL\n" );
     1539
     1540#if DEBUG_FATFS_GET_DENTRY
     1541char       parent_name[CONFIG_VFS_MAX_NAME_LENGTH];
     1542uint32_t   cycle = (uint32_t)hal_get_cycles();
     1543thread_t * this  = CURRENT_THREAD;
     1544vfs_inode_get_name( XPTR( local_cxy , parent_inode ) , parent_name );
     1545if( DEBUG_FATFS_GET_DENTRY < cycle )
     1546printk("\n[%s]  thread[%x,%x] enter for child <%s> in parent <%s> / cycle %d\n",
     1547__FUNCTION__, this->process->pid, this->trdid, name , parent_name , cycle );
     1548#endif
     1549
     1550    // get pointer and index of searched directory entry in mapper
     1551    mapper = parent_inode->mapper;
     1552    error  = fatfs_scan_directory( mapper, name , &entry , &index );
     1553
     1554    // update child inode and dentry descriptors if sucess
     1555    if( error == 0 )
     1556    {
    15001557
    15011558#if DEBUG_FATFS_GET_DENTRY
    15021559cycle = (uint32_t)hal_get_cycles();
    15031560if( DEBUG_FATFS_GET_DENTRY < cycle )
    1504 printk("\n[%s]  thread[%x,%x] exit / child <%s> not found / cycle %d\n",
    1505 __FUNCTION__, this->process->pid, this->trdid, name, cycle );
    1506 #endif
    1507 
    1508         return -1;
    1509     }
    1510 
    1511     // get child inode cluster and local pointer
    1512     cxy_t          inode_cxy = GET_CXY( child_inode_xp );
    1513     vfs_inode_t  * inode_ptr = GET_PTR( child_inode_xp );
    1514 
    1515     // build extended pointer on parent dentried root
    1516     xptr_t parents_root_xp = XPTR( inode_cxy , &inode_ptr->parents );
     1561printk("\n[%s]  thread[%x,%x] exit / intialised child <%s> in %s / cycle %d\n",
     1562__FUNCTION__, this->process->pid, this->trdid, name, parent_name, cycle );
     1563#endif
     1564        // get relevant infos from FAT32 directory entry
     1565        cluster = (fatfs_get_record( DIR_FST_CLUS_HI , entry , 1 ) << 16) |
     1566                  (fatfs_get_record( DIR_FST_CLUS_LO , entry , 1 )      ) ;
     1567        is_dir  = (fatfs_get_record( DIR_ATTR        , entry , 1 ) & ATTR_DIRECTORY);
     1568        size    =  fatfs_get_record( DIR_FILE_SIZE   , entry , 1 );
     1569
     1570        // get child inode cluster and local pointer
     1571        cxy_t          inode_cxy = GET_CXY( child_inode_xp );
     1572        vfs_inode_t  * inode_ptr = GET_PTR( child_inode_xp );
     1573
     1574        // build extended pointer on root of list of prent dentries
     1575        xptr_t parents_root_xp = XPTR( inode_cxy , &inode_ptr->parents );
    15171576
    15181577// check child inode has at least one parent
    15191578assert( (xlist_is_empty( parents_root_xp ) == false ), "child inode must have one parent\n");
    15201579
    1521     // get dentry pointers and cluster
    1522     xptr_t         dentry_xp  = XLIST_FIRST( parents_root_xp , vfs_dentry_t , parents );
    1523     vfs_dentry_t * dentry_ptr = GET_PTR( dentry_xp );
    1524     cxy_t          dentry_cxy = GET_CXY( dentry_xp );
     1580        // get dentry pointers and cluster
     1581        xptr_t         dentry_xp  = XLIST_FIRST( parents_root_xp , vfs_dentry_t , parents );
     1582        vfs_dentry_t * dentry_ptr = GET_PTR( dentry_xp );
     1583        cxy_t          dentry_cxy = GET_CXY( dentry_xp );
    15251584
    15261585// check dentry descriptor in same cluster as parent inode
    15271586assert( (dentry_cxy == local_cxy) , "illegal dentry cluster\n" );
    15281587
    1529     // update the child inode "type", "size", and "extend" fields
    1530     vfs_inode_type_t type = (is_dir) ? INODE_TYPE_DIR : INODE_TYPE_FILE;
    1531 
    1532     hal_remote_s32( XPTR( inode_cxy , &inode_ptr->type   ) , type );
    1533     hal_remote_s32( XPTR( inode_cxy , &inode_ptr->size   ) , size );
    1534     hal_remote_s32( XPTR( inode_cxy , &inode_ptr->extend ) , cluster );
    1535 
    1536     // update the dentry "extend" field
    1537     dentry_ptr->extend = (void *)(intptr_t)dentry_id;
    1538 
    1539 #if DEBUG_FATFS_GET_DENTRY
     1588        // update the child inode "type", "size", and "extend" fields
     1589        vfs_inode_type_t type = (is_dir) ? INODE_TYPE_DIR : INODE_TYPE_FILE;
     1590
     1591        hal_remote_s32( XPTR( inode_cxy , &inode_ptr->type   ) , type );
     1592        hal_remote_s32( XPTR( inode_cxy , &inode_ptr->size   ) , size );
     1593        hal_remote_s32( XPTR( inode_cxy , &inode_ptr->extend ) , cluster );
     1594
     1595        // update the dentry "extend" field
     1596        dentry_ptr->extend = (void *)(intptr_t)index;
     1597
     1598        return 0;
     1599    }
     1600    else
     1601    {
     1602        return -1;
     1603    }
     1604
     1605}  // end fatfs_new_dentry()
     1606
     1607//////////////////////////////////////////////////
     1608error_t fatfs_update_dentry( vfs_inode_t  * inode,
     1609                             vfs_dentry_t * dentry,
     1610                             uint32_t       size )
     1611{
     1612    uint8_t  * entry;    // pointer on FAT32 directory entry (array of 32 bytes)
     1613    uint32_t   index;    // index of FAT32 directory entry in mapper
     1614    mapper_t * mapper;   // pointer on directory mapper
     1615    error_t    error;
     1616
     1617// check arguments
     1618assert( (inode  != NULL) , "inode is NULL\n" );
     1619assert( (dentry != NULL) , "dentry is NULL\n" );
     1620assert( (size   != 0   ) , "size is 0\n" );
     1621
     1622#if DEBUG_FATFS_UPDATE_DENTRY
     1623char       dir_name[CONFIG_VFS_MAX_NAME_LENGTH];
     1624uint32_t   cycle = (uint32_t)hal_get_cycles();
     1625thread_t * this  = CURRENT_THREAD;
     1626vfs_inode_get_name( XPTR( local_cxy , inode ) , dir_name );
     1627if( DEBUG_FATFS_UPDATE_DENTRY < cycle )
     1628printk("\n[%s]  thread[%x,%x] enter for entry <%s> in dir <%s> / cycle %d\n",
     1629__FUNCTION__, this->process->pid, this->trdid, dentry->name , dir_name , cycle );
     1630#endif
     1631
     1632    // get pointer and index of searched directory entry in mapper
     1633    mapper = inode->mapper;
     1634    error  = fatfs_scan_directory( mapper, dentry->name , &entry , &index );
     1635
     1636    // update size in mapper if found
     1637    if( error == 0 )
     1638    {
     1639
     1640#if DEBUG_FATFS_UPDATE_DENTRY
    15401641cycle = (uint32_t)hal_get_cycles();
    1541 if( DEBUG_FATFS_GET_DENTRY < cycle )
    1542 printk("\n[%s]  thread[%x,%x] exit / child <%s> loaded in <%s> / cycle %d\n",
    1543 __FUNCTION__, this->process->pid, this->trdid, name, parent_name, cycle );
    1544 #endif
    1545 
    1546     return 0;
    1547 
    1548 }  // end fatfs_get_dentry()
     1642if( DEBUG_FATFS_UPDATE_DENTRY < cycle )
     1643printk("\n[%s]  thread[%x,%x] exit / found entry <%s> in <%s> / cycle %d\n",
     1644__FUNCTION__, this->process->pid, this->trdid, dentry->name, dir_name, cycle );
     1645#endif
     1646        // set size in FAT32 directory entry
     1647        fatfs_set_record( DIR_FILE_SIZE , entry , 1 , size );
     1648
     1649        // get local pointer on modified page base
     1650        void * base = (void *)((intptr_t)entry & (~CONFIG_PPM_PAGE_MASK));
     1651
     1652        // get extended pointer on modified page descriptor
     1653        xptr_t    page_xp = ppm_base2page( XPTR( local_cxy , base ) );
     1654
     1655        // mark page as dirty
     1656        ppm_page_do_dirty( page_xp );
     1657
     1658        return 0;
     1659    }
     1660    else
     1661    {
     1662        return -1;
     1663    }
     1664
     1665}  // end fatfs_update_dentry()
    15491666
    15501667///////////////////////////////////////////////////////
     
    20562173assert( (inode_xp != XPTR_NULL) , "inode pointer is NULL\n" );
    20572174
    2058     // get first_cluster from inode extension
     2175    // get inode cluster and local pointer
    20592176    inode_ptr     = GET_PTR( inode_xp );
    20602177    inode_cxy     = GET_CXY( inode_xp );
     2178
     2179    // get first_cluster from inode extension
    20612180    first_xp      = XPTR( inode_cxy , &inode_ptr->extend );
    20622181    first_cluster = (uint32_t)(intptr_t)hal_remote_lpt( first_xp );
     
    20732192printk("\n[%s] thread[%x,%x] enter for <%s> / first_cluster %x / cycle %d\n",
    20742193__FUNCTION__ , this->process->pid, this->trdid, name, first_cluster, cycle );
     2194#endif
     2195
     2196#if (DEBUG_FATFS_RELEASE_INODE & 1)
     2197fatfs_display_fat( 0 , 512 );
    20752198#endif
    20762199
  • trunk/kernel/fs/fatfs.h

    r614 r623  
    309309
    310310/*****************************************************************************************
    311  * This function implements the generic vfs_fs_get_dentry() function for the FATFS.
    312  *****************************************************************************************
    313  * It initialises a new child (new inode/dentry couple in Inode Tree), identified
    314  * by the <child_inode_xp> argument, from the parent directory mapper, identified by the
    315  * <parent_inode> argument.
     311 * This function implements the generic vfs_fs_new_dentry() function for the FATFS.
     312 *****************************************************************************************
     313 * It initializes a new inode/dentry couple in Inode Tree, attached to the directory
     314 * identified by the <parent_inode> argument. The new directory entry is identified
     315 * by the <name> argument. The child inode descriptor identified by the <child_inode_xp>
     316 * argument, and the dentry descriptor must have been previously allocated.
    316317 * It scan the parent mapper to find the <name> argument.
    317318 * It set the "type", "size", and "extend" fields in inode descriptor.
     
    324325 * @ return 0 if success / return ENOENT if child not found.
    325326 ****************************************************************************************/
    326 error_t fatfs_get_dentry( struct vfs_inode_s * parent_inode,
     327error_t fatfs_new_dentry( struct vfs_inode_s * parent_inode,
    327328                          char               * name,
    328329                          xptr_t               child_inode_xp );
    329330
    330331/*****************************************************************************************
     332 * This function implements the generic vfs_fs_update_dentry() function for the FATFS.
     333 *****************************************************************************************
     334 * It update the size of a directory entry identified by the <dentry> argument in
     335 * the mapper of a directory identified by the <inode> argument, as defined by the <size>
     336 * argument.
     337 * It scan the mapper to find the entry identified by the dentry "name" field.
     338 * It set the "size" field in the in the directory mapper AND marks the page as DIRTY.
     339 * It must be called by a thread running in the cluster containing the directory inode.
     340 *****************************************************************************************
     341 * @ inode        : local pointer on inode (directory).
     342 * @ dentry       : local pointer on dentry (for name).
     343 * @ size         : new size value.
     344 * @ return 0 if success / return ENOENT if child not found.
     345 ****************************************************************************************/
     346error_t fatfs_update_dentry( struct vfs_inode_s  * inode,
     347                             struct vfs_dentry_s * dentry,
     348                             uint32_t              size );
     349
     350/*****************************************************************************************
    331351 * This function implements the generic vfs_fs_get_user_dir() function for the FATFS.
    332352 *****************************************************************************************
    333353 * It is called by the remote_dir_create() function to scan the mapper of a directory
    334  * identified by the <inode> argument and copy up to <max_dirent> valid dentries to a
     354 * identified by the <inode> argument, and copy up to <max_dirent> valid dentries to a
    335355 * local dirent array, defined by the <array> argument. The <min_dentry> argument defines
    336  * the index of the first dentry to copied to the target dirent array.
     356 * the index of the first dentry to be copied to the target dirent array.
    337357 * This function returns in the <entries> buffer the number of dentries actually written,
    338358 * and signals in the <done> buffer when the last valid entry has been found.
    339359 * If the <detailed> argument is true, a dentry/inode couple that does not exist in
    340  * the Inode Tree is dynamically created, and all dirent fiels are documented in the
     360 * the Inode Tree is dynamically created, and all dirent fields are documented in the
    341361 * dirent array. Otherwise, only the dentry name is documented.
    342362 * It must be called by a thread running in the cluster containing the directory inode.
     
    443463 * The page - and the mapper - can be located in another cluster than the calling thread.
    444464 * The pointer on the mapper and the page index in file are found in the page descriptor.
    445  * It is used for both for a regular file/directory mapper, and the FAT mapper.
     465 * It is used for both a regular file/directory mapper, and the FAT mapper.
    446466 * For the FAT mapper, it access the FATFS to get the location on IOC device.
    447467 * For a regular file, it access the FAT mapper to get the cluster index on IOC device.
  • trunk/kernel/fs/ramfs.c

    r602 r623  
    3535                     char   * ramfs_root_name )
    3636{
    37     xptr_t    unused_xp;   // required by vfs_add_child_in_parent()                     
     37    xptr_t        dentry_xp;     // unused but required by vfs_add_child_in_parent()
     38    xptr_t        inode_xp;
     39    vfs_inode_t * inode_ptr;
    3840 
    3941    cxy_t     cxy = cluster_random_select();
     
    4143    // create VFS dentry and VFS inode for RAMFS root directory
    4244    return  vfs_add_child_in_parent( cxy,
    43                                      INODE_TYPE_DIR,
    4445                                     FS_TYPE_RAMFS,
    4546                                     parent_inode_xp,
    4647                                     ramfs_root_name,
    47                                      &unused_xp,
    48                                      &unused_xp );
     48                                     &dentry_xp,
     49                                     &inode_xp );
     50    // update inode type field
     51    inode_ptr = GET_PTR( inode_xp );
     52    inode_ptr->type = INODE_TYPE_DIR;
    4953}
    5054
  • trunk/kernel/fs/vfs.c

    r614 r623  
    33 *
    44 * Author  Mohamed Lamine Karaoui (2015)
    5  *         Alain Greiner (2016,2017,2018)
     5 *         Alain Greiner (2016,2017,2018,2019)
    66 *
    77 * Copyright (c) UPMC Sorbonne Universites
     
    142142////////////////////////////////////////////////////
    143143error_t vfs_inode_create( vfs_fs_type_t     fs_type,
    144                           vfs_inode_type_t  inode_type,
    145144                          uint32_t          attr,
    146145                          uint32_t          rights,
     
    214213
    215214    // initialize inode descriptor
    216     inode->type       = inode_type;
     215    inode->type       = INODE_TYPE_FILE;     // default value
    217216    inode->inum       = inum;
    218217    inode->attr       = attr;
     
    228227    mapper->inode     = inode;
    229228 
    230     // initialise threads waiting queue
    231     // xlist_root_init( XPTR( local_cxy , &inode->wait_root ) );
    232 
    233229    // initialize chidren dentries xhtab
    234230    xhtab_init( &inode->children , XHTAB_DENTRY_TYPE );
     
    278274    vfs_inode_t * ptr = GET_PTR( inode_xp );
    279275
     276    // build extended pointers on lock & size
     277    xptr_t   lock_xp = XPTR( cxy , &ptr->size_lock );
     278    xptr_t   size_xp = XPTR( cxy , &ptr->size );
     279
     280    // take lock in read mode
     281    remote_rwlock_rd_acquire( lock_xp );
     282
    280283    // get size
    281     remote_rwlock_rd_acquire( XPTR( cxy , &ptr->size_lock ) );
    282     uint32_t size = hal_remote_l32( XPTR( cxy , &ptr->size ) );
    283     remote_rwlock_rd_release( XPTR( cxy , &ptr->size_lock ) );
     284    uint32_t size = hal_remote_l32( size_xp );
     285
     286    // release lock from read mode
     287    remote_rwlock_rd_release( lock_xp );
     288
    284289    return size;
    285290}
    286291
    287 ////////////////////////////////////////////
    288 void vfs_inode_set_size( xptr_t    inode_xp,
    289                          uint32_t  size )
     292///////////////////////////////////////////////
     293void vfs_inode_update_size( xptr_t    inode_xp,
     294                            uint32_t  size )
    290295{
    291296    // get inode cluster and local pointer
     
    293298    vfs_inode_t * ptr = GET_PTR( inode_xp );
    294299
    295     // set size
    296     remote_rwlock_wr_release( XPTR( cxy , &ptr->size_lock ) );
    297     hal_remote_s32( XPTR( cxy , &ptr->size ) , size );
    298     remote_rwlock_wr_release( XPTR( cxy , &ptr->size_lock ) );
     300    // build extended pointers on lock & size
     301    xptr_t   lock_xp = XPTR( cxy , &ptr->size_lock );
     302    xptr_t   size_xp = XPTR( cxy , &ptr->size );
     303
     304    // take lock in write mode
     305    remote_rwlock_wr_acquire( lock_xp );
     306
     307    // get current size
     308    uint32_t current_size = hal_remote_l32( size_xp );
     309
     310    // set size if required
     311    if( current_size < size ) hal_remote_s32( size_xp , size );
     312
     313    // release lock from write mode
     314    remote_rwlock_wr_release( lock_xp );
    299315}
    300316
     
    546562
    547563// check refcount
    548 assert( (file->refcount == 0) , "refcount non zero\n" );
     564// assert( (file->refcount == 0) , "refcount non zero\n" );
    549565
    550566        kmem_req_t req;
     
    554570
    555571#if DEBUG_VFS_CLOSE
     572char name[CONFIG_VFS_MAX_NAME_LENGTH];
     573vfs_file_get_name( XPTR( local_cxy , file ) , name );
    556574thread_t * this = CURRENT_THREAD;
    557575uint32_t cycle = (uint32_t)hal_get_cycles();
    558576if( DEBUG_VFS_CLOSE < cycle )
    559 printk("\n[%s] thread[%x,%x] deleted file %x in cluster %x / cycle %d\n",
    560 __FUNCTION__, this->process->pid, this->trdid, file, local_cxy, cycle );
     577printk("\n[%s] thread[%x,%x] deleted file <%s> in cluster %x / cycle %d\n",
     578__FUNCTION__, this->process->pid, this->trdid, name, local_cxy, cycle );
    561579#endif
    562580
     
    585603    hal_remote_atomic_add( XPTR( file_cxy , &file_ptr->refcount ) , -1 );
    586604}
     605
     606///////////////////////////////////////
     607void vfs_file_get_name( xptr_t file_xp,
     608                        char * name )
     609{
     610    // get cluster and local pointer on remote file
     611    vfs_file_t * file_ptr = GET_PTR( file_xp );
     612    cxy_t        file_cxy = GET_CXY( file_xp );
     613
     614    // get pointers on remote inode
     615    vfs_inode_t * inode_ptr = hal_remote_lpt( XPTR( file_cxy , &file_ptr->inode ) );
     616    xptr_t        inode_xp  = XPTR( file_cxy , inode_ptr );
     617
     618    // call the relevant function
     619    vfs_inode_get_name( inode_xp , name );
     620}
     621
    587622
    588623//////////////////////////////////////////////////////////////////////////////////////////
     
    889924}  // vfs_lseek()
    890925
    891 ///////////////////////////////////
     926////////////////////////////////////
    892927error_t vfs_close( xptr_t   file_xp,
    893928                   uint32_t file_id )
    894929{
    895     cluster_t  * cluster;          // local pointer on local cluster
    896     cxy_t        file_cxy;         // cluster containing the file descriptor.
    897     vfs_file_t * file_ptr;         // local ponter on file descriptor
    898     cxy_t        owner_cxy;        // process owner cluster
    899     lpid_t       lpid;             // process local index
    900     xptr_t       root_xp;          // root of list of process copies
    901     xptr_t       lock_xp;          // lock protecting the list of copies
    902     xptr_t       iter_xp;          // iterator on list of process copies
    903     xptr_t       process_xp;       // extended pointer on one process copy
    904     cxy_t        process_cxy;      // process copy cluster
    905     process_t  * process_ptr;      // process copy local pointer
    906 
    907 // check arguments
    908 assert( (file_xp != XPTR_NULL) , "file_xp == XPTR_NULL\n" );
    909 assert( (file_id < CONFIG_PROCESS_FILE_MAX_NR) , "illegal file_id\n" );
     930    cxy_t         file_cxy;         // cluster containing the file descriptor.
     931    vfs_file_t  * file_ptr;         // local ponter on file descriptor
     932    cxy_t         owner_cxy;        // process owner cluster
     933    pid_t         pid;              // process identifier
     934    lpid_t        lpid;             // process local index
     935    xptr_t        root_xp;          // root of xlist (processes , or dentries)
     936    xptr_t        lock_xp;          // lock protecting the xlist
     937    xptr_t        iter_xp;          // iterator on xlist
     938    mapper_t    * mapper_ptr;       // local pointer on associated mapper
     939    xptr_t        mapper_xp;        // extended pointer on mapper
     940    vfs_inode_t * inode_ptr;        // local pointer on associated inode
     941    xptr_t        inode_xp;         // extended pointer on inode
     942    uint32_t      size;             // current file size (from inode descriptor)
     943    error_t       error;
     944
     945    char          name[CONFIG_VFS_MAX_NAME_LENGTH];  // file name
     946
     947// check argument
     948assert( (file_xp != XPTR_NULL) , "file_xp is XPTR_NULL\n" );
    910949
    911950    thread_t  * this    = CURRENT_THREAD;
    912951    process_t * process = this->process;
    913 
     952    cluster_t * cluster = LOCAL_CLUSTER;
     953
     954    // get file name
     955    vfs_file_get_name( file_xp , name );
     956   
    914957#if DEBUG_VFS_CLOSE
    915958uint32_t cycle = (uint32_t)hal_get_cycles();
    916959if( DEBUG_VFS_CLOSE < cycle )
    917 printk("\n[%s] thread[%x,%x] enter / fdid %d / cycle %d\n",
    918 __FUNCTION__, process->pid, this->trdid, file_id, cycle );
    919 #endif
    920 
    921     // get local pointer on local cluster manager
    922     cluster = LOCAL_CLUSTER;
     960printk("\n[%s] thread[%x,%x] enter for <%s> / cycle %d\n",
     961__FUNCTION__, process->pid, this->trdid, name, cycle );
     962#endif
     963
     964    // get cluster and local pointer on remote file descriptor
     965    file_cxy = GET_CXY( file_xp );
     966    file_ptr = GET_PTR( file_xp );
     967
     968    //////// 1) update all dirty pages from mapper to device
     969
     970    // get pointers on mapper associated to file
     971    mapper_ptr = hal_remote_lpt( XPTR( file_cxy , &file_ptr->mapper ) );
     972    mapper_xp  = XPTR( file_cxy , mapper_ptr );
     973
     974    // copy all dirty pages from mapper to device
     975    if( file_cxy == local_cxy )
     976    {
     977        error = mapper_sync( mapper_ptr );
     978    }
     979    else
     980    {
     981        rpc_mapper_sync_client( file_cxy,
     982                                mapper_ptr,
     983                                &error );
     984    }
     985
     986    if( error )
     987    {
     988        printk("\n[ERROR] in %s : cannot synchronise dirty pages for <%s>\n",
     989        __FUNCTION__, name );
     990        return -1;
     991    }
     992
     993#if DEBUG_VFS_CLOSE
     994if( DEBUG_VFS_CLOSE < cycle )
     995printk("\n[%s] thread[%x,%x] synchronised mapper of <%s> to device\n",
     996__FUNCTION__, process->pid, this->trdid, name );
     997#endif
     998
     999    //////// 2) update file size in all parent directory mapper(s) and on device
     1000
     1001    // get pointers on remote inode
     1002    inode_ptr = hal_remote_lpt( XPTR( file_cxy , &file_ptr->inode ) );
     1003    inode_xp  = XPTR( file_cxy , inode_ptr );
     1004
     1005    // get file size from remote inode
     1006    size = hal_remote_l32( XPTR( file_cxy , &inode_ptr->size ) );
     1007
     1008    // get root of list of parents dentry
     1009    root_xp = XPTR( file_cxy , &inode_ptr->parents );
     1010
     1011    // loop on all parents
     1012    XLIST_FOREACH( root_xp , iter_xp )
     1013    {
     1014        // get pointers on parent directory dentry
     1015        xptr_t         parent_dentry_xp  = XLIST_ELEMENT( iter_xp , vfs_dentry_t , parents );
     1016        cxy_t          parent_cxy        = GET_CXY( parent_dentry_xp );
     1017        vfs_dentry_t * parent_dentry_ptr = GET_PTR( parent_dentry_xp );
     1018
     1019        // get local pointer on parent directory inode
     1020        vfs_inode_t * parent_inode_ptr = hal_remote_lpt( XPTR( parent_cxy,
     1021                                                         &parent_dentry_ptr->parent ) );
     1022
     1023        // get local pointer on parent directory mapper
     1024        mapper_t * parent_mapper_ptr = hal_remote_lpt( XPTR( parent_cxy,
     1025                                                       &parent_inode_ptr->mapper ) );
     1026 
     1027        // update dentry size in parent directory mapper
     1028        if( parent_cxy == local_cxy )
     1029        {
     1030            error = vfs_fs_update_dentry( parent_inode_ptr,
     1031                                          parent_dentry_ptr,
     1032                                          size );
     1033        }
     1034        else
     1035        {
     1036            rpc_vfs_fs_update_dentry_client( parent_cxy,
     1037                                             parent_inode_ptr,
     1038                                             parent_dentry_ptr,
     1039                                             size,
     1040                                             &error );
     1041        }
     1042
     1043        if( error )
     1044        {
     1045            printk("\n[ERROR] in %s : cannot update size in parent\n",
     1046            __FUNCTION__ );
     1047            return -1;
     1048        }
     1049
     1050#if DEBUG_VFS_CLOSE
     1051char parent_name[CONFIG_VFS_MAX_NAME_LENGTH];
     1052vfs_inode_get_name( XPTR( parent_cxy , parent_inode_ptr ) , parent_name );
     1053if( DEBUG_VFS_CLOSE < cycle )
     1054printk("\n[%s] thread[%x,%x] updated size of <%s> in parent <%s>\n",
     1055__FUNCTION__, process->pid, this->trdid, name, parent_name );
     1056#endif
     1057
     1058        // copy all dirty pages from parent mapper to device
     1059        if( parent_cxy == local_cxy )
     1060        {
     1061            error = mapper_sync( parent_mapper_ptr );
     1062        }
     1063        else
     1064        {
     1065            rpc_mapper_sync_client( parent_cxy,
     1066                                    parent_mapper_ptr,
     1067                                    &error );
     1068        }
     1069
     1070        if( error )
     1071        {
     1072            printk("\n[ERROR] in %s : cannot synchronise parent mapper to device\n",
     1073            __FUNCTION__ );
     1074            return -1;
     1075        }
     1076
     1077#if DEBUG_VFS_CLOSE
     1078if( DEBUG_VFS_CLOSE < cycle )
     1079printk("\n[%s] thread[%x,%x] synchonized mapper of parent <%s> to device\n",
     1080__FUNCTION__, process->pid, this->trdid, parent_name );
     1081#endif
     1082
     1083    }
     1084
     1085    //////// 3) loop on the process copies to reset all fd_array[file_id] entries
    9231086
    9241087    // get owner process cluster and lpid
    925     owner_cxy  = CXY_FROM_PID( process->pid );
    926     lpid       = LPID_FROM_PID( process->pid );
     1088    pid        = process->pid;
     1089    owner_cxy  = CXY_FROM_PID( pid );
     1090    lpid       = LPID_FROM_PID( pid );
    9271091
    9281092    // get extended pointers on copies root and lock
     
    9301094    lock_xp = XPTR( owner_cxy , &cluster->pmgr.copies_lock[lpid] );
    9311095
    932     // 1) loop on the process descriptor copies to reset all fd_array[file_id] entries
    933 
    9341096    // take the lock protecting the list of copies
    9351097    remote_queuelock_acquire( lock_xp );
     
    9371099    XLIST_FOREACH( root_xp , iter_xp )
    9381100    {
    939         process_xp  = XLIST_ELEMENT( iter_xp , process_t , copies_list );
    940         process_cxy = GET_CXY( process_xp );
    941         process_ptr = GET_PTR( process_xp );
    942 
    943 #if (DEBUG_VFS_CLOSE & 1 )
    944 if( DEBUG_VFS_CLOSE < cycle )
    945 printk("\n[%s]  reset fd_array[%d] for process %x in cluster %x\n",
    946 __FUNCTION__, file_id, process_ptr, process_cxy );
    947 #endif
    948 
    949 // fd_array lock is required for atomic write of a 64 bits word
    950 // xptr_t fd_array_lock_xp = XPTR( process_cxy , &process_ptr->fd_array.lock );
    951 
    952         xptr_t entry_xp         = XPTR( process_cxy , &process_ptr->fd_array.array[file_id] );
    953 
    954 // remote_rwlock_wr_acquire( fd_array_lock_xp );
    955 
     1101        xptr_t      process_xp  = XLIST_ELEMENT( iter_xp , process_t , copies_list );
     1102        cxy_t       process_cxy = GET_CXY( process_xp );
     1103        process_t * process_ptr = GET_PTR( process_xp );
     1104
     1105        xptr_t entry_xp = XPTR( process_cxy , &process_ptr->fd_array.array[file_id] );
    9561106        hal_remote_s64( entry_xp , XPTR_NULL );
    957        
    958 // remote_rwlock_wr_release( fd_array_lock_xp );
    959 
    9601107        vfs_file_count_down( file_xp );
    961 
    9621108        hal_fence();
    9631109    }   
     
    9661112    remote_queuelock_release( lock_xp );
    9671113
    968 #if (DEBUG_VFS_CLOSE & 1)
     1114#if DEBUG_VFS_CLOSE
    9691115if( DEBUG_VFS_CLOSE < cycle )
    970 printk("\n[%s] thread[%x,%x] reset all fd-array copies\n",
    971 __FUNCTION__, process->pid, this->trdid );
    972 #endif
    973 
    974     // 2) release memory allocated to file descriptor in remote cluster
    975 
    976     // get cluster and local pointer on remote file descriptor
    977     file_cxy = GET_CXY( file_xp );
    978     file_ptr = GET_PTR( file_xp );
     1116printk("\n[%s] thread[%x,%x] reset all fd-array copies for <%x>\n",
     1117__FUNCTION__, process->pid, this->trdid, name );
     1118#endif
     1119
     1120    //////// 4) release memory allocated to file descriptor in remote cluster
    9791121
    9801122    if( file_cxy == local_cxy )             // file cluster is local
     
    9901132cycle = (uint32_t)hal_get_cycles();
    9911133if( DEBUG_VFS_CLOSE < cycle )
    992 printk("\n[%s] thread[%x,%x] exit / fdid %d closed / cycle %d\n",
    993 __FUNCTION__, process->pid, this->trdid, file_id, cycle );
     1134printk("\n[%s] thread[%x,%x] exit / <%s> closed / cycle %d\n",
     1135__FUNCTION__, process->pid, this->trdid, name, cycle );
    9941136#endif
    9951137
     
    11201262    {
    11211263        error = vfs_inode_create( parent_fs_type,
    1122                                   INODE_TYPE_DIR,
    11231264                                  attr,
    11241265                                  rights,
     
    11311272        rpc_vfs_inode_create_client( inode_cxy,
    11321273                                     parent_fs_type,
    1133                                      INODE_TYPE_DIR,
    11341274                                     attr,
    11351275                                     rights,
     
    11521292    // get new inode local pointer
    11531293    inode_ptr = GET_PTR( inode_xp );
     1294
     1295    // update inode "type" field
     1296    hal_remote_s32( XPTR( inode_cxy , &inode_ptr->type ) , INODE_TYPE_DIR );
    11541297   
    11551298#if(DEBUG_VFS_MKDIR & 1)
     
    14551598    xptr_t            dentry_xp;          // extended pointer on dentry to unlink
    14561599    vfs_dentry_t    * dentry_ptr;         // local pointer on dentry to unlink
     1600    vfs_ctx_t       * ctx_ptr;            // local pointer on FS context
     1601    vfs_fs_type_t     fs_type;            // File system type
    14571602
    14581603    char              name[CONFIG_VFS_MAX_NAME_LENGTH];  // name of link to remove
     
    14661611vfs_inode_get_name( root_xp , root_name );
    14671612if( DEBUG_VFS_UNLINK < cycle )
    1468 printk("\n[%s] thread[%x,%x] enter / root <%s> / path <%s> / cycle %d\n",
     1613printk("\n[%s] thread[%x,%x] : enter for root <%s> / path <%s> / cycle %d\n",
    14691614__FUNCTION__, process->pid, this->trdid, root_name, path, cycle );
    14701615#endif
     
    15011646vfs_inode_get_name( parent_xp , parent_name );
    15021647if( DEBUG_VFS_UNLINK < cycle )
    1503 printk("\n[%s] thread[%x,%x] parent inode <%s> is (%x,%x)\n",
     1648printk("\n[%s] thread[%x,%x] : parent inode <%s> is (%x,%x)\n",
    15041649__FUNCTION__, process->pid, this->trdid, parent_name, parent_cxy, parent_ptr );
    15051650#endif
     
    15081653    xptr_t children_xp = XPTR( parent_cxy , &parent_ptr->children );
    15091654
    1510     // get extended pointer on dentry to unlink
     1655    // try to get extended pointer on dentry from Inode Tree
    15111656    dentry_xp = xhtab_lookup( children_xp , name );
    15121657   
    1513     if( dentry_xp == XPTR_NULL )
    1514     {
    1515         remote_rwlock_wr_release( lock_xp );
    1516         printk("\n[ERROR] in %s : cannot get target dentry <%s> in <%s>\n",
    1517         __FUNCTION__, name, path );
    1518         return -1;
    1519     }
    1520    
    1521     // get local pointer on dentry to unlink
    1522     dentry_ptr = GET_PTR( dentry_xp );
     1658    // when dentry not found in Inode Tree, try to get it from inode tree
     1659
     1660    if( dentry_xp == XPTR_NULL )           // miss target dentry in Inode Tree
     1661    {
    15231662
    15241663#if( DEBUG_VFS_UNLINK & 1 )
    15251664if( DEBUG_VFS_UNLINK < cycle )
    1526 printk("\n[%s] thread[%x,%x] dentry <%s> to unlink is (%x,%x)\n",
    1527 __FUNCTION__, process->pid, this->trdid, name, parent_cxy, dentry_ptr );
    1528 #endif
    1529 
    1530     // get pointer on target inode
    1531     inode_xp  = hal_remote_l64( XPTR( parent_cxy , &dentry_ptr->child_xp ) );
    1532     inode_cxy = GET_CXY( inode_xp );
    1533     inode_ptr = GET_PTR( inode_xp );
    1534  
     1665printk("\n[%s] thread[%x,%x] : inode <%s> not found => scan parent mapper\n",
     1666__FUNCTION__, process->pid, this->trdid, name );
     1667#endif
     1668        // get parent inode FS type
     1669        ctx_ptr    = hal_remote_lpt( XPTR( parent_cxy , &parent_ptr->ctx ) );
     1670        fs_type    = hal_remote_l32( XPTR( parent_cxy , &ctx_ptr->type ) );
     1671
     1672        // select a cluster for new inode
     1673        inode_cxy = cluster_random_select();
     1674
     1675        // speculatively insert a new child dentry/inode couple in inode tree
     1676        error = vfs_add_child_in_parent( inode_cxy,
     1677                                         fs_type,
     1678                                         parent_xp,
     1679                                         name,
     1680                                         &dentry_xp,
     1681                                         &inode_xp );
     1682        if( error )
     1683        {
     1684            printk("\n[ERROR] in %s : cannot create inode <%s> in path <%s>\n",
     1685            __FUNCTION__ , name, path );
     1686
     1687            vfs_remove_child_from_parent( dentry_xp );
     1688            return -1;
     1689        }
     1690
     1691        // get local pointers on new dentry and new inode descriptors
     1692        inode_ptr  = GET_PTR( inode_xp );
     1693        dentry_ptr = GET_PTR( dentry_xp );
     1694
     1695        // scan parent mapper to find the missing dentry, and complete
     1696        // initialisation of new dentry and new inode descriptors In Inode Tree
     1697        if( parent_cxy == local_cxy )
     1698        {
     1699            error = vfs_fs_new_dentry( parent_ptr,
     1700                                       name,
     1701                                       inode_xp );
     1702        }
     1703        else
     1704        {
     1705            rpc_vfs_fs_new_dentry_client( parent_cxy,
     1706                                          parent_ptr,
     1707                                          name,
     1708                                          inode_xp,
     1709                                          &error );
     1710        }
     1711
     1712        if ( error )   // dentry not found in parent mapper
     1713        {
     1714            printk("\n[ERROR] in %s : cannot get dentry <%s> in path <%s>\n",
     1715            __FUNCTION__ , name, path );
     1716            return -1;
     1717        }
     1718
     1719#if (DEBUG_VFS_UNLINK & 1)
     1720if( DEBUG_VFS_UNLINK < cycle )
     1721printk("\n[%s] thread[%x,%x] : created missing inode & dentry <%s> in cluster %x\n",
     1722__FUNCTION__, process->pid, this->trdid, name, inode_cxy );
     1723#endif
     1724
     1725    }
     1726    else                                  // found target dentry in Inode Tree
     1727    {
     1728        dentry_ptr = GET_PTR( dentry_xp );
     1729       
     1730        // get pointer on target inode from dentry
     1731        inode_xp  = hal_remote_l64( XPTR( parent_cxy , &dentry_ptr->child_xp ) );
     1732        inode_cxy = GET_CXY( inode_xp );
     1733        inode_ptr = GET_PTR( inode_xp );
     1734    }
     1735
     1736    // At this point the Inode Tree contains the target dentry and child inode
     1737    // we can safely remove this dentry from both the parent mapper, and the Inode Tree.
     1738
    15351739#if( DEBUG_VFS_UNLINK & 1 )
    1536 char inode_name[CONFIG_VFS_MAX_NAME_LENGTH];
    1537 vfs_inode_get_name( inode_xp , inode_name );
    15381740if( DEBUG_VFS_UNLINK < cycle )
    1539 printk("\n[%s] thread[%x,%x] target inode <%s> is (%x,%x) / cycle %d\n",
    1540 __FUNCTION__, process->pid, this->trdid, inode_name, inode_cxy, inode_ptr, cycle );
     1741printk("\n[%s] thread[%x,%x] : dentry (%x,%x) / inode (%x,%x)\n",
     1742__FUNCTION__, process->pid, this->trdid, parent_cxy, dentry_ptr, inode_cxy, inode_ptr );
    15411743#endif
    15421744
     
    15451747    inode_links  = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->links ) );
    15461748
    1547 // check target inode links counter
    1548 assert( (inode_links >= 1), "illegal inode links count %d for <%s>\n", inode_links, path );
    1549 
    15501749    ///////////////////////////////////////////////////////////////////////
    15511750    if( (inode_type == INODE_TYPE_FILE) || (inode_type == INODE_TYPE_DIR) )
    15521751    {
     1752
     1753#if( DEBUG_VFS_UNLINK & 1 )
     1754if( DEBUG_VFS_UNLINK < cycle )
     1755printk("\n[%s] thread[%x,%x] : unlink inode <%s> / type %s / %d links\n",
     1756__FUNCTION__, process->pid, this->trdid, name, vfs_inode_type_str(inode_type), inode_links );
     1757#endif
     1758
    15531759        // 1. Release clusters allocated to target inode
    15541760        //    and synchronize the FAT on IOC device if last link.
     
    15571763            // build extended pointer on target inode "children" number
    15581764            xptr_t inode_children_xp = XPTR( inode_cxy , &inode_ptr->children.items );
     1765
     1766printk("\n@@@ in %s : children_xp = (%x,%x)\n",
     1767__FUNCTION__, inode_cxy, &inode_ptr->children.items );
    15591768
    15601769            // get target inode number of children
     
    17131922
    17141923}  // end vfs_stat()
    1715 
    1716 /////////////////////////////////////////////
    1717 error_t vfs_readdir( xptr_t          file_xp,
    1718                      struct dirent * k_dirent )
    1719 {
    1720     assert( false , "not implemented file_xp: %x, k_dirent ptr %x\n",
    1721       file_xp, k_dirent );
    1722     return 0;
    1723 }
    1724 
    1725 ////////////////////////////////////
    1726 error_t vfs_rmdir( xptr_t   file_xp,
    1727                    char   * path )
    1728 {
    1729     assert( false , "not implemented file_xp: %x, path <%s>\n",
    1730       file_xp, path );
    1731     return 0;
    1732 }
    17331924
    17341925////////////////////////////////////
     
    21952386    cxy_t              child_cxy;    // cluster for child inode
    21962387    vfs_inode_t      * child_ptr;    // local pointer on child inode
    2197     vfs_inode_type_t   child_type;   // child inode type
    21982388    vfs_fs_type_t      fs_type;      // File system type
    21992389    vfs_ctx_t        * ctx_ptr;      // local pointer on FS context
     
    23192509                child_cxy = cluster_random_select();
    23202510
    2321                 // define child inode type
    2322                 if( dir ) child_type = INODE_TYPE_DIR;
    2323                 else      child_type = INODE_TYPE_FILE;
    2324  
    23252511                // insert a new child dentry/inode couple in inode tree
    23262512                error = vfs_add_child_in_parent( child_cxy,
    2327                                                  child_type,
    23282513                                                 fs_type,
    23292514                                                 parent_xp,
     
    23502535                if( parent_cxy == local_cxy )
    23512536                {
    2352                     error = vfs_fs_get_dentry( parent_ptr,
     2537                    error = vfs_fs_new_dentry( parent_ptr,
    23532538                                               name,
    23542539                                               child_xp );
     
    23562541                else
    23572542                {
    2358                     rpc_vfs_fs_get_dentry_client( parent_cxy,
     2543                    rpc_vfs_fs_new_dentry_client( parent_cxy,
    23592544                                                  parent_ptr,
    23602545                                                  name,
     
    29613146////////////////////////////////////////////////////////////////////
    29623147error_t vfs_add_child_in_parent( cxy_t              child_cxy,
    2963                                  vfs_inode_type_t   child_type,
    29643148                                 vfs_fs_type_t      fs_type,
    29653149                                 xptr_t             parent_inode_xp,
     
    30383222    {
    30393223        error = vfs_inode_create( fs_type,
    3040                                   child_type,
    30413224                                  attr,
    30423225                                  mode,
     
    30493232        rpc_vfs_inode_create_client( child_cxy,
    30503233                                     fs_type,
    3051                                      child_type,
    30523234                                     attr,
    30533235                                     mode,
     
    33093491
    33103492////////////////////////////////////////////////
    3311 error_t vfs_fs_get_dentry( vfs_inode_t * parent,
     3493error_t vfs_fs_new_dentry( vfs_inode_t * parent,
    33123494                           char        * name,
    33133495                           xptr_t        child_xp )
     
    33253507    if( fs_type == FS_TYPE_FATFS )
    33263508    {
    3327         error = fatfs_get_dentry( parent , name , child_xp );
     3509        error = fatfs_new_dentry( parent , name , child_xp );
    33283510    }
    33293511    else if( fs_type == FS_TYPE_RAMFS )
     
    33423524    return error;
    33433525
    3344 } // end vfs_fs_get_dentry()
     3526} // end vfs_fs_new_dentry()
     3527
     3528///////////////////////////////////////////////////
     3529error_t vfs_fs_update_dentry( vfs_inode_t  * inode,
     3530                              vfs_dentry_t * dentry,
     3531                              uint32_t       size )
     3532{
     3533    error_t error = 0;
     3534
     3535// check arguments
     3536assert( (inode  != NULL) , "inode  pointer is NULL\n");
     3537assert( (dentry != NULL) , "dentry pointer is NULL\n");
     3538
     3539    // get parent inode FS type
     3540    vfs_fs_type_t fs_type = inode->ctx->type;
     3541
     3542    // call relevant FS function
     3543    if( fs_type == FS_TYPE_FATFS )
     3544    {
     3545        error = fatfs_update_dentry( inode , dentry , size );
     3546    }
     3547    else if( fs_type == FS_TYPE_RAMFS )
     3548    {
     3549        assert( false , "should not be called for RAMFS\n" );
     3550    }
     3551    else if( fs_type == FS_TYPE_DEVFS )
     3552    {
     3553        assert( false , "should not be called for DEVFS\n" );
     3554    }
     3555    else
     3556    {
     3557        assert( false , "undefined file system type\n" );
     3558    }
     3559
     3560    return error;
     3561
     3562} // end vfs_fs_update_dentry()
    33453563
    33463564///////////////////////////////////////////////////
  • trunk/kernel/fs/vfs.h

    r614 r623  
    108108/******************************************************************************************
    109109 * This structure define a VFS inode.
    110  * An inode has several children dentries (if it is a directory), an can have several
     110 * An inode can have several children dentries (if it is a directory), an can have several
    111111 * parents dentries (if it hass several aliases links):
    112112 * - The "parents" field is the root of the xlist of parents dentries, and the "links"
     
    166166        remote_rwlock_t    size_lock;        /*! protect read/write to size                  */
    167167        remote_rwlock_t    main_lock;        /*! protect inode tree traversal and modifs     */
    168 //  list_entry_t       list;             /*! member of set of inodes in same cluster     */
    169 //  list_entry_t       wait_root;        /*! root of threads waiting on this inode       */
    170168        struct mapper_s  * mapper;           /*! associated file cache                       */
    171169        void             * extend;           /*! fs_type_specific inode extension            */
     
    195193
    196194/******************************************************************************************
    197  * This structure defines a directory entry.
     195 Rpt* This structure defines a directory entry.
    198196 * A dentry contains the name of a remote file/dir, an extended pointer on the
    199197 * inode representing this file/dir, a local pointer on the inode representing
     
    321319 *****************************************************************************************/
    322320error_t vfs_inode_create( vfs_fs_type_t     fs_type,
    323                           vfs_inode_type_t  inode_type,
    324321                          uint32_t          attr,
    325322                          uint32_t          rights,
     
    349346
    350347/******************************************************************************************
    351  * This function set the <size> of a file/dir to a remote inode,
    352  * taking the remote_rwlock protecting <size> in WRITE_MODE.
     348 * This function updates the "size" field of a remote inode identified by <inode_xp>.
     349 * It takes the rwlock protecting the file size in WRITE_MODE, and set the "size" field
     350 * when the current size is smaller than the requested <size> argument.
    353351 *****************************************************************************************
    354352 * @ inode_xp  : extended pointer on the remote inode.
    355  * @ size      : value to be written.
    356  *****************************************************************************************/
    357 void vfs_inode_set_size( xptr_t   inode_xp,
    358                          uint32_t size );
     353 * @ size      : requested size value.
     354 *****************************************************************************************/
     355void vfs_inode_update_size( xptr_t   inode_xp,
     356                            uint32_t size );
    359357
    360358/******************************************************************************************
     
    451449 * This function releases memory allocated to a local file descriptor.
    452450 * It must be executed by a thread running in the cluster containing the inode,
    453  * and the file refcount must be zero.
    454  * If the client thread is not running in the owner cluster, it must use the
    455  * rpc_vfs_file_destroy_client() function.
     451 * and the file refcount must be zero. Use the RPC_VFS_FILE_DESTROY if required.
    456452 ******************************************************************************************
    457453 * @ file  : local pointer on file descriptor.
     
    465461void vfs_file_count_up  ( xptr_t   file_xp );
    466462void vfs_file_count_down( xptr_t   file_xp );
     463
     464/******************************************************************************************
     465 * This debug function copies the name of a the file identified by <file_xp>
     466 * argument to a local buffer identified by the <name> argument.
     467 * The local buffer size must be at least CONFIG_VFS_MAX_NAME_LENGTH.
     468 *****************************************************************************************
     469 * @ file_xp  : extended pointer on the remote inode.
     470 * @ name     : local buffer pointer.
     471 *****************************************************************************************/
     472void vfs_file_get_name( xptr_t inode_xp,
     473                        char * name );
    467474
    468475
     
    537544 * Only the distributed Inode Tree is modified: it does NOT modify the parent mapper,
    538545 * and does NOT update the FS on IOC device.
     546 * It set the inode type to the default INODE_TYPE_FILE value
    539547 * It can be executed by any thread running in any cluster (can be different from both
    540548 * the child cluster and the parent cluster).
     
    552560 ******************************************************************************************
    553561 * @ child_inode_cxy  : [in]  target cluster for child inode.
    554  * @ child_inode_type : [in]  child inode type
    555562 * @ fs_type          : [in]  child inode FS type.
    556563 * @ parent_inode_xp  : [in]  extended pointer on parent inode.
     
    561568 *****************************************************************************************/
    562569error_t vfs_add_child_in_parent( cxy_t              child_inode_cxy,
    563                                  vfs_inode_type_t   child_inode_type,
    564570                                 vfs_fs_type_t      fs_type,
    565571                                 xptr_t             parent_inode_xp,
     
    729735/******************************************************************************************
    730736 * This function close the - non-replicated - file descriptor identified by the <file_xp>
    731  * and <file_id> arguments.
    732  * 1) All entries in the fd_array copies are directly reset by the calling thread,
     737 * and <file_id> arguments. The <file_id> is required to reset the fd_array[] slot.
     738 * It can be called by a thread running in any cluster, and executes the following actions:
     739 * 1) It access the block device to updates all dirty pages from the mapper associated
     740 *    to the file, and removes these pages from the dirty list, using an RPC if required.
     741 * 2) It updates the file size in all parent directory mapper(s), and update the modified
     742 *    pages on the block device, using RPCs if required.
     743 * 3) All entries in the fd_array copies are directly reset by the calling thread,
    733744 *    using remote accesses.
    734  * 2) The memory allocated to file descriptor in cluster containing the inode is released.
    735  *    It requires a RPC if cluster containing the file descriptor is remote.
    736  ******************************************************************************************
    737  * @ file_xp     : extended pointer on the file descriptor in owner cluster.
    738  * @ file_id     : file descriptor index in fd_array.
     745 * 4) The memory allocated to file descriptor in cluster containing the inode is released,
     746 *    using an RPC if cluster containing the file descriptor is remote.
     747 ******************************************************************************************
     748 * @ file_xp     : extended pointer on the file descriptor.
     749 * @ file_id     : file descriptor index in fd_array[].
    739750 * @ returns 0 if success / -1 if error.
    740751 *****************************************************************************************/
     
    877888/******************************************************************************************
    878889 * This function makes the I/O operation to move one page identified by the <page_xp>
    879  * argument to/from the IOC device from/to the mapper, as defined by <cmd_type>.
     890 * argument to/from the IOC device from/to the mapper, as defined by the <cmd_type>.
    880891 * Depending on the file system type, it calls the proper, FS specific function.
    881892 * It is used in case of MISS on the mapper, or when a dirty page in the mapper must
     
    918929 * Finally, it synchronously updates the parent directory on IOC device.
    919930 *
     931 * Depending on the file system type, it calls the relevant, FS specific function.
    920932 * It must be executed by a thread running in the cluster containing the parent directory.
    921  * It can be the RPC_VFS_VS_REMOVE_DENTRY. This function does NOT take any lock.
     933 * It can be the RPC_VFS_FS_REMOVE_DENTRY. This function does NOT take any lock.
    922934 ******************************************************************************************
    923935 * @ parent  : local pointer on parent (directory) inode.
     
    933945 * and updates both the child inode descriptor, identified by the <child_xp> argument,
    934946 * and the associated dentry descriptor :
    935  * - It set the "size", and "extend" fields in inode descriptor.
     947 * - It set the "size", "type", and "extend" fields in inode descriptor.
    936948 * - It set the "extend" field in dentry descriptor.
    937949 * It is called by the vfs_lookup() function in case of miss.
     
    939951 * Depending on the file system type, it calls the relevant, FS specific function.
    940952 * It must be called by a thread running in the cluster containing the parent inode.
    941  * This function does NOT take any lock.
     953 * It can be the RPC_VFS_FS_NEW_DENTRY. This function does NOT take any lock.
    942954 ******************************************************************************************
    943955 * @ parent    : local pointer on parent inode (directory).
    944956 * @ name      : child name.
    945957 * @ child_xp  : extended pointer on remote child inode (file or directory)
    946  * @ return 0 if success / return ENOENT if not found.
    947  *****************************************************************************************/
    948 error_t vfs_fs_get_dentry( vfs_inode_t * parent,
     958 * @ return 0 if success / return -1 if dentry not found.
     959 *****************************************************************************************/
     960error_t vfs_fs_new_dentry( vfs_inode_t * parent,
    949961                           char        * name,
    950962                           xptr_t        child_xp );
     963
     964/******************************************************************************************
     965 * This function scan the mapper of an an existing inode directory, identified by
     966 * the <inode> argument, to find a directory entry identified by the <dentry> argument,
     967 * and update the size for this directory entry in mapper, as defined by <size>.
     968 * The searched "name" is defined in the <dentry> argument, that must be in the same
     969 * cluster as the parent inode. It is called by the vfs_close() function.
     970 *
     971 * Depending on the file system type, it calls the relevant, FS specific function.
     972 * It must be called by a thread running in the cluster containing the parent inode.
     973 * It can be the RPC_VFS_FS_UPDATE_DENTRY. This function does NOT take any lock.
     974 ******************************************************************************************
     975 * @ parent    : local pointer on parent inode (directory).
     976 * @ dentry    : local pointer on dentry.
     977 * @ size      : new size value (bytes).
     978 * @ return 0 if success / return ENOENT if not found.
     979 *****************************************************************************************/
     980error_t vfs_fs_update_dentry( vfs_inode_t  * inode,
     981                              vfs_dentry_t * dentry,
     982                              uint32_t       size );
    951983
    952984/******************************************************************************************
Note: See TracChangeset for help on using the changeset viewer.