Changeset 623 for trunk/kernel/fs
- Timestamp:
- Mar 6, 2019, 4:37:15 PM (6 years ago)
- Location:
- trunk/kernel/fs
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/fs/devfs.c
r614 r623 3 3 * 4 4 * Author Mohamed Lamine Karaoui (2014,2015) 5 * Alain Greiner (2016,2017 )5 * Alain Greiner (2016,2017,2018,2019) 6 6 * 7 7 * Copyright (c) Sorbonne Universites … … 91 91 xptr_t * devfs_external_inode_xp ) 92 92 { 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; 95 96 96 97 // create DEVFS "dev" inode in cluster 0 97 98 error = vfs_add_child_in_parent( 0, // cxy 98 INODE_TYPE_DIR,99 99 FS_TYPE_DEVFS, 100 100 root_inode_xp, … … 103 103 devfs_dev_inode_xp ); 104 104 105 // update inode "type" field 106 inode = GET_PTR( *devfs_dev_inode_xp ); 107 inode->type = INODE_TYPE_DIR; 108 105 109 // create dentries <.> and <..> in <dev> 106 110 error |= vfs_add_special_dentries( *devfs_dev_inode_xp, 107 111 root_inode_xp ); 108 112 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 } 111 118 112 119 #if DEBUG_DEVFS_GLOBAL_INIT … … 120 127 // create DEVFS "external" inode in cluster 0 121 128 error = vfs_add_child_in_parent( 0, // cxy 122 INODE_TYPE_DIR,123 129 FS_TYPE_DEVFS, 124 130 *devfs_dev_inode_xp, … … 127 133 devfs_external_inode_xp ); 128 134 135 // update inode "type" field 136 inode = GET_PTR( *devfs_external_inode_xp ); 137 inode->type = INODE_TYPE_DIR; 138 129 139 // create dentries <.> and <..> in <external> 130 140 error |= vfs_add_special_dentries( *devfs_external_inode_xp, 131 141 *devfs_dev_inode_xp ); 132 142 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 } 135 148 136 149 #if DEBUG_DEVFS_GLOBAL_INIT … … 153 166 chdev_t * chdev_ptr; 154 167 xptr_t inode_xp; 155 cxy_t inode_cxy;156 168 vfs_inode_t * inode_ptr; 157 169 uint32_t channel; … … 171 183 172 184 error = vfs_add_child_in_parent( local_cxy, 173 INODE_TYPE_DIR,174 185 FS_TYPE_DEVFS, 175 186 devfs_dev_inode_xp, … … 178 189 devfs_internal_inode_xp ); 179 190 191 // set inode "type" field 192 inode_ptr = GET_PTR( *devfs_internal_inode_xp ); 193 inode_ptr->type = INODE_TYPE_DEV; 194 180 195 // create dentries <.> and <..> in <internal> 181 196 error |= vfs_add_special_dentries( *devfs_internal_inode_xp, 182 197 devfs_dev_inode_xp ); 183 198 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 } 186 204 187 205 #if DEBUG_DEVFS_LOCAL_INIT … … 199 217 chdev_cxy = GET_CXY( chdev_xp ); 200 218 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 } 202 225 203 226 error = vfs_add_child_in_parent( local_cxy, 204 INODE_TYPE_DEV,205 227 FS_TYPE_DEVFS, 206 228 *devfs_internal_inode_xp, … … 209 231 &inode_xp ); 210 232 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 215 241 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; 217 244 218 245 #if DEBUG_DEVFS_LOCAL_INIT … … 234 261 chdev_cxy = GET_CXY( chdev_xp ); 235 262 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 } 237 269 238 270 error = vfs_add_child_in_parent( local_cxy, 239 INODE_TYPE_DEV,240 271 FS_TYPE_DEVFS, 241 272 *devfs_internal_inode_xp, … … 243 274 &unused_xp, 244 275 &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 250 284 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; 252 287 253 288 #if DEBUG_DEVFS_LOCAL_INIT … … 270 305 { 271 306 error = vfs_add_child_in_parent( local_cxy, 272 INODE_TYPE_DEV,273 307 FS_TYPE_DEVFS, 274 308 devfs_external_inode_xp, … … 276 310 &unused_xp, 277 311 &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 283 320 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; 285 323 286 324 #if DEBUG_DEVFS_LOCAL_INIT … … 303 341 { 304 342 error = vfs_add_child_in_parent( local_cxy, 305 INODE_TYPE_DEV,306 343 FS_TYPE_DEVFS, 307 344 devfs_external_inode_xp, … … 310 347 &inode_xp ); 311 348 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 } 313 355 314 356 // update child inode "extend" field 315 inode_cxy = GET_CXY( inode_xp );316 357 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; 318 360 319 361 #if DEBUG_DEVFS_LOCAL_INIT … … 338 380 { 339 381 error = vfs_add_child_in_parent( local_cxy, 340 INODE_TYPE_DEV,341 382 FS_TYPE_DEVFS, 342 383 devfs_external_inode_xp, … … 345 386 &inode_xp ); 346 387 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 351 396 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; 353 399 354 400 #if DEBUG_DEVFS_LOCAL_INIT … … 374 420 { 375 421 error = vfs_add_child_in_parent( local_cxy, 376 INODE_TYPE_DEV,377 422 FS_TYPE_DEVFS, 378 423 devfs_external_inode_xp, … … 380 425 &unused_xp, 381 426 &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 387 435 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; 389 438 390 439 #if DEBUG_DEVFS_LOCAL_INIT … … 410 459 { 411 460 error = vfs_add_child_in_parent( local_cxy, 412 INODE_TYPE_DEV,413 461 FS_TYPE_DEVFS, 414 462 devfs_external_inode_xp, … … 416 464 &unused_xp, 417 465 &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 423 474 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; 425 477 426 478 #if DEBUG_DEVFS_LOCAL_INIT … … 446 498 { 447 499 error = vfs_add_child_in_parent( local_cxy, 448 INODE_TYPE_DEV,449 500 FS_TYPE_DEVFS, 450 501 devfs_external_inode_xp, … … 452 503 &unused_xp, 453 504 &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 459 513 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; 461 516 462 517 #if DEBUG_DEVFS_LOCAL_INIT … … 482 537 { 483 538 error = vfs_add_child_in_parent( local_cxy, 484 INODE_TYPE_DEV,485 539 FS_TYPE_DEVFS, 486 540 devfs_external_inode_xp, … … 488 542 &unused_xp, 489 543 &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 495 552 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; 497 555 498 556 #if DEBUG_DEVFS_LOCAL_INIT … … 518 576 { 519 577 error = vfs_add_child_in_parent( local_cxy, 520 INODE_TYPE_DEV,521 578 FS_TYPE_DEVFS, 522 579 devfs_external_inode_xp, … … 524 581 &unused_xp, 525 582 &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 531 591 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; 533 594 534 595 #if DEBUG_DEVFS_LOCAL_INIT -
trunk/kernel/fs/fatfs.c
r614 r623 793 793 #if (DEBUG_FATFS_CTX_INIT & 0x1) 794 794 if( 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 } 795 putb( "boot record", buffer , 256 ); 811 796 #endif 812 797 … … 960 945 assert( (inode != NULL) , "inode pointer is NULL\n" ); 961 946 assert( (dentry != NULL) , "dentry pointer is NULL\n" ); 962 assert( (inode->type == INODE_TYPE_DIR) , "inode is not a directory\n" );963 947 assert( (inode->mapper != NULL ) , "mapper pointer is NULL\n" ); 964 948 … … 1359 1343 } // end fatfs_remove_dentry 1360 1344 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 ////////////////////////////////////////////////////////////////////////////////////////////// 1360 error_t fatfs_scan_directory( mapper_t * mapper, 1361 char * name, 1362 uint8_t ** entry, 1363 uint32_t * index ) 1365 1364 { 1366 1365 // Two embedded loops to scan the directory mapper: … … 1368 1367 // - scan the directory entries in each 4 Kbytes page 1369 1368 1370 #if DEBUG_FATFS_GET_DENTRY 1369 // check parent_inode and child_inode 1370 assert( (mapper != NULL) , "mapper pointer is NULL\n" ); 1371 assert( (name != NULL ), "child name is undefined\n" ); 1372 assert( (entry != NULL ), "entry buffer undefined\n" ); 1373 1374 #if DEBUG_FATFS_SCAN_DIRECTORY 1371 1375 char parent_name[CONFIG_VFS_MAX_NAME_LENGTH]; 1372 1376 uint32_t cycle = (uint32_t)hal_get_cycles(); 1373 1377 thread_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 forchild <%s> in parent <%s> / cycle %d\n",1378 vfs_inode_get_name( XPTR( local_cxy , mapper->inode ) , parent_name ); 1379 if( DEBUG_FATFS_SCAN_DIRECTORY < cycle ) 1380 printk("\n[%s] thread[%x,%x] enter to search child <%s> in parent <%s> / cycle %d\n", 1377 1381 __FUNCTION__, this->process->pid, this->trdid, name , parent_name , cycle ); 1378 1382 #endif 1379 1383 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 1391 1385 1392 1386 char lfn1[16]; // buffer for one partial cname 1393 1387 char lfn2[16]; // buffer for one partial cname 1394 1388 char lfn3[16]; // buffer for one partial cname 1389 xptr_t mapper_xp; // extended pointer on mapper descriptor 1395 1390 xptr_t page_xp; // extended pointer on page descriptor 1396 1391 xptr_t base_xp; // extended pointer on page base … … 1400 1395 uint32_t seq; // sequence index 1401 1396 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 1406 1398 uint32_t page_id = 0; // page index in mapper 1407 uint32_t dentry_id = 0; // directory entry index1408 1399 uint32_t offset = 0; // byte offset in page 1409 1400 1410 // scan the parent directory mapper 1401 mapper_xp = XPTR( local_cxy , mapper ); 1402 1403 // scan the mapper pages 1411 1404 while ( found == 0 ) 1412 1405 { … … 1414 1407 page_xp = mapper_remote_get_page( mapper_xp , page_id ); 1415 1408 1416 if( page_xp == XPTR_NULL) return EIO; 1409 if( page_xp == XPTR_NULL) 1410 { 1411 found = -1; 1412 } 1417 1413 1418 1414 // get page base … … 1420 1416 base = (uint8_t *)GET_PTR( base_xp ); 1421 1417 1422 #if (DEBUG_FATFS_ GET_DENTRY & 0x1)1423 if( DEBUG_FATFS_ GET_DENTRY < cycle )1418 #if (DEBUG_FATFS_SCAN_DIRECTORY & 0x1) 1419 if( DEBUG_FATFS_SCAN_DIRECTORY < cycle ) 1424 1420 mapper_display_page( mapper_xp , page_id , 256 ); 1425 1421 #endif … … 1432 1428 if (ord == NO_MORE_ENTRY) // no more entry => break 1433 1429 { 1434 found = -1;1430 found = 2; 1435 1431 } 1436 1432 else if ( ord == FREE_ENTRY ) // free entry => skip … … 1477 1473 if ( strcmp( name , cname ) == 0 ) 1478 1474 { 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; 1484 1477 found = 1; 1485 1478 } … … 1494 1487 } // end loop on pages 1495 1488 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 1493 cycle = (uint32_t)hal_get_cycles(); 1494 if( DEBUG_FATFS_SCAN_DIRECTORY < cycle ) 1495 printk("\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 1504 cycle = (uint32_t)hal_get_cycles(); 1505 if( DEBUG_FATFS_SCAN_DIRECTORY < cycle ) 1506 printk("\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 ///////////////////////////////////////////////////// 1523 error_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 1536 assert( (parent_inode != NULL) , "parent_inode is NULL\n" ); 1537 assert( (name != NULL) , "name is NULL\n" ); 1538 assert( (child_inode_xp != XPTR_NULL ) , "child_inode is XPTR_NULL\n" ); 1539 1540 #if DEBUG_FATFS_GET_DENTRY 1541 char parent_name[CONFIG_VFS_MAX_NAME_LENGTH]; 1542 uint32_t cycle = (uint32_t)hal_get_cycles(); 1543 thread_t * this = CURRENT_THREAD; 1544 vfs_inode_get_name( XPTR( local_cxy , parent_inode ) , parent_name ); 1545 if( DEBUG_FATFS_GET_DENTRY < cycle ) 1546 printk("\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 { 1500 1557 1501 1558 #if DEBUG_FATFS_GET_DENTRY 1502 1559 cycle = (uint32_t)hal_get_cycles(); 1503 1560 if( 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 ); 1561 printk("\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 ); 1517 1576 1518 1577 // check child inode has at least one parent 1519 1578 assert( (xlist_is_empty( parents_root_xp ) == false ), "child inode must have one parent\n"); 1520 1579 1521 // get dentry pointers and cluster1522 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 ); 1525 1584 1526 1585 // check dentry descriptor in same cluster as parent inode 1527 1586 assert( (dentry_cxy == local_cxy) , "illegal dentry cluster\n" ); 1528 1587 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 ////////////////////////////////////////////////// 1608 error_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 1618 assert( (inode != NULL) , "inode is NULL\n" ); 1619 assert( (dentry != NULL) , "dentry is NULL\n" ); 1620 assert( (size != 0 ) , "size is 0\n" ); 1621 1622 #if DEBUG_FATFS_UPDATE_DENTRY 1623 char dir_name[CONFIG_VFS_MAX_NAME_LENGTH]; 1624 uint32_t cycle = (uint32_t)hal_get_cycles(); 1625 thread_t * this = CURRENT_THREAD; 1626 vfs_inode_get_name( XPTR( local_cxy , inode ) , dir_name ); 1627 if( DEBUG_FATFS_UPDATE_DENTRY < cycle ) 1628 printk("\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 1540 1641 cycle = (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() 1642 if( DEBUG_FATFS_UPDATE_DENTRY < cycle ) 1643 printk("\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() 1549 1666 1550 1667 /////////////////////////////////////////////////////// … … 2056 2173 assert( (inode_xp != XPTR_NULL) , "inode pointer is NULL\n" ); 2057 2174 2058 // get first_cluster from inode extension2175 // get inode cluster and local pointer 2059 2176 inode_ptr = GET_PTR( inode_xp ); 2060 2177 inode_cxy = GET_CXY( inode_xp ); 2178 2179 // get first_cluster from inode extension 2061 2180 first_xp = XPTR( inode_cxy , &inode_ptr->extend ); 2062 2181 first_cluster = (uint32_t)(intptr_t)hal_remote_lpt( first_xp ); … … 2073 2192 printk("\n[%s] thread[%x,%x] enter for <%s> / first_cluster %x / cycle %d\n", 2074 2193 __FUNCTION__ , this->process->pid, this->trdid, name, first_cluster, cycle ); 2194 #endif 2195 2196 #if (DEBUG_FATFS_RELEASE_INODE & 1) 2197 fatfs_display_fat( 0 , 512 ); 2075 2198 #endif 2076 2199 -
trunk/kernel/fs/fatfs.h
r614 r623 309 309 310 310 /***************************************************************************************** 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. 316 317 * It scan the parent mapper to find the <name> argument. 317 318 * It set the "type", "size", and "extend" fields in inode descriptor. … … 324 325 * @ return 0 if success / return ENOENT if child not found. 325 326 ****************************************************************************************/ 326 error_t fatfs_ get_dentry( struct vfs_inode_s * parent_inode,327 error_t fatfs_new_dentry( struct vfs_inode_s * parent_inode, 327 328 char * name, 328 329 xptr_t child_inode_xp ); 329 330 330 331 /***************************************************************************************** 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 ****************************************************************************************/ 346 error_t fatfs_update_dentry( struct vfs_inode_s * inode, 347 struct vfs_dentry_s * dentry, 348 uint32_t size ); 349 350 /***************************************************************************************** 331 351 * This function implements the generic vfs_fs_get_user_dir() function for the FATFS. 332 352 ***************************************************************************************** 333 353 * 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 a354 * identified by the <inode> argument, and copy up to <max_dirent> valid dentries to a 335 355 * 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. 337 357 * This function returns in the <entries> buffer the number of dentries actually written, 338 358 * and signals in the <done> buffer when the last valid entry has been found. 339 359 * 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 fiel s are documented in the360 * the Inode Tree is dynamically created, and all dirent fields are documented in the 341 361 * dirent array. Otherwise, only the dentry name is documented. 342 362 * It must be called by a thread running in the cluster containing the directory inode. … … 443 463 * The page - and the mapper - can be located in another cluster than the calling thread. 444 464 * The pointer on the mapper and the page index in file are found in the page descriptor. 445 * It is used for both fora regular file/directory mapper, and the FAT mapper.465 * It is used for both a regular file/directory mapper, and the FAT mapper. 446 466 * For the FAT mapper, it access the FATFS to get the location on IOC device. 447 467 * For a regular file, it access the FAT mapper to get the cluster index on IOC device. -
trunk/kernel/fs/ramfs.c
r602 r623 35 35 char * ramfs_root_name ) 36 36 { 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; 38 40 39 41 cxy_t cxy = cluster_random_select(); … … 41 43 // create VFS dentry and VFS inode for RAMFS root directory 42 44 return vfs_add_child_in_parent( cxy, 43 INODE_TYPE_DIR,44 45 FS_TYPE_RAMFS, 45 46 parent_inode_xp, 46 47 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; 49 53 } 50 54 -
trunk/kernel/fs/vfs.c
r614 r623 3 3 * 4 4 * Author Mohamed Lamine Karaoui (2015) 5 * Alain Greiner (2016,2017,2018 )5 * Alain Greiner (2016,2017,2018,2019) 6 6 * 7 7 * Copyright (c) UPMC Sorbonne Universites … … 142 142 //////////////////////////////////////////////////// 143 143 error_t vfs_inode_create( vfs_fs_type_t fs_type, 144 vfs_inode_type_t inode_type,145 144 uint32_t attr, 146 145 uint32_t rights, … … 214 213 215 214 // initialize inode descriptor 216 inode->type = inode_type;215 inode->type = INODE_TYPE_FILE; // default value 217 216 inode->inum = inum; 218 217 inode->attr = attr; … … 228 227 mapper->inode = inode; 229 228 230 // initialise threads waiting queue231 // xlist_root_init( XPTR( local_cxy , &inode->wait_root ) );232 233 229 // initialize chidren dentries xhtab 234 230 xhtab_init( &inode->children , XHTAB_DENTRY_TYPE ); … … 278 274 vfs_inode_t * ptr = GET_PTR( inode_xp ); 279 275 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 280 283 // 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 284 289 return size; 285 290 } 286 291 287 //////////////////////////////////////////// 288 void vfs_inode_ set_size( xptr_t inode_xp,289 uint32_t size )292 /////////////////////////////////////////////// 293 void vfs_inode_update_size( xptr_t inode_xp, 294 uint32_t size ) 290 295 { 291 296 // get inode cluster and local pointer … … 293 298 vfs_inode_t * ptr = GET_PTR( inode_xp ); 294 299 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 ); 299 315 } 300 316 … … 546 562 547 563 // check refcount 548 assert( (file->refcount == 0) , "refcount non zero\n" );564 // assert( (file->refcount == 0) , "refcount non zero\n" ); 549 565 550 566 kmem_req_t req; … … 554 570 555 571 #if DEBUG_VFS_CLOSE 572 char name[CONFIG_VFS_MAX_NAME_LENGTH]; 573 vfs_file_get_name( XPTR( local_cxy , file ) , name ); 556 574 thread_t * this = CURRENT_THREAD; 557 575 uint32_t cycle = (uint32_t)hal_get_cycles(); 558 576 if( DEBUG_VFS_CLOSE < cycle ) 559 printk("\n[%s] thread[%x,%x] deleted file %xin cluster %x / cycle %d\n",560 __FUNCTION__, this->process->pid, this->trdid, file, local_cxy, cycle );577 printk("\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 ); 561 579 #endif 562 580 … … 585 603 hal_remote_atomic_add( XPTR( file_cxy , &file_ptr->refcount ) , -1 ); 586 604 } 605 606 /////////////////////////////////////// 607 void 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 587 622 588 623 ////////////////////////////////////////////////////////////////////////////////////////// … … 889 924 } // vfs_lseek() 890 925 891 /////////////////////////////////// 926 //////////////////////////////////// 892 927 error_t vfs_close( xptr_t file_xp, 893 928 uint32_t file_id ) 894 929 { 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 948 assert( (file_xp != XPTR_NULL) , "file_xp is XPTR_NULL\n" ); 910 949 911 950 thread_t * this = CURRENT_THREAD; 912 951 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 914 957 #if DEBUG_VFS_CLOSE 915 958 uint32_t cycle = (uint32_t)hal_get_cycles(); 916 959 if( 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; 960 printk("\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 994 if( DEBUG_VFS_CLOSE < cycle ) 995 printk("\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 1051 char parent_name[CONFIG_VFS_MAX_NAME_LENGTH]; 1052 vfs_inode_get_name( XPTR( parent_cxy , parent_inode_ptr ) , parent_name ); 1053 if( DEBUG_VFS_CLOSE < cycle ) 1054 printk("\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 1078 if( DEBUG_VFS_CLOSE < cycle ) 1079 printk("\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 923 1086 924 1087 // 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 ); 927 1091 928 1092 // get extended pointers on copies root and lock … … 930 1094 lock_xp = XPTR( owner_cxy , &cluster->pmgr.copies_lock[lpid] ); 931 1095 932 // 1) loop on the process descriptor copies to reset all fd_array[file_id] entries933 934 1096 // take the lock protecting the list of copies 935 1097 remote_queuelock_acquire( lock_xp ); … … 937 1099 XLIST_FOREACH( root_xp , iter_xp ) 938 1100 { 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] ); 956 1106 hal_remote_s64( entry_xp , XPTR_NULL ); 957 958 // remote_rwlock_wr_release( fd_array_lock_xp );959 960 1107 vfs_file_count_down( file_xp ); 961 962 1108 hal_fence(); 963 1109 } … … 966 1112 remote_queuelock_release( lock_xp ); 967 1113 968 #if (DEBUG_VFS_CLOSE & 1)1114 #if DEBUG_VFS_CLOSE 969 1115 if( 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 ); 1116 printk("\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 979 1121 980 1122 if( file_cxy == local_cxy ) // file cluster is local … … 990 1132 cycle = (uint32_t)hal_get_cycles(); 991 1133 if( DEBUG_VFS_CLOSE < cycle ) 992 printk("\n[%s] thread[%x,%x] exit / fdid %dclosed / cycle %d\n",993 __FUNCTION__, process->pid, this->trdid, file_id, cycle );1134 printk("\n[%s] thread[%x,%x] exit / <%s> closed / cycle %d\n", 1135 __FUNCTION__, process->pid, this->trdid, name, cycle ); 994 1136 #endif 995 1137 … … 1120 1262 { 1121 1263 error = vfs_inode_create( parent_fs_type, 1122 INODE_TYPE_DIR,1123 1264 attr, 1124 1265 rights, … … 1131 1272 rpc_vfs_inode_create_client( inode_cxy, 1132 1273 parent_fs_type, 1133 INODE_TYPE_DIR,1134 1274 attr, 1135 1275 rights, … … 1152 1292 // get new inode local pointer 1153 1293 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 ); 1154 1297 1155 1298 #if(DEBUG_VFS_MKDIR & 1) … … 1455 1598 xptr_t dentry_xp; // extended pointer on dentry to unlink 1456 1599 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 1457 1602 1458 1603 char name[CONFIG_VFS_MAX_NAME_LENGTH]; // name of link to remove … … 1466 1611 vfs_inode_get_name( root_xp , root_name ); 1467 1612 if( DEBUG_VFS_UNLINK < cycle ) 1468 printk("\n[%s] thread[%x,%x] enter /root <%s> / path <%s> / cycle %d\n",1613 printk("\n[%s] thread[%x,%x] : enter for root <%s> / path <%s> / cycle %d\n", 1469 1614 __FUNCTION__, process->pid, this->trdid, root_name, path, cycle ); 1470 1615 #endif … … 1501 1646 vfs_inode_get_name( parent_xp , parent_name ); 1502 1647 if( DEBUG_VFS_UNLINK < cycle ) 1503 printk("\n[%s] thread[%x,%x] parent inode <%s> is (%x,%x)\n",1648 printk("\n[%s] thread[%x,%x] : parent inode <%s> is (%x,%x)\n", 1504 1649 __FUNCTION__, process->pid, this->trdid, parent_name, parent_cxy, parent_ptr ); 1505 1650 #endif … … 1508 1653 xptr_t children_xp = XPTR( parent_cxy , &parent_ptr->children ); 1509 1654 1510 // get extended pointer on dentry to unlink1655 // try to get extended pointer on dentry from Inode Tree 1511 1656 dentry_xp = xhtab_lookup( children_xp , name ); 1512 1657 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 { 1523 1662 1524 1663 #if( DEBUG_VFS_UNLINK & 1 ) 1525 1664 if( 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 1665 printk("\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) 1720 if( DEBUG_VFS_UNLINK < cycle ) 1721 printk("\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 1535 1739 #if( DEBUG_VFS_UNLINK & 1 ) 1536 char inode_name[CONFIG_VFS_MAX_NAME_LENGTH];1537 vfs_inode_get_name( inode_xp , inode_name );1538 1740 if( 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);1741 printk("\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 ); 1541 1743 #endif 1542 1744 … … 1545 1747 inode_links = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->links ) ); 1546 1748 1547 // check target inode links counter1548 assert( (inode_links >= 1), "illegal inode links count %d for <%s>\n", inode_links, path );1549 1550 1749 /////////////////////////////////////////////////////////////////////// 1551 1750 if( (inode_type == INODE_TYPE_FILE) || (inode_type == INODE_TYPE_DIR) ) 1552 1751 { 1752 1753 #if( DEBUG_VFS_UNLINK & 1 ) 1754 if( DEBUG_VFS_UNLINK < cycle ) 1755 printk("\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 1553 1759 // 1. Release clusters allocated to target inode 1554 1760 // and synchronize the FAT on IOC device if last link. … … 1557 1763 // build extended pointer on target inode "children" number 1558 1764 xptr_t inode_children_xp = XPTR( inode_cxy , &inode_ptr->children.items ); 1765 1766 printk("\n@@@ in %s : children_xp = (%x,%x)\n", 1767 __FUNCTION__, inode_cxy, &inode_ptr->children.items ); 1559 1768 1560 1769 // get target inode number of children … … 1713 1922 1714 1923 } // 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 }1733 1924 1734 1925 //////////////////////////////////// … … 2195 2386 cxy_t child_cxy; // cluster for child inode 2196 2387 vfs_inode_t * child_ptr; // local pointer on child inode 2197 vfs_inode_type_t child_type; // child inode type2198 2388 vfs_fs_type_t fs_type; // File system type 2199 2389 vfs_ctx_t * ctx_ptr; // local pointer on FS context … … 2319 2509 child_cxy = cluster_random_select(); 2320 2510 2321 // define child inode type2322 if( dir ) child_type = INODE_TYPE_DIR;2323 else child_type = INODE_TYPE_FILE;2324 2325 2511 // insert a new child dentry/inode couple in inode tree 2326 2512 error = vfs_add_child_in_parent( child_cxy, 2327 child_type,2328 2513 fs_type, 2329 2514 parent_xp, … … 2350 2535 if( parent_cxy == local_cxy ) 2351 2536 { 2352 error = vfs_fs_ get_dentry( parent_ptr,2537 error = vfs_fs_new_dentry( parent_ptr, 2353 2538 name, 2354 2539 child_xp ); … … 2356 2541 else 2357 2542 { 2358 rpc_vfs_fs_ get_dentry_client( parent_cxy,2543 rpc_vfs_fs_new_dentry_client( parent_cxy, 2359 2544 parent_ptr, 2360 2545 name, … … 2961 3146 //////////////////////////////////////////////////////////////////// 2962 3147 error_t vfs_add_child_in_parent( cxy_t child_cxy, 2963 vfs_inode_type_t child_type,2964 3148 vfs_fs_type_t fs_type, 2965 3149 xptr_t parent_inode_xp, … … 3038 3222 { 3039 3223 error = vfs_inode_create( fs_type, 3040 child_type,3041 3224 attr, 3042 3225 mode, … … 3049 3232 rpc_vfs_inode_create_client( child_cxy, 3050 3233 fs_type, 3051 child_type,3052 3234 attr, 3053 3235 mode, … … 3309 3491 3310 3492 //////////////////////////////////////////////// 3311 error_t vfs_fs_ get_dentry( vfs_inode_t * parent,3493 error_t vfs_fs_new_dentry( vfs_inode_t * parent, 3312 3494 char * name, 3313 3495 xptr_t child_xp ) … … 3325 3507 if( fs_type == FS_TYPE_FATFS ) 3326 3508 { 3327 error = fatfs_ get_dentry( parent , name , child_xp );3509 error = fatfs_new_dentry( parent , name , child_xp ); 3328 3510 } 3329 3511 else if( fs_type == FS_TYPE_RAMFS ) … … 3342 3524 return error; 3343 3525 3344 } // end vfs_fs_get_dentry() 3526 } // end vfs_fs_new_dentry() 3527 3528 /////////////////////////////////////////////////// 3529 error_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 3536 assert( (inode != NULL) , "inode pointer is NULL\n"); 3537 assert( (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() 3345 3563 3346 3564 /////////////////////////////////////////////////// -
trunk/kernel/fs/vfs.h
r614 r623 108 108 /****************************************************************************************** 109 109 * This structure define a VFS inode. 110 * An inode hasseveral children dentries (if it is a directory), an can have several110 * An inode can have several children dentries (if it is a directory), an can have several 111 111 * parents dentries (if it hass several aliases links): 112 112 * - The "parents" field is the root of the xlist of parents dentries, and the "links" … … 166 166 remote_rwlock_t size_lock; /*! protect read/write to size */ 167 167 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 */170 168 struct mapper_s * mapper; /*! associated file cache */ 171 169 void * extend; /*! fs_type_specific inode extension */ … … 195 193 196 194 /****************************************************************************************** 197 * This structure defines a directory entry.195 Rpt* This structure defines a directory entry. 198 196 * A dentry contains the name of a remote file/dir, an extended pointer on the 199 197 * inode representing this file/dir, a local pointer on the inode representing … … 321 319 *****************************************************************************************/ 322 320 error_t vfs_inode_create( vfs_fs_type_t fs_type, 323 vfs_inode_type_t inode_type,324 321 uint32_t attr, 325 322 uint32_t rights, … … 349 346 350 347 /****************************************************************************************** 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. 353 351 ***************************************************************************************** 354 352 * @ 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 *****************************************************************************************/ 355 void vfs_inode_update_size( xptr_t inode_xp, 356 uint32_t size ); 359 357 360 358 /****************************************************************************************** … … 451 449 * This function releases memory allocated to a local file descriptor. 452 450 * 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. 456 452 ****************************************************************************************** 457 453 * @ file : local pointer on file descriptor. … … 465 461 void vfs_file_count_up ( xptr_t file_xp ); 466 462 void 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 *****************************************************************************************/ 472 void vfs_file_get_name( xptr_t inode_xp, 473 char * name ); 467 474 468 475 … … 537 544 * Only the distributed Inode Tree is modified: it does NOT modify the parent mapper, 538 545 * and does NOT update the FS on IOC device. 546 * It set the inode type to the default INODE_TYPE_FILE value 539 547 * It can be executed by any thread running in any cluster (can be different from both 540 548 * the child cluster and the parent cluster). … … 552 560 ****************************************************************************************** 553 561 * @ child_inode_cxy : [in] target cluster for child inode. 554 * @ child_inode_type : [in] child inode type555 562 * @ fs_type : [in] child inode FS type. 556 563 * @ parent_inode_xp : [in] extended pointer on parent inode. … … 561 568 *****************************************************************************************/ 562 569 error_t vfs_add_child_in_parent( cxy_t child_inode_cxy, 563 vfs_inode_type_t child_inode_type,564 570 vfs_fs_type_t fs_type, 565 571 xptr_t parent_inode_xp, … … 729 735 /****************************************************************************************** 730 736 * 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, 733 744 * using remote accesses. 734 * 2) The memory allocated to file descriptor in cluster containing the inode is released.735 * It requires aRPC 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[]. 739 750 * @ returns 0 if success / -1 if error. 740 751 *****************************************************************************************/ … … 877 888 /****************************************************************************************** 878 889 * 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>. 880 891 * Depending on the file system type, it calls the proper, FS specific function. 881 892 * It is used in case of MISS on the mapper, or when a dirty page in the mapper must … … 918 929 * Finally, it synchronously updates the parent directory on IOC device. 919 930 * 931 * Depending on the file system type, it calls the relevant, FS specific function. 920 932 * 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. 922 934 ****************************************************************************************** 923 935 * @ parent : local pointer on parent (directory) inode. … … 933 945 * and updates both the child inode descriptor, identified by the <child_xp> argument, 934 946 * 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. 936 948 * - It set the "extend" field in dentry descriptor. 937 949 * It is called by the vfs_lookup() function in case of miss. … … 939 951 * Depending on the file system type, it calls the relevant, FS specific function. 940 952 * 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. 942 954 ****************************************************************************************** 943 955 * @ parent : local pointer on parent inode (directory). 944 956 * @ name : child name. 945 957 * @ child_xp : extended pointer on remote child inode (file or directory) 946 * @ return 0 if success / return ENOENT ifnot 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 *****************************************************************************************/ 960 error_t vfs_fs_new_dentry( vfs_inode_t * parent, 949 961 char * name, 950 962 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 *****************************************************************************************/ 980 error_t vfs_fs_update_dentry( vfs_inode_t * inode, 981 vfs_dentry_t * dentry, 982 uint32_t size ); 951 983 952 984 /******************************************************************************************
Note: See TracChangeset
for help on using the changeset viewer.