Changeset 407 for trunk/kernel/fs/vfs.c
- Timestamp:
- Nov 7, 2017, 3:08:12 PM (7 years ago)
- Location:
- trunk/kernel/fs
- Files:
-
- 1 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/fs/vfs.c
r406 r407 156 156 error_t error; 157 157 158 vfs_dmsg("\n[INFO] %s : core[%x,%d] enter / dentry_xp = %l\n",159 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , dentry_xp);158 vfs_dmsg("\n[DBG] %s : core[%x,%d] enter / dentry = %x in cluster %x\n", 159 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, GET_PTR(dentry_xp), GET_CXY(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 : 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);231 vfs_dmsg("\n[DBG] %s : core[%x,%d] exit / inode = %x in cluster %x\n", 232 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, inode , local_cxy ); 233 233 234 234 // return extended pointer on inode … … 262 262 xptr_t child_xp ) 263 263 { 264 vfs_dmsg("\n[INFO] %s : core[%x,%d] enter for <%s> / cycle %d\n",265 264 vfs_dmsg("\n[DBG] %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 : core[%x,%d] exit for <%s> / cycle %d\n",295 294 vfs_dmsg("\n[DBG] %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; … … 413 413 414 414 // display inode header 415 printk("\n*** inode <%s> / inode_xp = %l / dentry_xp = %l ***\n",416 name , inode_xp , dentry_xp);415 printk("\n***** inode <%s> [%x in cluster %x]\n", 416 name , GET_PTR(inode_xp) , GET_CXY(inode_xp) ); 417 417 418 418 // display children from xhtab … … 435 435 kmem_req_t req; // request to kernel memory allocator 436 436 437 vfs_dmsg("\n[INFO] %s : core[%x,%d] enter for <%s> / parent inode = %x / cycle %d\n",438 437 vfs_dmsg("\n[DBG] %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 : 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() );486 vfs_dmsg("\n[DBG] %s : core[%x,%d] exit for <%s> / dentry = %x in cluster %x / cycle %d\n", 487 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, name, dentry, local_cxy , hal_time_stamp() ); 488 488 489 489 return 0; … … 586 586 ////////////////////////////////////////////////////////////////////////////////////////// 587 587 588 //////////////////////////////////// 589 error_t vfs_open( xptr_t cwd_xp,590 char * path,591 uint32_t flags,592 uint32_t mode,593 xptr_t * new_file_xp,594 uint32_t * new_file_id )588 ////////////////////////////////////// 589 error_t vfs_open( process_t * process, 590 char * path, 591 uint32_t flags, 592 uint32_t mode, 593 xptr_t * new_file_xp, 594 uint32_t * new_file_id ) 595 595 { 596 596 error_t error; … … 603 603 uint32_t file_id; // created file descriptor index in reference fd_array 604 604 605 vfs_dmsg("\n[INFO] %s : core[%x,%d] enter for <%s> / cycle %d\n",606 605 vfs_dmsg("\n[DBG] %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 … … 614 614 // compute attributes for the created file 615 615 file_attr = 0; 616 if( (flags & O_RDONLY ) == 0 ) file_attr |= FD_ATTR_ READ_ENABLE;617 if( (flags & O_WRONLY ) == 0 ) file_attr |= FD_ATTR_ WRITE_ENABLE;616 if( (flags & O_RDONLY ) == 0 ) file_attr |= FD_ATTR_WRITE_ENABLE; 617 if( (flags & O_WRONLY ) == 0 ) file_attr |= FD_ATTR_READ_ENABLE; 618 618 if( (flags & O_SYNC ) ) file_attr |= FD_ATTR_SYNC; 619 619 if( (flags & O_APPEND ) ) file_attr |= FD_ATTR_APPEND; … … 621 621 622 622 // get extended pointer on target inode 623 error = vfs_lookup( cwd_xp , path , lookup_mode , &inode_xp );623 error = vfs_lookup( process->vfs_cwd_xp , path , lookup_mode , &inode_xp ); 624 624 625 625 if( error ) return error; … … 629 629 inode_ptr = (vfs_inode_t *)GET_PTR( inode_xp ); 630 630 631 vfs_dmsg("\n[DBG] %s : core[%x,%d] found inode for <%s> in cluster %x / cycle %d\n", 632 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, path, inode_cxy , (uint32_t)hal_time_stamp() ); 633 631 634 // create a new file descriptor in cluster containing inode 632 635 if( inode_cxy == local_cxy ) // target cluster is local … … 641 644 if( error ) return error; 642 645 643 // allocate and register a new file descriptor index in reference cluster fd_array644 error = process_fd_register( file_xp , &file_id );646 // allocate and register a new file descriptor index in reference process 647 error = process_fd_register( process , file_xp , &file_id ); 645 648 646 649 if( error ) return error; 647 650 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() ); 651 vfs_dmsg("\n[DBG] %s : core[%x,%d] exit for <%s> / file = %x in cluster %x / cycle %d\n", 652 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, path, 653 GET_PTR(file_xp), GET_CXY(file_xp), hal_time_stamp() ); 650 654 651 655 // success … … 656 660 } // end vfs_open() 657 661 658 //////////////////////////////////////////// 659 error_t vfs_user_move( bool_t to_buffer, 660 xptr_t file_xp, 661 void * buffer, 662 uint32_t size ) 663 { 664 assert( ( file_xp != XPTR_NULL ) , __FUNCTION__ , "file_xp == XPTR_NULL" ); 662 ////////////////////////////////////// 663 int vfs_user_move( bool_t to_buffer, 664 xptr_t file_xp, 665 void * buffer, 666 uint32_t size ) 667 { 668 assert( ( file_xp != XPTR_NULL ) , __FUNCTION__ , 669 "file_xp == XPTR_NULL" ); 665 670 666 671 cxy_t file_cxy; // remote file descriptor cluster … … 678 683 inode_type = hal_remote_lw( XPTR( file_cxy , &file_ptr->type ) ); 679 684 680 // action depends on inode type 681 if( inode_type == INODE_TYPE_FILE ) 682 { 683 // get mapper pointer and file offset from file descriptor 684 file_offset = hal_remote_lw( XPTR( file_cxy , &file_ptr->offset ) ); 685 mapper = (mapper_t *)hal_remote_lpt( XPTR( file_cxy , &file_ptr->mapper ) ); 686 687 // move data between mapper and buffer 688 if( file_cxy == local_cxy ) 689 { 690 error = mapper_move_user( mapper, 691 to_buffer, 692 file_offset, 693 buffer, 694 size ); 695 } 696 else 697 { 698 rpc_mapper_move_buffer_client( file_cxy, 699 mapper, 700 to_buffer, 701 true, // user buffer 702 file_offset, 703 (uint64_t)(intptr_t)buffer, 704 size, 705 &error ); 706 } 707 708 if( error ) return -1; 709 else return 0; 710 } 711 else 712 { 713 printk("\n[ERROR] in %s : inode is not a file", __FUNCTION__ ); 714 return -1; 715 } 685 assert( (inode_type == INODE_TYPE_FILE) , __FUNCTION__ , 686 "inode type is not INODE_TYPE_FILE" ); 687 688 // get mapper pointer and file offset from file descriptor 689 file_offset = hal_remote_lw( XPTR( file_cxy , &file_ptr->offset ) ); 690 mapper = (mapper_t *)hal_remote_lpt( XPTR( file_cxy , &file_ptr->mapper ) ); 691 692 // move data between mapper and buffer 693 if( file_cxy == local_cxy ) 694 { 695 error = mapper_move_user( mapper, 696 to_buffer, 697 file_offset, 698 buffer, 699 size ); 700 } 701 else 702 { 703 rpc_mapper_move_buffer_client( file_cxy, 704 mapper, 705 to_buffer, 706 true, // user buffer 707 file_offset, 708 (uint64_t)(intptr_t)buffer, 709 size, 710 &error ); 711 } 712 713 if( error ) return -1; 714 else return size; 715 716 716 } // end vfs_user_move() 717 717 … … 905 905 panic("not implemented"); 906 906 return 0; 907 } // vfs_unlink()908 909 /////////////////////////////////////// 910 error_t vfs_stat( xptr_t file_xp,911 vfs_stat_t * k_stat )907 } 908 909 //////////////////////////////////////// 910 error_t vfs_stat( xptr_t file_xp, 911 struct stat * k_stat ) 912 912 { 913 913 panic("not implemented"); … … 915 915 } 916 916 917 //////////////////////////////////////////// 918 error_t vfs_readdir( xptr_t file_xp,919 vfs_dirent_t * k_dirent )917 ///////////////////////////////////////////// 918 error_t vfs_readdir( xptr_t file_xp, 919 struct dirent * k_dirent ) 920 920 { 921 921 panic("not implemented"); … … 1094 1094 1095 1095 // display inode 1096 nolock_printk("%s%s <%s> : inode = % l / mapper = %l / dentry = %l\n",1096 nolock_printk("%s%s <%s> : inode = %x / mapper = %x / cluster %x\n", 1097 1097 indent_str[indent], vfs_inode_type_str( inode_type ), name, 1098 inode_ xp , XPTR( inode_cxy , mapper_ptr ) , dentry_xp);1098 inode_ptr , mapper_ptr , inode_cxy ); 1099 1099 1100 1100 // scan directory entries … … 1171 1171 1172 1172 // get pointers on TXT0 chdev 1173 xptr_t txt0_xp = chdev_dir.txt [0];1173 xptr_t txt0_xp = chdev_dir.txt_tx[0]; 1174 1174 cxy_t txt0_cxy = GET_CXY( txt0_xp ); 1175 1175 chdev_t * txt0_ptr = GET_PTR( txt0_xp ); … … 1338 1338 process = this->process; 1339 1339 1340 vfs_dmsg("\n[INFO] %s : core[%x,%d] enter for <%s> / cycle %d\n",1341 1340 vfs_dmsg("\n[DBG] %s : core[%x,%d] enter for <%s> / cycle %d\n", 1341 __FUNCTION__ , local_cxy , this->core->lid , pathname , hal_time_stamp() ); 1342 1342 1343 1343 // get extended pointer on first inode to search … … 1362 1362 vfs_get_name_from_path( current , name , &next , &last ); 1363 1363 1364 vfs_dmsg("\n[INFO] %s : core[%x,%d] look for <%s> / last = %d\n",1365 1364 vfs_dmsg("\n[DBG] %s : core[%x,%d] look for <%s> / last = %d\n", 1365 __FUNCTION__ , local_cxy , this->core->lid , name , last ); 1366 1366 1367 1367 // search a child dentry matching name in parent inode … … 1380 1380 if (found == false ) // child node not found in inode tree 1381 1381 { 1382 vfs_dmsg("\n[INFO] %s : core[%x,%d] miss <%s> => load it\n", 1383 __FUNCTION__ , local_cxy , this->core->lid , name ); 1382 1383 vfs_dmsg("\n[DBG] %s : core[%x,%d] miss <%s> => load it\n", 1384 __FUNCTION__ , local_cxy , this->core->lid , name ); 1384 1385 1385 1386 // release lock on parent inode … … 1405 1406 if( error ) 1406 1407 { 1407 printk("\n[ERROR] in %s : no memory for inode %s in path %s\n",1408 printk("\n[ERROR] in %s : no memory for inode <%s> in path <%s>\n", 1408 1409 __FUNCTION__ , name , pathname ); 1409 1410 return ENOMEM; … … 1428 1429 if ( error ) 1429 1430 { 1430 printk("\n[ERROR] in %s : core[%x,%d] / <%s> no t found in parent\n",1431 __FUNCTION__ , local_cxy , this->core->lid , name );1431 printk("\n[ERROR] in %s : core[%x,%d] / <%s> node not found in <%s>\n", 1432 __FUNCTION__ , local_cxy , this->core->lid , name , pathname ); 1432 1433 return ENOENT; 1433 1434 } … … 1464 1465 vfs_inode_lock( parent_xp ); 1465 1466 1466 vfs_dmsg("\n[INFO] %s : core[%x,%d] created node <%s>\n", 1467 __FUNCTION__ , local_cxy , this->core->lid , name ); 1467 vfs_dmsg("\n[DBG] %s : core[%x,%d] created node <%s>\n", 1468 __FUNCTION__ , local_cxy , this->core->lid , name ); 1469 1468 1470 } 1469 1471 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);1472 vfs_dmsg("\n[DBG] %s : core[%x,%d] found <%s> / inode = %x in cluster %x\n", 1473 __FUNCTION__ , local_cxy , this->core->lid , name , GET_PTR(child_xp) , GET_CXY(child_xp) ); 1472 1474 1473 1475 // TODO check access rights here [AG] … … 1494 1496 vfs_inode_unlock( parent_xp ); 1495 1497 1496 vfs_dmsg("\n[INFO] %s : exit <%s> found / inode = %l\n",1497 __FUNCTION__ , pathname , child_xp);1498 vfs_dmsg("\n[DBG] %s : core[%x,%d] exit for <%s> / inode = %x in cluster %x\n", 1499 __FUNCTION__,local_cxy,this->core->lid,pathname,GET_PTR(child_xp),GET_CXY(child_xp) ); 1498 1500 1499 1501 // return searched pointer … … 1593 1595 parent_ptr = (vfs_inode_t *)GET_PTR( parent_xp ); 1594 1596 1595 vfs_dmsg("\n[INFO] %s : enter for <%s> / core[%x,%d] / child_cxy = %x / parent_xp = %l\n",1596 __FUNCTION__ , name , local_cxy , CURRENT_THREAD->core->lid , child_cxy , parent_xp);1597 vfs_dmsg("\n[DBG] %s : core[%x,%d] enter for <%s> / child_cxy = %x / parent_cxy = %x\n", 1598 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , name , child_cxy , parent_cxy ); 1597 1599 1598 1600 // 1. create dentry … … 1604 1606 &dentry_xp ); 1605 1607 1606 vfs_dmsg("\n[INFO] %s : dentry <%s> created in local cluster %x\n", 1607 __FUNCTION__ , name , local_cxy ); 1608 vfs_dmsg("\n[DBG] %s : dentry <%s> created in local cluster %x\n", 1609 __FUNCTION__ , name , local_cxy ); 1610 1608 1611 } 1609 1612 else // parent cluster is remote … … 1616 1619 &error ); 1617 1620 1618 vfs_dmsg("\n[INFO] %s : dentry <%s> created in remote cluster %x\n", 1619 __FUNCTION__ , name , parent_cxy ); 1621 vfs_dmsg("\n[DBG] %s : dentry <%s> created in remote cluster %x\n", 1622 __FUNCTION__ , name , parent_cxy ); 1623 1620 1624 } 1621 1625 … … 1623 1627 { 1624 1628 printk("\n[ERROR] in %s : cannot create dentry in cluster %x\n", 1625 1629 __FUNCTION__ , parent_cxy ); 1626 1630 return ENOMEM; 1627 1631 } … … 1645 1649 &inode_xp ); 1646 1650 1647 vfs_dmsg("\n[INFO] %s : inode %l created in local cluster %x\n", 1648 __FUNCTION__ , inode_xp , local_cxy ); 1651 vfs_dmsg("\n[DBG] %s : inode %x created in local cluster %x\n", 1652 __FUNCTION__ , GET_PTR(inode_xp) , local_cxy ); 1653 1649 1654 } 1650 1655 else // child cluster is remote … … 1662 1667 &error ); 1663 1668 1664 vfs_dmsg("\n[INFO] %s : inode %l created in remote cluster %x\n", 1665 __FUNCTION__ , inode_xp , child_cxy ); 1669 vfs_dmsg("\n[DBG] %s : inode %x created in remote cluster %x\n", 1670 __FUNCTION__ , GET_PTR(inode_xp) , child_cxy ); 1671 1666 1672 } 1667 1673 … … 1682 1688 hal_remote_swd( XPTR( dentry_cxy , &dentry_ptr->child_xp ) , inode_xp ); 1683 1689 1684 vfs_dmsg("\n[INFO] %s : exit in cluster %x for <%s>\n",1685 1690 vfs_dmsg("\n[DBG] %s : exit in cluster %x for <%s>\n", 1691 __FUNCTION__ , local_cxy , name ); 1686 1692 1687 1693 // success : return extended pointer on child inode … … 1707 1713 assert( (mapper != NULL) , __FUNCTION__ , "no mapper for page\n" ); 1708 1714 1709 vfs_dmsg("\n[DMSG] %s : enters for page %d / inode_cxy = %x / inode_ptr= %x\n",1710 __FUNCTION__ , page->index , local_cxy, mapper->inode );1715 vfs_dmsg("\n[DBG] %s : core[%x,%d] enters for page %d / mapper = %x / inode = %x\n", 1716 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid , page->index , mapper, mapper->inode ); 1711 1717 1712 1718 // get FS type … … 1733 1739 } 1734 1740 1735 vfs_dmsg("\n[DMSG] %s : exit for page %d / inode_cxy = %x / inode_ptr= %x\n",1736 __FUNCTION__ , page->index , local_cxy, mapper->inode );1741 vfs_dmsg("\n[DBG] %s : core[%x,%d] exit for page %d / mapper = %x / inode = %x\n", 1742 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, page->index, mapper, mapper->inode ); 1737 1743 1738 1744 return error; … … 1753 1759 assert( (mapper != NULL) , __FUNCTION__ , "mapper pointer is NULL\n" ); 1754 1760 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) );1761 vfs_dmsg("\n[DBG] %s : core[%x,%d] enter for inode %x in cluster %x/ cycle %d\n", 1762 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, inode , local_cxy , hal_time_stamp() ); 1757 1763 1758 1764 // compute number of pages … … 1770 1776 } 1771 1777 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) );1778 vfs_dmsg("\n[DBG] %s : core[%x,%d] exit for inode %x in cluster %x / cycle %d\n", 1779 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, inode , local_cxy , hal_time_stamp() ); 1774 1780 1775 1781 return 0;
Note: See TracChangeset
for help on using the changeset viewer.