Changeset 626 for trunk/kernel/fs/vfs.c
- Timestamp:
- Apr 29, 2019, 7:25:09 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/fs/vfs.c
r625 r626 423 423 } // end vfs_inode_load_all_pages() 424 424 425 ///////////////////////////////////////// 426 void vfs_inode_display( xptr_t inode_xp ) 427 { 428 assert( (inode_xp != XPTR_NULL), "inode pointer is NULL"); 429 430 char name[CONFIG_VFS_MAX_NAME_LENGTH]; 431 432 vfs_inode_get_name( inode_xp , name ); 433 434 cxy_t inode_cxy = GET_CXY( inode_xp ); 435 vfs_inode_t * inode_ptr = GET_PTR( inode_xp ); 436 437 vfs_inode_type_t type = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->type ) ); 438 uint32_t attr = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->attr ) ); 439 uint32_t size = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->size ) ); 440 uint32_t parents = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->links ) ); 441 mapper_t * mapper = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->mapper ) ); 442 void * extend = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->extend ) ); 443 444 printk("\n**** inode <%s>\n" 445 " - type = %s\n" 446 " - attr = %x\n" 447 " - size = %d\n" 448 " - parents = %d\n" 449 " - cxy = %x\n" 450 " - inode = %x\n" 451 " - mapper = %x\n" 452 " - extend = %x\n", 453 name, 454 vfs_inode_type_str( type ), 455 attr, 456 size, 457 parents, 458 inode_cxy, 459 inode_ptr, 460 mapper, 461 extend ); 462 463 } // end vfs_inode_display() 464 465 425 466 //////////////////////////////////////////////////////////////////////////////////////////// 426 467 // VFS dentry descriptor related functions … … 737 778 cycle = (uint32_t)hal_get_cycles(); 738 779 if( DEBUG_VFS_OPEN < cycle ) 739 printk("\n[%s] thread[%x,%x] exit for <%s> / fdid %d / c luster%x / cycle %d\n",780 printk("\n[%s] thread[%x,%x] exit for <%s> / fdid %d / cxy %x / cycle %d\n", 740 781 __FUNCTION__, process->pid, this->trdid, path, file_id, GET_CXY( file_xp ), cycle ); 741 782 #endif … … 773 814 // check inode type 774 815 assert( (inode_type == INODE_TYPE_FILE), "bad inode type" ); 816 817 #if DEBUG_VFS_USER_MOVE 818 char name[CONFIG_VFS_MAX_NAME_LENGTH]; 819 uint32_t cycle = (uint32_t)hal_get_cycles(); 820 thread_t * this = CURRENT_THREAD; 821 vfs_inode_t * inode = hal_remote_lpt( XPTR( file_cxy , &file_ptr->inode ) ); 822 vfs_inode_get_name( XPTR( file_cxy , inode ) , name ); 823 if( cycle > DEBUG_VFS_USER_MOVE ) 824 { 825 if( to_buffer ) 826 printk("\n[%s] thread[%x,%x] enter / %d bytes / mapper(%s) -> buffer(%x) / cycle %d\n", 827 __FUNCTION__ , this->process->pid, this->trdid, size, name, buffer, cycle ); 828 else 829 printk("\n[%s] thread[%x,%x] enter / %d bytes / buffer(%x) -> mapper(%s) / cycle %d\n", 830 __FUNCTION__ , this->process->pid, this->trdid, size, buffer, name, cycle ); 831 } 832 #endif 775 833 776 834 // get mapper pointer and file offset from file descriptor … … 794 852 795 853 #if DEBUG_VFS_USER_MOVE 796 char name[CONFIG_VFS_MAX_NAME_LENGTH]; 797 uint32_t cycle = (uint32_t)hal_get_cycles(); 798 thread_t * this = CURRENT_THREAD; 799 vfs_inode_t * inode = hal_remote_lpt( XPTR( file_cxy , &file_ptr->inode ) ); 800 vfs_inode_get_name( XPTR( file_cxy , inode ) , name ); 854 cycle = (uint32_t)hal_get_cycles(); 801 855 if( cycle > DEBUG_VFS_USER_MOVE ) 802 856 { 803 857 if( to_buffer ) 804 printk("\n[%s] thread[%x,%x] moves %d bytes from <%s> mapper to buffer(%x) / cycle %d\n",805 __FUNCTION__ , this->process->pid, this->trdid, size, name, buffer );858 printk("\n[%s] thread[%x,%x] exit / %d bytes / mapper(%s) -> buffer(%x) / cycle %d\n", 859 __FUNCTION__ , this->process->pid, this->trdid, size, name, buffer, cycle ); 806 860 else 807 printk("\n[%s] thread[%x,%x] moves %d bytes from buffer (%x) to <%s> mapper/ cycle %d\n",808 __FUNCTION__ , this->process->pid, this->trdid, size, buffer, name );861 printk("\n[%s] thread[%x,%x] exit / %d bytes / buffer(%x) -> mapper(%s) / cycle %d\n", 862 __FUNCTION__ , this->process->pid, this->trdid, size, buffer, name, cycle ); 809 863 } 810 864 #endif … … 1794 1848 xptr_t inode_children_xp = XPTR( inode_cxy , &inode_ptr->children.items ); 1795 1849 1796 printk("\n@@@ in %s : children_xp = (%x,%x)\n",1797 __FUNCTION__, inode_cxy, &inode_ptr->children.items );1798 1799 1850 // get target inode number of children 1800 1851 inode_children = hal_remote_l32( inode_children_xp ); … … 2166 2217 2167 2218 // display inode 2168 nolock_printk("%s<%s> : %s / extd % d/ %d bytes / dirty %d / cxy %x / inode %x / mapper %x\n",2219 nolock_printk("%s<%s> : %s / extd %x / %d bytes / dirty %d / cxy %x / inode %x / mapper %x\n", 2169 2220 indent_str[indent], name, vfs_inode_type_str( inode_type ), (uint32_t)inode_extd, 2170 2221 inode_size, inode_dirty, inode_cxy, inode_ptr, mapper_ptr ); … … 2301 2352 // This static function is used by the vfs_lookup() function. 2302 2353 // It takes an extended pointer on a remote parent directory inode, a directory 2303 // entry name, and returns an extended pointer on the child inode. 2354 // entry name, and and scan the XHTAB associated to the parent inode to find the 2355 // searched dentry. It does NOT modify the inode tree in case of miss. 2304 2356 // It can be used by any thread running in any cluster. 2305 2357 ////////////////////////////////////////////////////////////////////////////////////////// … … 2424 2476 bool_t create; // searched inode must be created if not found 2425 2477 bool_t excl; // searched inode must not exist 2426 bool_t par ;// searched inode is the parent2478 bool_t parent; // searched inode is the parent 2427 2479 thread_t * this; // pointer on calling thread descriptor 2428 2480 process_t * process; // pointer on calling process descriptor … … 2449 2501 create = (lookup_mode & VFS_LOOKUP_CREATE) == VFS_LOOKUP_CREATE; 2450 2502 excl = (lookup_mode & VFS_LOOKUP_EXCL) == VFS_LOOKUP_EXCL; 2451 par 2503 parent = (lookup_mode & VFS_LOOKUP_PARENT) == VFS_LOOKUP_PARENT; 2452 2504 2453 2505 // initialise loop variables … … 2499 2551 child_cxy = GET_CXY( child_xp ); 2500 2552 2501 // analyse found & last, depending on lookup_mode2502 2553 if( found == false ) // not found in Inode Tree 2503 2554 { 2504 2555 // when a inode is not found in the Inode Tree: 2505 // - if (last and par ) the Inode Tree is not modified2556 // - if (last and parent) the Inode Tree is not modified 2506 2557 // - else we speculatively introduce a new (dentry/inode) in inode tree, 2507 2558 // and scan the parent directory mapper to initialise it. … … 2514 2565 // - if the child is a directory, the child mapper is loaded from device 2515 2566 2516 if( last && par ) // does nothing2567 if( last && parent ) // does nothing 2517 2568 { 2518 2569 … … 2577 2628 } 2578 2629 2579 if ( error ) // child not found in parent mapper 2630 // when the missing dentry is not in the parent mapper, 2631 // it is a new dentry that must be registered in parent directory mapper 2632 if ( error ) 2580 2633 { 2581 2634 if ( last && create ) // add a brand new dentry in parent directory … … 2594 2647 #if (DEBUG_VFS_LOOKUP & 1) 2595 2648 if( DEBUG_VFS_LOOKUP < cycle ) 2596 printk("\n[%s] thread[%x,%x] child <%s> not found in parent mapper => create it\n",2649 printk("\n[%s] thread[%x,%x] child <%s> not found in parent mapper => created it\n", 2597 2650 __FUNCTION__, process->pid, this->trdid, name ); 2598 #endif 2651 vfs_inode_display( child_xp ); 2652 #endif 2653 2654 2599 2655 } 2600 2656 else // not last or not create => error … … 2687 2743 if ( last ) // last inode in path => return relevant info 2688 2744 { 2689 if ( par ) // return parent inode and child name2745 if ( parent ) // return parent inode and child name 2690 2746 { 2691 2747 … … 2757 2813 vfs_inode_t * child_ptr = GET_PTR( child_xp ); 2758 2814 2759 // 1. allocate one free cluster to child inode 2760 // depending on the child inode FS type 2815 // 1. allocate one free cluster in file system to child inode, 2816 // and update the File Allocation Table in both the TAF mapper and IOC device. 2817 // It depends on the child inode FS type. 2761 2818 vfs_ctx_t * ctx = hal_remote_lpt( XPTR( child_cxy , &child_ptr->ctx ) ); 2762 2819 … … 2772 2829 #if( DEBUG_VFS_NEW_DENTRY_INIT & 1) 2773 2830 if( DEBUG_VFS_NEW_DENTRY_INIT < cycle ) 2774 printk("\n[%s] thread[%x,%x] allocated F ATcluster %x to <%s>\n",2831 printk("\n[%s] thread[%x,%x] allocated FS cluster %x to <%s>\n", 2775 2832 __FUNCTION__ , this->process->pid, this->trdid, cluster, child_name ); 2776 2833 #endif 2777 2834 2778 // 2. update the child inode descriptor 2835 // 2. update the child inode descriptor size and extend 2779 2836 child_type = hal_remote_l32( XPTR( child_cxy , &child_ptr->type ) ); 2780 2837 child_size = (child_type == INODE_TYPE_DIR) ? 4096 : 0; … … 3301 3358 #endif 3302 3359 3303 // register new_dentry in parent_inode xhtab of children3360 // 4. register new_dentry in parent_inode xhtab of children 3304 3361 children_xhtab_xp = XPTR( parent_cxy , &parent_inode_ptr->children ); 3305 3362 children_entry_xp = XPTR( parent_cxy , &new_dentry_ptr->children ); … … 3313 3370 #endif 3314 3371 3315 // update "parent" and "child_xp" fields in new_dentry3372 // 5. update "parent" and "child_xp" fields in new_dentry 3316 3373 hal_remote_s64( XPTR( parent_cxy , &new_dentry_ptr->child_xp ) , new_inode_xp ); 3317 3374 hal_remote_spt( XPTR( parent_cxy , &new_dentry_ptr->parent ) , parent_inode_ptr );
Note: See TracChangeset
for help on using the changeset viewer.