Changeset 614 for trunk/kernel/fs/fatfs.c
- Timestamp:
- Jan 15, 2019, 1:59:32 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/fs/fatfs.c
r612 r614 1064 1064 { 1065 1065 // copy the modified page to IOC device 1066 fatfs_move_page( page_xp , false);1066 fatfs_move_page( page_xp , IOC_SYNC_WRITE ); 1067 1067 1068 1068 // get the next page in FAT mapper … … 1217 1217 1218 1218 // copy the modified page to the IOC device 1219 fatfs_move_page( page_xp , false);1219 fatfs_move_page( page_xp , IOC_SYNC_WRITE ); 1220 1220 1221 1221 #if DEBUG_FATFS_ADD_DENTRY 1222 1222 cycle = (uint32_t)hal_get_cycles(); 1223 1223 if( DEBUG_FATFS_ADD_DENTRY < cycle ) 1224 printk("\n[%s] thread[%x,%x] exit / parent %s / child %s/ cycle %d\n",1224 printk("\n[%s] thread[%x,%x] exit / parent <%s> / child <%s> / cycle %d\n", 1225 1225 __FUNCTION__, this->process->pid, this->trdid, dir_name, dentry->name, cycle ); 1226 1226 #endif … … 1313 1313 1314 1314 // copy the modified page to the IOC device 1315 fatfs_move_page( page_xp , false);1315 fatfs_move_page( page_xp , IOC_SYNC_WRITE ); 1316 1316 1317 1317 // get extended pointer on page descriptor from parent directory mapper … … 1345 1345 1346 1346 // copy the modified page to the IOC device 1347 fatfs_move_page( page_xp , false);1347 fatfs_move_page( page_xp , IOC_SYNC_WRITE ); 1348 1348 1349 1349 … … 1396 1396 xptr_t base_xp; // extended pointer on page base 1397 1397 uint8_t * base; // local pointer on page base 1398 uint 32_tattr; // directory entry ATTR field1399 uint 32_tord; // directory entry ORD field1398 uint8_t attr; // directory entry ATTR field 1399 uint8_t ord; // directory entry ORD field 1400 1400 uint32_t seq; // sequence index 1401 1401 uint32_t lfn = 0; // LFN entries number … … 1422 1422 #if (DEBUG_FATFS_GET_DENTRY & 0x1) 1423 1423 if( DEBUG_FATFS_GET_DENTRY < cycle ) 1424 mapper_display_page( mapper_xp , page_id , 256 , parent_name);1424 mapper_display_page( mapper_xp , page_id , 256 ); 1425 1425 #endif 1426 1426 // scan this page until end of directory, end of page, or name found … … 1435 1435 } 1436 1436 else if ( ord == FREE_ENTRY ) // free entry => skip 1437 { 1438 offset = offset + 32; 1439 } 1440 else if ( attr == 0x28 ) // volune_id => skip 1437 1441 { 1438 1442 offset = offset + 32; … … 1577 1581 assert( (detailed == false), "detailed argument not supported/n"); 1578 1582 1579 char cname[CONFIG_VFS_MAX_NAME_LENGTH]; // name extracte r from each directoryentry1583 char cname[CONFIG_VFS_MAX_NAME_LENGTH]; // name extracted from each dentry 1580 1584 1581 1585 char lfn1[16]; // buffer for one partial cname … … 1585 1589 xptr_t base_xp; // extended pointer on page base 1586 1590 uint8_t * base; // local pointer on page base 1587 uint 32_tattr; // directory entry ATTR field1588 uint 32_tord; // directory entry ORD field1591 uint8_t attr; // directory entry ATTR field 1592 uint8_t ord; // directory entry ORD field 1589 1593 uint32_t seq; // sequence index 1590 1594 uint32_t lfn = 0; // LFN entries number … … 1609 1613 #if (DEBUG_FATFS_GET_USER_DIR & 0x1) 1610 1614 if( DEBUG_FATFS_GET_USER_DIR < cycle ) 1611 mapper_display_page( mapper_xp , page_id , 256 , inode_name);1615 mapper_display_page( mapper_xp , page_id , 256 ); 1612 1616 #endif 1613 1617 // loop on NORMAL/LFN (32 bytes) directory entries in this page … … 1625 1629 } 1626 1630 else if ( ord == FREE_ENTRY ) // free entry => skip 1631 { 1632 offset = offset + 32; 1633 } 1634 else if ( attr == 0x28 ) // volune_id => skip 1627 1635 { 1628 1636 offset = offset + 32; … … 1693 1701 if( DEBUG_FATFS_GET_USER_DIR < cycle ) 1694 1702 printk("\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 ); 1696 1704 #endif 1697 1705 … … 1756 1764 1757 1765 // move page from mapper to device 1758 error = fatfs_move_page( page_xp , false);1766 error = fatfs_move_page( page_xp , IOC_WRITE ); 1759 1767 1760 1768 if ( error ) return -1; … … 1827 1835 #endif 1828 1836 // move page from mapper to device 1829 error = fatfs_move_page( page_xp , false);1837 error = fatfs_move_page( page_xp , IOC_SYNC_WRITE ); 1830 1838 1831 1839 if ( error ) return -1; … … 2132 2140 } // end fatfs_release_inode() 2133 2141 2134 ///////////////////////////////////////// 2135 error_t fatfs_move_page( xptr_t page_xp,2136 bool_t to_mapper)2142 //////////////////////////////////////////// 2143 error_t fatfs_move_page( xptr_t page_xp, 2144 cmd_type_t cmd_type ) 2137 2145 { 2138 2146 error_t error; … … 2172 2180 2173 2181 // 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; 2176 2187 2177 2188 if( error ) return EIO; … … 2179 2190 #if (DEBUG_FATFS_MOVE_PAGE & 0x1) 2180 2191 if( DEBUG_FATFS_MOVE_PAGE < cycle ) 2181 mapper_display_page( XPTR(page_cxy , mapper_ptr) , page_id , "FAT");2192 mapper_display_page( XPTR(page_cxy , mapper_ptr) , page_id ); 2182 2193 #endif 2183 2194 … … 2186 2197 if( DEBUG_FATFS_MOVE_PAGE < cycle ) 2187 2198 { 2188 if ( to_mapper)2199 if ( (cmd_type == IOC_READ) || (cmd_type == IOC_SYNC_READ) ) 2189 2200 printk("\n[%s] thread[%x,%x] load page %d of FAT / cycle %d\n", 2190 2201 __FUNCTION__, this->process->pid, this->trdid, page_id, cycle ); … … 2230 2241 2231 2242 // 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; 2234 2248 2235 2249 if( error ) return EIO; … … 2237 2251 #if (DEBUG_FATFS_MOVE_PAGE & 0x1) 2238 2252 if( 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 ); 2253 mapper_display_page( XPTR(page_cxy , mapper_ptr) , page_id ); 2242 2254 #endif 2243 2255 … … 2246 2258 if(DEBUG_FATFS_MOVE_PAGE < cycle) 2247 2259 { 2248 if (to_mapper)2260 if ( (cmd_type == IOC_READ) || (cmd_type == IOC_SYNC_READ) ) 2249 2261 printk("\n[%s] thread[%x,%x] load page %d of <%s> inode / cycle %d\n", 2250 2262 __FUNCTION__, this->process->pid, this->trdid, page_id, name, cycle );
Note: See TracChangeset
for help on using the changeset viewer.