Changeset 623 for trunk/kernel/fs/vfs.c


Ignore:
Timestamp:
Mar 6, 2019, 4:37:15 PM (5 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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///////////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.