Changeset 623 for trunk/kernel/fs/vfs.c
- Timestamp:
- Mar 6, 2019, 4:37:15 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 ///////////////////////////////////////////////////
Note: See TracChangeset
for help on using the changeset viewer.