Changeset 401 for trunk/kernel/vfs
- Timestamp:
- Aug 17, 2017, 3:02:18 PM (7 years ago)
- Location:
- trunk/kernel/vfs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/vfs/fatfs.c
r367 r401 26 26 #include <hal_special.h> 27 27 #include <printk.h> 28 #include <thread.h> 28 29 #include <kmem.h> 29 30 #include <ppm.h> … … 462 463 bool_t to_mapper ) 463 464 { 464 error_t error; 465 error_t error; 466 vfs_inode_t * inode; 467 mapper_t * mapper; 468 uint32_t index; // page index in mapper 469 uint8_t * buffer; // page base address in mapper 470 uint32_t count; // number of sectors in a page 471 uint32_t lba; // block address on device 472 fatfs_ctx_t * fatfs_ctx; // pointer on local FATFS context 465 473 466 474 // get pointer on source mapper and page index from page descriptor 467 mapper _t * mapper= page->mapper;468 uint32_tindex = page->index;475 mapper = page->mapper; 476 index = page->index; 469 477 470 478 // get VFS inode pointer from mapper 471 vfs_inode_t *inode = mapper->inode;472 473 fatfs_dmsg("\n[INFO] %s : enter for inode %x / page_index= %d / mapper = %x\n",474 __FUNCTION__, inode , index , mapper );475 476 // get memory bufferbase address479 inode = mapper->inode; 480 481 fatfs_dmsg("\n[INFO] %s : core[%x,%d] enter for inode %x / page_id = %d / mapper = %x\n", 482 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , inode , index , mapper ); 483 484 // get page to move base address 477 485 xptr_t base_xp = ppm_page2base( XPTR( local_cxy , page ) ); 478 uint8_t *buffer = (uint8_t *)GET_PTR( base_xp );486 buffer = (uint8_t *)GET_PTR( base_xp ); 479 487 480 // get number of sectors f rom FATFS context481 fatfs_ctx _t * fatfs_ctx= (fatfs_ctx_t *)fs_context[FS_TYPE_FATFS].extend;482 uint32_tcount = fatfs_ctx->sectors_per_cluster;483 484 // analyse the mapper type : FAT ornormal inode485 if( inode == NULL ) // it is the FAT mapper488 // get number of sectors for one page (from FATFS context) 489 fatfs_ctx = (fatfs_ctx_t *)fs_context[FS_TYPE_FATFS].extend; 490 count = fatfs_ctx->sectors_per_cluster; 491 492 // test FAT/normal inode 493 if( inode == NULL ) // it is the FAT mapper 486 494 { 487 495 // get lba from page index 488 uint32_tlba = fatfs_ctx->fat_begin_lba + (count * index);496 lba = fatfs_ctx->fat_begin_lba + (count * index); 489 497 490 fatfs_dmsg("\n[INFO] %s : for FAT/ lba = %d\n",491 __FUNCTION__, lba );498 fatfs_dmsg("\n[INFO] %s : core[%x,%d] access FAT on device / lba = %d\n", 499 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , lba ); 492 500 493 501 // access device … … 496 504 497 505 if( error ) return EIO; 498 499 fatfs_dmsg("\n[INFO] %s : exit for FAT / page_index = %d / mapper = %x\n", 500 __FUNCTION__ , index , mapper ); 501 } 502 else // it is a normal inode mapper 506 } 507 else // it is a normal inode mapper 503 508 { 504 509 uint32_t searched_cluster_id; … … 506 511 // get first_cluster_id from inode extension 507 512 uint32_t first_cluster_id = (uint32_t)(intptr_t)inode->extend; 508 509 fatfs_dmsg("\n[INFO] %s : for inode %x / first_cluster_id = %d\n",510 __FUNCTION__ , inode , first_cluster_id );511 513 512 514 // compute cluster_id … … 544 546 545 547 // get lba from cluster_id 546 uint32_tlba = fatfs_lba_from_cluster( fatfs_ctx , searched_cluster_id );547 548 fatfs_dmsg("\n[INFO] %s : for inode %x / page = %d / cluster_id = %d / lba = %x\n",549 __FUNCTION__ , inode , index , searched_cluster_id , lba);548 lba = fatfs_lba_from_cluster( fatfs_ctx , searched_cluster_id ); 549 550 fatfs_dmsg("\n[INFO] %s : core[%x,%d] access device for inode %x / cluster_id = %d\n", 551 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , inode , first_cluster_id ); 550 552 551 553 // access device … … 554 556 555 557 if( error ) return EIO; 556 557 fatfs_dmsg("\n[INFO] %s : exit for inode %x / page_index = %d / mapper = %x\n", 558 __FUNCTION__ , inode , index , mapper );559 }558 } 559 560 fatfs_dmsg("\n[INFO] %s : core[%x,%d] exit for inode %x / page_id = %d / mapper = %x\n", 561 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , inode , index , mapper ); 560 562 561 563 return 0; -
trunk/kernel/vfs/fatfs.h
r367 r401 249 249 * It must be called by a thread running in cluster containing the mapper. 250 250 * The pointer on the mapper and the page index in file are found in the page descriptor. 251 * WARNING : The inode field in the mapper must be NULL for the FAT mapper.252 * Thisis used to implement a specific behaviour to access the FAT zone on device.251 * WARNING : The inode field in the mapper MUST be NULL for the FAT mapper, as this 252 * is used to implement a specific behaviour to access the FAT zone on device. 253 253 ***************************************************************************************** 254 254 * @ page : local pointer on page descriptor. -
trunk/kernel/vfs/vfs.c
r395 r401 156 156 error_t error; 157 157 158 vfs_dmsg("\n[INFO] %s : enter / local_cxy = %x / parent_xp = %l\n",159 __FUNCTION__ , local_cxy , dentry_xp );158 vfs_dmsg("\n[INFO] %s : core[%x,%d] enter / dentry_xp = %l\n", 159 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , dentry_xp ); 160 160 161 161 // check fs type and get pointer on context … … 229 229 remote_spinlock_init( XPTR( local_cxy , &inode->main_lock ) ); 230 230 231 vfs_dmsg("\n[INFO] %s : exit / child_xp = %l / parent_xp = %l\n",232 __FUNCTION__ , XPTR( local_cxy , inode ), dentry_xp );233 231 vfs_dmsg("\n[INFO] %s : core[%x,%d] exit / inode_xp = %l / dentry_xp = %l\n", 232 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, XPTR(local_cxy,inode), dentry_xp ); 233 234 234 // return extended pointer on inode 235 235 *inode_xp = XPTR( local_cxy , inode ); … … 262 262 xptr_t child_xp ) 263 263 { 264 vfs_dmsg("\n[INFO] %s : enter for child <%s>\n",265 __FUNCTION__ , name);264 vfs_dmsg("\n[INFO] %s : core[%x,%d] enter for <%s> / cycle %d\n", 265 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , name , hal_time_stamp() ); 266 266 267 267 error_t error = 0; … … 292 292 } 293 293 294 vfs_dmsg("\n[INFO] %s : exit for child <%s>\n",295 __FUNCTION__ , name);294 vfs_dmsg("\n[INFO] %s : core[%x,%d] exit for <%s> / cycle %d\n", 295 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , name , hal_time_stamp() ); 296 296 297 297 return error; … … 435 435 kmem_req_t req; // request to kernel memory allocator 436 436 437 vfs_dmsg("\n[INFO] %s : enter for %s / parent inode = %x / cycle =%d\n",438 __FUNCTION__ , name , parent, hal_time_stamp() );437 vfs_dmsg("\n[INFO] %s : core[%x,%d] enter for <%s> / parent inode = %x / cycle %d\n", 438 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, name, parent, hal_time_stamp() ); 439 439 440 440 // get pointer on context … … 484 484 *dentry_xp = XPTR( local_cxy , dentry ); 485 485 486 vfs_dmsg("\n[INFO] %s : exit for %s / cycle =%d\n",487 __FUNCTION__ , name, hal_time_stamp() );486 vfs_dmsg("\n[INFO] %s : core[%x,%d] exit for <%s> / dentry = %l / cycle %d\n", 487 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, name, *dentry_xp, hal_time_stamp() ); 488 488 489 489 return 0; … … 603 603 uint32_t file_id; // created file descriptor index in reference fd_array 604 604 605 vfs_dmsg("\n[INFO] %s : enters for <%s> atcycle %d\n",606 __FUNCTION__ , path, (uint32_t)hal_time_stamp() );605 vfs_dmsg("\n[INFO] %s : core[%x,%d] enter for <%s> / cycle %d\n", 606 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, path, (uint32_t)hal_time_stamp() ); 607 607 608 608 // compute lookup working mode … … 623 623 error = vfs_lookup( cwd_xp , path , lookup_mode , &inode_xp ); 624 624 625 vfs_dmsg("\n[INFO] %s : get inode_xp = %l for <%s> at cycle %d\n",626 __FUNCTION__ , inode_xp , path , hal_get_cycles() );627 628 625 if( error ) return error; 629 626 … … 649 646 if( error ) return error; 650 647 651 vfs_dmsg("\n[INFO] %s : exit for <%s> / file_id = %d / file_xp = %l / atcycle %d\n",652 __FUNCTION__ , path , file_id , file_xp , hal_get_cycles() );648 vfs_dmsg("\n[INFO] %s : core[%x,%d] exit for <%s> / file_xp = %l / cycle %d\n", 649 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, path, file_xp, hal_time_stamp() ); 653 650 654 651 // success … … 1185 1182 1186 1183 // print header 1187 nolock_printk("\n***** file system state\n ");1184 nolock_printk("\n***** file system state\n\n"); 1188 1185 1189 1186 // call recursive function … … 1341 1338 process = this->process; 1342 1339 1343 vfs_dmsg("\n[INFO] %s : enter for <%s> / core[%x,%d]/ cycle %d\n",1344 __FUNCTION__ , pathname , local_cxy , this->core->lid, hal_time_stamp() );1340 vfs_dmsg("\n[INFO] %s : core[%x,%d] enter for <%s> / cycle %d\n", 1341 __FUNCTION__ , local_cxy , this->core->lid , pathname , hal_time_stamp() ); 1345 1342 1346 1343 // get extended pointer on first inode to search … … 1357 1354 vfs_inode_lock( parent_xp ); 1358 1355 1359 // load from device if one intermediate node not found 1360 // exit while loop when last name found (i.e. last == true) 1356 // sequencially loop on nodes in pathname 1357 // load from device if one node not found in inode tree 1358 // exit loop when last name found (i.e. last == true) 1361 1359 do 1362 1360 { 1363 // get one name from path, and the"last" flag1361 // get one name from path, and "last" flag 1364 1362 vfs_get_name_from_path( current , name , &next , &last ); 1365 1363 1366 vfs_dmsg("\n[INFO] %s : looking for <%s> / core[%x,%d]/ last = %d\n",1367 __FUNCTION__ , name , local_cxy , this->core->lid, last );1364 vfs_dmsg("\n[INFO] %s : core[%x,%d] look for <%s> / last = %d\n", 1365 __FUNCTION__ , local_cxy , this->core->lid , name , last ); 1368 1366 1369 1367 // search a child dentry matching name in parent inode … … 1382 1380 if (found == false ) // child node not found in inode tree 1383 1381 { 1384 vfs_dmsg("\n[INFO] %s : <%s> not found => load it / core[%x,%d]\n",1385 __FUNCTION__ , local_cxy , this->core->lid );1382 vfs_dmsg("\n[INFO] %s : core[%x,%d] miss <%s> => load it\n", 1383 __FUNCTION__ , local_cxy , this->core->lid , name ); 1386 1384 1387 1385 // release lock on parent inode … … 1391 1389 parent_cxy = GET_CXY( parent_xp ); 1392 1390 parent_ptr = (vfs_inode_t *)GET_PTR( parent_xp ); 1393 1394 ctx_ptr = (vfs_ctx_t *)hal_remote_lpt( XPTR( parent_cxy , 1395 &parent_ptr->ctx ) ); 1391 ctx_ptr = (vfs_ctx_t *)hal_remote_lpt( XPTR( parent_cxy , &parent_ptr->ctx ) ); 1396 1392 fs_type = hal_remote_lw( XPTR( parent_cxy , &ctx_ptr->type ) ); 1397 1393 1398 1394 // select a cluster for missing inode 1399 1395 child_cxy = vfs_cluster_random_select(); 1400 1396 1401 1397 // insert a new child dentry/inode in parent inode 1402 1398 error = vfs_add_child_in_parent( child_cxy, … … 1467 1463 // take lock on parent inode 1468 1464 vfs_inode_lock( parent_xp ); 1465 1466 vfs_dmsg("\n[INFO] %s : core[%x,%d] created node <%s>\n", 1467 __FUNCTION__ , local_cxy , this->core->lid , name ); 1469 1468 } 1470 1469 1471 vfs_dmsg("\n[INFO] %s : found <%s> / core[%x,%d]/ parent = %l / child = %l\n",1472 __FUNCTION__ , name , local_cxy , this->core->lid, parent_xp , child_xp );1470 vfs_dmsg("\n[INFO] %s : core[%x,%d] found <%s> / parent = %l / child = %l\n", 1471 __FUNCTION__ , local_cxy , this->core->lid , name , parent_xp , child_xp ); 1473 1472 1474 1473 // TODO check access rights here [AG] … … 1519 1518 // implementation note: 1520 1519 // we use two variables "index" and "count" because the buffer 1521 // is actuallywritten in decreasing index order (from leaf to root)1522 // TODO : handle conflict with a concurrent rename 1523 // FIXME : handle synchro in the loop ...[AG]1520 // is written in decreasing index order (from leaf to root) 1521 // TODO : handle conflict with a concurrent rename [AG] 1522 // TODO : handle synchro in the loop [AG] 1524 1523 1525 1524 // set the NUL character in buffer / initialise buffer index and count … … 1606 1605 1607 1606 vfs_dmsg("\n[INFO] %s : dentry <%s> created in local cluster %x\n", 1608 1607 __FUNCTION__ , name , local_cxy ); 1609 1608 } 1610 1609 else // parent cluster is remote … … 1618 1617 1619 1618 vfs_dmsg("\n[INFO] %s : dentry <%s> created in remote cluster %x\n", 1620 1619 __FUNCTION__ , name , parent_cxy ); 1621 1620 } 1622 1621 … … 1708 1707 assert( (mapper != NULL) , __FUNCTION__ , "no mapper for page\n" ); 1709 1708 1710 vfs_dmsg("\n[INFO] %s : enters for page %d in mapper / inode %l\n",1709 vfs_dmsg("\n[INFO] %s : enters for page %d in mapper / inode_xp %l\n", 1711 1710 __FUNCTION__ , page->index , XPTR( local_cxy , &mapper->inode ) ); 1712 1711 … … 1754 1753 assert( (mapper != NULL) , __FUNCTION__ , "mapper pointer is NULL\n" ); 1755 1754 1755 vfs_dmsg("\n[INFO] %s : core[%x,%d] enter for inode %l / cycle %d\n", 1756 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, XPTR(local_cxy , inode) ); 1757 1758 // compute number of pages 1756 1759 uint32_t npages = size >> CONFIG_PPM_PAGE_SHIFT; 1757 1760 if( (size & CONFIG_PPM_PAGE_MASK) || (size == 0) ) npages++; … … 1767 1770 } 1768 1771 1772 vfs_dmsg("\n[INFO] %s : core[%x,%d] exit for inode %l / cycle %d\n", 1773 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, XPTR(local_cxy , inode) ); 1774 1769 1775 return 0; 1770 1776
Note: See TracChangeset
for help on using the changeset viewer.