Ignore:
Timestamp:
Jan 15, 2019, 1:59:32 PM (5 years ago)
Author:
alain
Message:

1) introduce a dev_ioc_sync_write() function in IOC API,

to improve the DEVFS synchronous update.

2) fix a big bug in both the user_dir_create() and user_dir_destroy()

functions: add an extended pointer on the reference client process
in the function's arguments.

File:
1 edited

Legend:

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

    r612 r614  
    10641064        {
    10651065            // copy the modified page to IOC device
    1066             fatfs_move_page( page_xp , false );   
     1066            fatfs_move_page( page_xp , IOC_SYNC_WRITE );   
    10671067
    10681068            // get the next page in FAT mapper
     
    12171217
    12181218    // copy the modified page to the IOC device
    1219     fatfs_move_page( page_xp , false );   
     1219    fatfs_move_page( page_xp , IOC_SYNC_WRITE );   
    12201220
    12211221#if DEBUG_FATFS_ADD_DENTRY
    12221222cycle = (uint32_t)hal_get_cycles();
    12231223if( DEBUG_FATFS_ADD_DENTRY < cycle )
    1224 printk("\n[%s]  thread[%x,%x] exit / parent %s / child %s / cycle %d\n",
     1224printk("\n[%s]  thread[%x,%x] exit / parent <%s> / child <%s> / cycle %d\n",
    12251225__FUNCTION__, this->process->pid, this->trdid, dir_name, dentry->name, cycle );
    12261226#endif
     
    13131313
    13141314            // copy the modified page to the IOC device
    1315             fatfs_move_page( page_xp , false );   
     1315            fatfs_move_page( page_xp , IOC_SYNC_WRITE );   
    13161316
    13171317            // get extended pointer on page descriptor from parent directory mapper
     
    13451345
    13461346    // copy the modified page to the IOC device
    1347     fatfs_move_page( page_xp , false );   
     1347    fatfs_move_page( page_xp , IOC_SYNC_WRITE );   
    13481348   
    13491349
     
    13961396    xptr_t     base_xp;          // extended pointer on page base
    13971397    uint8_t  * base;             // local pointer on page base
    1398     uint32_t   attr;             // directory entry ATTR field
    1399     uint32_t   ord;              // directory entry ORD field
     1398    uint8_t    attr;             // directory entry ATTR field
     1399    uint8_t    ord;              // directory entry ORD field
    14001400    uint32_t   seq;              // sequence index
    14011401    uint32_t   lfn       = 0;    // LFN entries number
     
    14221422#if (DEBUG_FATFS_GET_DENTRY & 0x1)
    14231423if( DEBUG_FATFS_GET_DENTRY < cycle )
    1424 mapper_display_page( mapper_xp , page_id , 256 , parent_name );
     1424mapper_display_page( mapper_xp , page_id , 256 );
    14251425#endif
    14261426        // scan this page until end of directory, end of page, or name found
     
    14351435            }
    14361436            else if ( ord == FREE_ENTRY )             // free entry => skip
     1437            {
     1438                offset = offset + 32;
     1439            }
     1440            else if ( attr == 0x28 )                  // volune_id => skip
    14371441            {
    14381442                offset = offset + 32;
     
    15771581assert( (detailed == false), "detailed argument not supported/n");
    15781582
    1579     char       cname[CONFIG_VFS_MAX_NAME_LENGTH];  // name extracter from each directory entry
     1583    char       cname[CONFIG_VFS_MAX_NAME_LENGTH];  // name extracted from each dentry
    15801584
    15811585    char       lfn1[16];           // buffer for one partial cname
     
    15851589    xptr_t     base_xp;            // extended pointer on page base
    15861590    uint8_t  * base;               // local pointer on page base
    1587     uint32_t   attr;               // directory entry ATTR field
    1588     uint32_t   ord;                // directory entry ORD field
     1591    uint8_t    attr;               // directory entry ATTR field
     1592    uint8_t    ord;                // directory entry ORD field
    15891593    uint32_t   seq;                // sequence index
    15901594    uint32_t   lfn       = 0;      // LFN entries number
     
    16091613#if (DEBUG_FATFS_GET_USER_DIR & 0x1)
    16101614if( DEBUG_FATFS_GET_USER_DIR < cycle )
    1611 mapper_display_page( mapper_xp , page_id , 256 , inode_name );
     1615mapper_display_page( mapper_xp , page_id , 256 );
    16121616#endif
    16131617        // loop on NORMAL/LFN (32 bytes) directory entries in this page
     
    16251629            }
    16261630            else if ( ord == FREE_ENTRY )             // free entry => skip
     1631            {
     1632                offset = offset + 32;
     1633            }
     1634            else if ( attr == 0x28 )                  // volune_id => skip
    16271635            {
    16281636                offset = offset + 32;
     
    16931701if( DEBUG_FATFS_GET_USER_DIR < cycle )
    16941702printk("\n[%s]  thread[%x,%x] exit for inode <%s> / %d entries / cycle %d\n",
    1695 __FUNCTION__, this->process->pid, this->trdid, inode_name, entries, cycle );
     1703__FUNCTION__, this->process->pid, this->trdid, inode_name, dirent_id, cycle );
    16961704#endif
    16971705
     
    17561764
    17571765                // move page from mapper to device
    1758                 error = fatfs_move_page( page_xp , false );
     1766                error = fatfs_move_page( page_xp , IOC_WRITE );
    17591767
    17601768                if ( error )  return -1;
     
    18271835#endif
    18281836                // move page from mapper to device
    1829                 error = fatfs_move_page( page_xp , false );
     1837                error = fatfs_move_page( page_xp , IOC_SYNC_WRITE );
    18301838
    18311839                if ( error )  return -1;
     
    21322140}  // end fatfs_release_inode()
    21332141
    2134 /////////////////////////////////////////
    2135 error_t fatfs_move_page( xptr_t  page_xp,
    2136                          bool_t  to_mapper )
     2142////////////////////////////////////////////
     2143error_t fatfs_move_page( xptr_t     page_xp,
     2144                         cmd_type_t cmd_type )
    21372145{
    21382146    error_t       error;
     
    21722180 
    21732181        // access device
    2174         if( to_mapper ) error = dev_ioc_sync_read ( buffer , lba , 8 );
    2175         else            error = dev_ioc_write( buffer , lba , 8 );     
     2182        if     ( cmd_type == IOC_SYNC_READ  ) error = dev_ioc_sync_read ( buffer , lba , 8 );
     2183        else if( cmd_type == IOC_SYNC_WRITE ) error = dev_ioc_sync_write( buffer , lba , 8 );
     2184        else if( cmd_type == IOC_READ       ) error = dev_ioc_read      ( buffer , lba , 8 );
     2185        else if( cmd_type == IOC_WRITE      ) error = dev_ioc_write     ( buffer , lba , 8 );
     2186        else                                  error = -1;
    21762187
    21772188        if( error ) return EIO;
     
    21792190#if (DEBUG_FATFS_MOVE_PAGE & 0x1)
    21802191if( DEBUG_FATFS_MOVE_PAGE < cycle )
    2181 mapper_display_page( XPTR(page_cxy , mapper_ptr) , page_id , "FAT" );
     2192mapper_display_page( XPTR(page_cxy , mapper_ptr) , page_id );
    21822193#endif
    21832194
     
    21862197if( DEBUG_FATFS_MOVE_PAGE < cycle )
    21872198{
    2188     if (to_mapper)
     2199    if ( (cmd_type == IOC_READ) || (cmd_type == IOC_SYNC_READ) )
    21892200         printk("\n[%s] thread[%x,%x] load page %d of FAT / cycle %d\n",
    21902201         __FUNCTION__, this->process->pid, this->trdid, page_id, cycle );
     
    22302241
    22312242        // access device
    2232         if( to_mapper ) error = dev_ioc_sync_read ( buffer , lba , 8 );
    2233         else            error = dev_ioc_write( buffer , lba , 8 );     
     2243        if     ( cmd_type == IOC_SYNC_READ  ) error = dev_ioc_sync_read ( buffer , lba , 8 );
     2244        else if( cmd_type == IOC_SYNC_WRITE ) error = dev_ioc_sync_write( buffer , lba , 8 );
     2245        else if( cmd_type == IOC_READ       ) error = dev_ioc_read      ( buffer , lba , 8 );
     2246        else if( cmd_type == IOC_WRITE      ) error = dev_ioc_write     ( buffer , lba , 8 );
     2247        else                                  error = -1;
    22342248
    22352249        if( error ) return EIO;
     
    22372251#if (DEBUG_FATFS_MOVE_PAGE & 0x1)
    22382252if( DEBUG_FATFS_MOVE_PAGE < cycle )
    2239 char string[CONFIG_VFS_MAX_NAME_LENGTH];
    2240 vfs_inode_get_name( XPTR(page_cxy , inode_ptr) , string );
    2241 mapper_display_page( XPTR(page_cxy , mapper_ptr) , page_id , string );
     2253mapper_display_page( XPTR(page_cxy , mapper_ptr) , page_id );
    22422254#endif
    22432255
     
    22462258if(DEBUG_FATFS_MOVE_PAGE < cycle)
    22472259{
    2248     if(to_mapper)
     2260    if ( (cmd_type == IOC_READ) || (cmd_type == IOC_SYNC_READ) )
    22492261        printk("\n[%s] thread[%x,%x] load page %d of <%s> inode / cycle %d\n",
    22502262        __FUNCTION__, this->process->pid, this->trdid, page_id, name, cycle );
Note: See TracChangeset for help on using the changeset viewer.