Changeset 683 for trunk/kernel/fs
- Timestamp:
- Jan 13, 2021, 12:36:17 AM (4 years ago)
- Location:
- trunk/kernel/fs
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/fs/devfs.c
r673 r683 56 56 xptr_t devfs_ctx_alloc( cxy_t cxy ) 57 57 { 58 kmem_req_t req;59 60 req.type = KMEM_KCM;61 req.order = bits_log2( sizeof(devfs_ctx_t) );62 req.flags = AF_KERNEL | AF_ZERO;63 64 58 // allocates devfs context from target cluster 65 return XPTR( cxy , kmem_remote_alloc( cxy , &req ) ); 59 void * ptr = kmem_remote_alloc( cxy, 60 bits_log2(sizeof(devfs_ctx_t)), 61 AF_ZERO ); 62 63 if( ptr == NULL ) return XPTR_NULL; 64 else return XPTR( cxy , ptr ); 66 65 } 67 66 … … 90 89 void devfs_ctx_destroy( xptr_t devfs_ctx_xp ) 91 90 { 92 kmem_req_t req;93 94 91 // get cluster and local pointer on devfs context 95 92 devfs_ctx_t * devfs_ctx_ptr = GET_PTR( devfs_ctx_xp ); 96 93 cxy_t devfs_ctx_cxy = GET_CXY( devfs_ctx_xp ); 97 94 98 req.type = KMEM_KCM;99 req.ptr = devfs_ctx_ptr;100 101 95 // release devfs context descriptor to remote cluster 102 kmem_remote_free( devfs_ctx_cxy , &req ); 96 kmem_remote_free( devfs_ctx_cxy, 97 devfs_ctx_ptr, 98 bits_log2(sizeof(devfs_ctx_t)) ); 103 99 } 104 100 -
trunk/kernel/fs/fatfs.c
r673 r683 1630 1630 xptr_t fatfs_ctx_alloc( cxy_t cxy ) 1631 1631 { 1632 kmem_req_t req;1633 1634 1632 // allocate memory from remote cluster 1635 req.type = KMEM_KCM; 1636 req.order = bits_log2( sizeof(fatfs_ctx_t) ); 1637 req.flags = AF_KERNEL | AF_ZERO; 1638 1639 return XPTR( cxy , kmem_remote_alloc( cxy , &req ) ); 1633 void * ptr = kmem_remote_alloc( cxy, 1634 bits_log2(sizeof(fatfs_ctx_t)), 1635 AF_ZERO ); 1636 1637 if( ptr == NULL ) return XPTR_NULL; 1638 else return XPTR( cxy , ptr ); 1640 1639 1641 1640 } //end faffs_ctx_alloc() … … 1645 1644 { 1646 1645 error_t error; 1647 kmem_req_t req;1648 1646 cxy_t cxy; // FATFS context cluster identifier 1649 1647 fatfs_ctx_t * fatfs_ctx_ptr; // local pointer on FATFS context … … 1667 1665 // allocate a 512 bytes buffer in remote cluster, used to store 1668 1666 // temporarily the BOOT sector, and permanently the FS_INFO sector 1669 req.type = KMEM_KCM; 1670 req.order = 9; // 512 bytes 1671 req.flags = AF_KERNEL | AF_ZERO; 1672 buffer = kmem_remote_alloc( cxy , &req ); 1673 1667 buffer = kmem_remote_alloc( cxy, 1668 9, 1669 AF_ZERO ); 1674 1670 if( buffer == NULL ) 1675 1671 { … … 1827 1823 void fatfs_ctx_destroy( xptr_t fatfs_ctx_xp ) 1828 1824 { 1829 kmem_req_t req;1830 1825 mapper_t * fat_mapper; 1831 1826 uint8_t * fs_info_buffer; … … 1844 1839 fs_info_buffer = hal_remote_lpt( XPTR( fatfs_ctx_cxy , &fatfs_ctx_ptr->fs_info_buffer ) ); 1845 1840 1846 // release FS_INFO buffer 1847 req.type = KMEM_KCM;1848 req.ptr = fs_info_buffer;1849 kmem_remote_free( fatfs_ctx_cxy , &req );1841 // release FS_INFO buffer (512 bytes) 1842 kmem_remote_free( fatfs_ctx_cxy, 1843 fs_info_buffer, 1844 9 ); 1850 1845 1851 1846 // release FATFS context descriptor 1852 req.type = KMEM_KCM;1853 req.ptr = fatfs_ctx_ptr;1854 kmem_remote_free( fatfs_ctx_cxy , &req);1847 kmem_remote_free( fatfs_ctx_cxy, 1848 fatfs_ctx_ptr, 1849 bits_log2(sizeof(fatfs_ctx_t)) ); 1855 1850 1856 1851 } // end fatfs_ctx_destroy() … … 2857 2852 2858 2853 // compute number of pages 2859 npages = size >> CONFIG_PPM_PAGE_ SHIFT;2854 npages = size >> CONFIG_PPM_PAGE_ORDER; 2860 2855 if( size & CONFIG_PPM_PAGE_MASK ) npages++; 2861 2856 -
trunk/kernel/fs/vfs.c
r673 r683 48 48 49 49 ////////////////////////////////////////////////////////////////////////////////////////// 50 // Extern variables50 // Extern global variables 51 51 ////////////////////////////////////////////////////////////////////////////////////////// 52 52 … … 54 54 extern chdev_directory_t chdev_dir; // allocated in kernel_init.c 55 55 extern char * lock_type_str[]; // allocated in kernel_init.c 56 extern process_t process_zero; // allocated in kernel_init.c 56 57 57 58 /////////////////////////////////////////////////////////////////////////////////////////// … … 186 187 uint32_t inum; // inode identifier (to be allocated) 187 188 vfs_ctx_t * ctx; // file system context 188 kmem_req_t req; // request to kernel memory allocator189 189 error_t error; 190 190 … … 192 192 uint32_t cycle = (uint32_t)hal_get_cycles(); 193 193 thread_t * this = CURRENT_THREAD; 194 pid_t pid = this->process->pid; 195 trdid_t trdid = this->trdid; 194 196 #endif 195 197 … … 202 204 203 205 #if DEBUG_VFS_ERROR 204 if( DEBUG_VFS_ERROR < cycle ) 205 printk("\n[ERROR] in %s : thread[%x,%x] / illegal FS type\n", 206 __FUNCTION__ , this->process->pid , this->trdid ); 206 printk("\n[ERROR] in %s : thread[%x,%x] / illegal FS type / cycle %d\n", 207 __FUNCTION__ , pid , trdid, cycle ); 207 208 #endif 208 209 return -1; … … 220 221 221 222 #if DEBUG_VFS_ERROR 222 if( DEBUG_VFS_ERROR < cycle ) 223 printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate inum\n", 224 __FUNCTION__ , this->process->pid , this->trdid ); 223 printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate inum / cycle %d\n", 224 __FUNCTION__ , pid , trdid, cycle ); 225 225 #endif 226 226 return -1; … … 234 234 235 235 #if DEBUG_VFS_ERROR 236 if( DEBUG_VFS_ERROR < cycle ) 237 printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate mapper\n", 238 __FUNCTION__ , this->process->pid , this->trdid ); 236 printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate mapper / cycle %d\n", 237 __FUNCTION__ , pid , trdid, cycle ); 239 238 #endif 240 239 vfs_ctx_inum_release( XPTR( cxy , ctx ) , inum ); … … 244 243 mapper_ptr = GET_PTR( mapper_xp ); 245 244 246 // allocate one page for VFS inode descriptor 247 // because the embedded "children" xhtab footprint 248 req.type = KMEM_PPM; 249 req.order = 0; 250 req.flags = AF_KERNEL | AF_ZERO; 251 inode_ptr = kmem_remote_alloc( cxy , &req ); 252 245 // allocate memory for inode descriptor 246 inode_ptr = kmem_remote_alloc( cxy, 247 bits_log2(sizeof(vfs_inode_t)), 248 AF_ZERO ); 253 249 if( inode_ptr == NULL ) 254 250 { 255 251 256 252 #if DEBUG_VFS_ERROR 257 if( DEBUG_VFS_ERROR < cycle ) 258 printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate inode\n", 259 __FUNCTION__ , this->process->pid , this->trdidi ); 253 printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate inode / cycle %d\n", 254 __FUNCTION__ , pid , trdid, cycle ); 260 255 #endif 261 256 vfs_ctx_inum_release( XPTR( cxy , ctx ) , inum ); … … 297 292 if( DEBUG_VFS_INODE_CREATE < cycle ) 298 293 printk("\n[%s] thread[%x,%x] created inode (%x,%x) / ctx %x / fs_type %d / cycle %d\n", 299 __FUNCTION__, this->process->pid, this->trdid, cxy, inode_ptr, ctx, ctx->type, cycle );294 __FUNCTION__, pid, trdid, cxy, inode_ptr, ctx, ctx->type, cycle ); 300 295 #endif 301 296 … … 318 313 319 314 // release memory allocated for inode descriptor 320 kmem_req_t req; 321 req.type = KMEM_PPM; 322 req.ptr = inode_ptr; 323 kmem_remote_free( inode_cxy , &req ); 315 kmem_remote_free( inode_cxy, 316 inode_ptr, 317 bits_log2(sizeof(vfs_inode_t)) ); 324 318 325 319 } // end vfs_inode_destroy() … … 447 441 uint32_t size = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->size ) ); 448 442 449 #if DEBUG_VFS_INODE_LOAD_ALL 450 char name[CONFIG_VFS_MAX_NAME_LENGTH]; 443 #if DEBUG_VFS_INODE_LOAD_ALL || DEBUG_VFS_ERROR 451 444 uint32_t cycle = (uint32_t)hal_get_cycles(); 452 445 thread_t * this = CURRENT_THREAD; 446 #endif 447 448 #if DEBUG_VFS_INODE_LOAD_ALL 449 char name[CONFIG_VFS_MAX_NAME_LENGTH]; 453 450 vfs_inode_get_name( inode_xp , name ); 454 451 if( DEBUG_VFS_INODE_LOAD_ALL < cycle ) … … 458 455 459 456 // compute number of pages 460 uint32_t npages = size >> CONFIG_PPM_PAGE_ SHIFT;457 uint32_t npages = size >> CONFIG_PPM_PAGE_ORDER; 461 458 if( (size & CONFIG_PPM_PAGE_MASK) || (size == 0) ) npages++; 462 459 … … 468 465 page_xp = mapper_get_page( XPTR( inode_cxy , mapper ), page_id ); 469 466 470 if( page_xp == XPTR_NULL ) return -1; 467 if( page_xp == XPTR_NULL ) 468 { 469 470 #if DEBUG_VFS_ERROR 471 printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate memory for mapper / cycle %d\n", 472 __FUNCTION__, this->process->pid, this->trdid, cycle ); 473 #endif 474 return -1; 475 } 471 476 } 472 477 … … 534 539 xptr_t * dentry_xp ) 535 540 { 536 kmem_req_t req; // request to kernel memory allocator537 541 vfs_ctx_t * ctx = NULL; // context descriptor 538 542 vfs_dentry_t * dentry_ptr; // dentry descriptor (to be allocated) … … 557 561 558 562 #if DEBUG_VFS_ERROR 559 if( DEBUG_VFS_ERROR < cycle ) 560 printk("\n[ERROR] in %s : thread[%x,%x] / undefined fs_type %d\n", 561 __FUNCTION__ , this->process->pid, this->trdid, fs_type ); 563 printk("\n[ERROR] in %s : thread[%x,%x] / undefined fs_type %d / cycle %d\n", 564 __FUNCTION__ , this->process->pid, this->trdid, fs_type, cycle ); 562 565 #endif 563 566 return -1; … … 570 573 571 574 // allocate memory for dentry descriptor 572 req.type = KMEM_KCM; 573 req.order = bits_log2( sizeof(vfs_dentry_t) ); 574 req.flags = AF_KERNEL | AF_ZERO; 575 dentry_ptr = kmem_remote_alloc( cxy , &req ); 576 575 dentry_ptr = kmem_remote_alloc( cxy, 576 bits_log2(sizeof(vfs_dentry_t)), 577 AF_ZERO ); 577 578 if( dentry_ptr == NULL ) 578 579 { 579 580 580 581 #if DEBUG_VFS_ERROR 581 if( DEBUG_VFS_ERROR < cycle ) 582 printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate dentry descriptor\n", 583 __FUNCTION__ , this->process->pid, this->trdid ); 582 printk("\n[ERROR] in %s : thread[%x,%x] cannot allocate dentry descriptor / cycle %d\n", 583 __FUNCTION__ , this->process->pid, this->trdid, cycle ); 584 584 #endif 585 585 return -1; … … 616 616 617 617 // release memory allocated to dentry 618 kmem_req_t req; 619 req.type = KMEM_KCM; 620 req.ptr = dentry_ptr; 621 kmem_remote_free( dentry_cxy , &req ); 618 kmem_remote_free( dentry_cxy, 619 dentry_ptr, 620 bits_log2(sizeof(vfs_dentry_t)) ); 622 621 623 622 } // end vfs_dentry_destroy() … … 634 633 { 635 634 vfs_file_t * file_ptr; 636 kmem_req_t req;637 635 uint32_t type; 638 636 mapper_t * mapper; … … 644 642 cxy_t inode_cxy = GET_CXY( inode_xp ); 645 643 644 #if DEBUG_VFS_FILE_CREATE || DEBUG_VFS_ERROR 645 thread_t * this = CURRENT_THREAD; 646 uint32_t cycle = (uint32_t)hal_get_cycles(); 647 #endif 648 646 649 #if DEBUG_VFS_FILE_CREATE 647 thread_t * this = CURRENT_THREAD;648 uint32_t cycle = (uint32_t)hal_get_cycles();649 650 if( DEBUG_VFS_FILE_CREATE < cycle ) 650 651 printk("\n[%s] thread[%x,%x] enter for inode (%x,%x) / cycle %d\n", … … 653 654 654 655 // allocate memory for new file descriptor 655 req.type = KMEM_KCM; 656 req.order = bits_log2( sizeof(vfs_file_t) ); 657 req.flags = AF_KERNEL | AF_ZERO; 658 file_ptr = kmem_remote_alloc( inode_cxy , &req ); 659 660 if( file_ptr == NULL ) return -1; 656 file_ptr = kmem_remote_alloc( inode_cxy, 657 bits_log2(sizeof(vfs_file_t)), 658 AF_ZERO ); 659 660 if( file_ptr == NULL ) 661 { 662 663 #if DEBUG_VFS_ERROR 664 printk("\n[ERROR] in %s : thread[%x,%x] / cannot allocate memory / cycle %d\n", 665 __FUNCTION__ , this->process->pid, this->trdid, cycle ); 666 #endif 667 return -1; 668 } 661 669 662 670 // get type, ctx, mapper, and buffer from inode descriptor … … 718 726 719 727 // release file descriptor 720 kmem_req_t req; 721 req.type = KMEM_KCM; 722 req.ptr = file_ptr; 723 kmem_remote_free( file_cxy , &req ); 728 kmem_remote_free( file_cxy, 729 file_ptr, 730 bits_log2(sizeof(vfs_file_t)) ); 724 731 725 732 #if DEBUG_VFS_FILE_DESTROY … … 775 782 xptr_t lock_xp; // extended pointer on Inode Tree lock 776 783 784 #if DEBUG_VFS_OPEN || DEBUG_VFS_ERROR 785 uint32_t cycle = (uint32_t)hal_get_cycles(); 786 thread_t * this = CURRENT_THREAD; 787 pid_t pid = this->process->pid; 788 trdid_t trdid = this->trdid; 789 #endif 790 777 791 if( mode != 0 ) 778 792 { 779 printk("\n[ERROR] in %s : the mode parameter is not supported yet\n" ); 793 794 #if DEBUG_VFS_ERROR 795 printk("\n[ERROR] in %s : the mode parameter is not supported yet\n" ); 796 #endif 780 797 return -1; 781 798 } 782 783 thread_t * this = CURRENT_THREAD;784 process_t * process = this->process;785 799 786 800 // compute lookup working mode … … 790 804 if( (flags & O_EXCL ) ) lookup_mode |= VFS_LOOKUP_EXCL; 791 805 792 #if DEBUG_VFS_OPEN || DEBUG_VFS_ERROR793 uint32_t cycle = (uint32_t)hal_get_cycles();794 #endif795 796 806 #if DEBUG_VFS_OPEN 797 807 if( DEBUG_VFS_OPEN < cycle ) 798 808 printk("\n[%s] thread[%x,%x] enter for <%s> / root_inode (%x,%x) / cycle %d\n", 799 __FUNCTION__, p rocess->pid, this->trdid, path, GET_CXY(root_xp), GET_PTR(root_xp), cycle );809 __FUNCTION__, pid, trdid, path, GET_CXY(root_xp), GET_PTR(root_xp), cycle ); 800 810 #endif 801 811 … … 809 819 810 820 // build extended pointer on lock protecting Inode Tree 811 vfs_root_xp = process ->vfs_root_xp;821 vfs_root_xp = process_zero.vfs_root_xp; 812 822 vfs_root_ptr = GET_PTR( vfs_root_xp ); 813 823 vfs_root_cxy = GET_CXY( vfs_root_xp ); … … 831 841 832 842 #if DEBUG_VFS_ERROR 833 if( DEBUG_VFS_ERROR < cycle ) 834 printk("\n[ERROR] in %s : thread[%x,%x] cannot get inode <%s>\n", 835 __FUNCTION__ , process->pid, this->trdid , path ); 843 printk("\n[ERROR] in %s : thread[%x,%x] cannot get inode <%s> / cycle %d\n", 844 __FUNCTION__ , pid, trdid , path , cycle ); 836 845 #endif 837 846 return -1; … … 843 852 844 853 #if (DEBUG_VFS_OPEN & 1) 845 cycle = (uint32_t)hal_get_cycles();846 854 if( DEBUG_VFS_OPEN < cycle ) 847 855 printk("\n[%s] thread[%x,%x] found inode(%x,%x) for <%s>\n", 848 __FUNCTION__, p rocess->pid, this->trdid, inode_cxy, inode_ptr, path );856 __FUNCTION__, pid, trdid, inode_cxy, inode_ptr, path ); 849 857 #endif 850 858 … … 852 860 error = vfs_file_create( inode_xp , file_attr , &file_xp ); 853 861 854 if( error ) return error; 862 if( error ) 863 { 864 865 #if DEBUG_VFS_ERROR 866 printk("\n[ERROR] in %s : thread[%x,%x] cannot create file descriptor for <%s> / cycle %d\n", 867 __FUNCTION__ , pid, trdid , path , cycle ); 868 #endif 869 return error; 870 } 855 871 856 872 #if (DEBUG_VFS_OPEN & 1) 857 cycle = (uint32_t)hal_get_cycles();858 873 if( DEBUG_VFS_OPEN < cycle ) 859 874 printk("\n[%s] thread[%x,%x] created file descriptor (%x,%x) for <%s>\n", 860 __FUNCTION__, p rocess->pid, this->trdid, GET_CXY(file_xp), GET_PTR(file_xp), path );875 __FUNCTION__, pid, trdid, GET_CXY(file_xp), GET_PTR(file_xp), path ); 861 876 #endif 862 877 … … 864 879 error = process_fd_register( process_xp , file_xp , &file_id ); 865 880 866 if( error ) return error; 881 if( error ) 882 { 883 884 #if DEBUG_VFS_ERROR 885 printk("\n[ERROR] in %s : thread[%x,%x] cannot register file descriptor for <%s> / cycle %d\n", 886 __FUNCTION__ , pid, trdid , path , cycle ); 887 #endif 888 return error; 889 } 867 890 868 891 // get new file descriptor cluster and local pointer … … 891 914 if( DEBUG_VFS_OPEN < cycle ) 892 915 printk("\n[%s] thread[%x,%x] exit for <%s> / fdid %d / file(%x,%x) / cycle %d\n", 893 __FUNCTION__, p rocess->pid, this->trdid, path, file_id,916 __FUNCTION__, pid, trdid, path, file_id, 894 917 GET_CXY( file_xp ), GET_PTR( file_xp ), cycle ); 895 918 #endif … … 997 1020 998 1021 #if DEBUG_VFS_ERROR 999 if( DEBUG_VFS_ERROR < cycle ) 1000 printk("\n[ERROR] in %s thread[%x,%x] cannot move data", 1001 __FUNCTION__, this->process->pid, this->trdid ); 1022 printk("\n[ERROR] in %s thread[%x,%x] cannot move data / cycle %d", 1023 __FUNCTION__, this->process->pid, this->trdid, cycle ); 1002 1024 #endif 1003 1025 return -1; … … 1008 1030 1009 1031 #if DEBUG_VFS_USER_MOVE 1010 cycle = (uint32_t)hal_get_cycles();1011 1032 if( cycle > DEBUG_VFS_USER_MOVE ) 1012 1033 { … … 1032 1053 cxy_t file_cxy; // remote file descriptor cluster 1033 1054 vfs_file_t * file_ptr; // remote file descriptor local pointer 1034 vfs_file_type_t inode_type; // remote file type1035 1055 uint32_t file_offset; // current offset in file 1036 1056 mapper_t * mapper_ptr; // remote mapper local pointer … … 1041 1061 assert( __FUNCTION__, (file_xp != XPTR_NULL) , "file_xp == XPTR_NULL" ); 1042 1062 1063 #if DEBUG_VFS_KERNEL_MOVE || DEBUG_VFS_ERROR 1064 uint32_t cycle = (uint32_t)hal_get_cycles(); 1065 thread_t * this = CURRENT_THREAD; 1066 #endif 1067 1043 1068 // get cluster and local pointer on remote file descriptor 1044 1069 file_cxy = GET_CXY( file_xp ); 1045 1070 file_ptr = GET_PTR( file_xp ); 1046 1047 // get inode type from remote file descriptor1048 inode_type = hal_remote_l32( XPTR( file_cxy , &file_ptr->type ) );1049 1050 // check inode type1051 assert( __FUNCTION__, (inode_type == FILE_TYPE_REG), "bad file type" );1052 1071 1053 1072 // get mapper pointers and file offset from file descriptor … … 1064 1083 if( error ) 1065 1084 { 1066 printk("\n[ERROR] in %s : cannot move data", __FUNCTION__ ); 1085 1086 #if DEBUG_VFS_ERROR 1087 printk("\n[ERROR] in %s : thread[%x,%x] / cannot move data / cycle %d\n", 1088 __FUNCTION__ , this->process->pid , this->trdid , cycle ); 1089 #endif 1067 1090 return -1; 1091 1068 1092 } 1069 1093 1070 1094 #if DEBUG_VFS_KERNEL_MOVE 1071 1095 char name[CONFIG_VFS_MAX_NAME_LENGTH]; 1072 uint32_t cycle = (uint32_t)hal_get_cycles();1073 thread_t * this = CURRENT_THREAD;1074 1096 cxy_t buffer_cxy = GET_CXY( buffer_xp ); 1075 1097 void * buffer_ptr = GET_PTR( buffer_xp ); … … 1109 1131 assert( __FUNCTION__, (new_offset != NULL ) , "new_offset == NULL" ); 1110 1132 1133 #if DEBUG_VFS_LSEEK || DEBUG_VFS_ERROR 1134 uint32_t cycle = (uint32_t)hal_get_cycles(); 1135 thread_t * this = CURRENT_THREAD; 1136 #endif 1137 1111 1138 // get cluster and local pointer on remote file descriptor 1112 1139 file_cxy = GET_CXY( file_xp ); … … 1138 1165 else 1139 1166 { 1140 printk("\n[ERROR] in %s : illegal whence value\n", __FUNCTION__ ); 1167 1168 #if DEBUG_VFS_ERROR 1169 printk("\n[ERROR] in %s : thread[%x,%x] / undefined whence value / cycle %d", 1170 __FUNCTION__ , this->process->pid , this->trdid , cycle ); 1171 #endif 1141 1172 remote_rwlock_wr_release( lock_xp ); 1142 1173 return -1; … … 1191 1222 cluster_t * cluster = LOCAL_CLUSTER; 1192 1223 1224 #if DEBUG_VFS_CLOSE || DEBUG_VFS_ERROR 1225 uint32_t cycle = (uint32_t)hal_get_cycles(); 1226 #endif 1227 1193 1228 // get file name 1194 1229 vfs_file_get_name( file_xp , name ); 1195 1230 1196 1231 #if DEBUG_VFS_CLOSE 1197 uint32_t cycle = (uint32_t)hal_get_cycles();1198 1232 if( DEBUG_VFS_CLOSE < cycle ) 1199 1233 printk("\n[%s] thread[%x,%x] enter for <%s> / cycle %d\n", … … 1215 1249 if( error ) 1216 1250 { 1217 printk("\n[ERROR] in %s : cannot synchronise dirty pages for <%s>\n", 1218 __FUNCTION__, name ); 1251 1252 #if DEBUG_VFS_ERROR 1253 printk("\n[ERROR] in %s : thread[%x,%x] / cannot synchronise dirty pages for <%s> / cycle %d\n", 1254 __FUNCTION__ , this->process->pid , this->trdid , name , cycle ); 1255 #endif 1219 1256 return -1; 1220 1257 } … … 1222 1259 #if DEBUG_VFS_CLOSE 1223 1260 if( DEBUG_VFS_CLOSE < cycle ) 1224 printk("\n[%s] thread[%x,%x] synchronised mapper of <%s>to device\n",1261 printk("\n[%s] thread[%x,%x] synchronised <%s> mapper to device\n", 1225 1262 __FUNCTION__, process->pid, this->trdid, name ); 1226 1263 #endif … … 1259 1296 if( error ) 1260 1297 { 1261 printk("\n[ERROR] in %s : cannot update size in parent\n", 1262 __FUNCTION__ ); 1298 1299 #if DEBUG_VFS_ERROR 1300 printk("\n[ERROR] in %s : thread[%x,%x] / cannot update size in parent / cycle %d\n", 1301 __FUNCTION__ , this->process->pid , this->trdid , cycle ); 1302 #endif 1263 1303 return -1; 1264 1304 } … … 1277 1317 if( error ) 1278 1318 { 1279 printk("\n[ERROR] in %s : cannot synchronise parent mapper to device\n", 1280 __FUNCTION__ ); 1319 1320 #if DEBUG_VFS_ERROR 1321 printk("\n[ERROR] in %s : thread[%x,%x] / cannot synchronise mapper & device / cycle %d\n", 1322 __FUNCTION__ , this->process->pid , this->trdid , cycle ); 1323 #endif 1281 1324 return -1; 1282 1325 } … … 1367 1410 char last_name[CONFIG_VFS_MAX_NAME_LENGTH]; 1368 1411 1412 #if DEBUG_VFS_MKDIR || DEBUG_VFS_ERROR 1413 uint32_t cycle = (uint32_t)hal_get_cycles(); 1414 #endif 1415 1369 1416 thread_t * this = CURRENT_THREAD; 1370 1417 process_t * process = this->process; … … 1373 1420 char root_name[CONFIG_VFS_MAX_NAME_LENGTH]; 1374 1421 vfs_inode_get_name( root_xp , root_name ); 1375 uint32_t cycle = (uint32_t)hal_get_cycles();1376 1422 if( DEBUG_VFS_MKDIR < cycle ) 1377 1423 printk("\n[%s] thread[%x,%x] enter / root <%s> / path <%s> / cycle %d\n", … … 1396 1442 if( error ) 1397 1443 { 1444 1445 #if DEBUG_VFS_ERROR 1446 printk("\n[ERROR] in %s : thread[%x,%x] cannot get parent inode for <%s> / cycle %d\n", 1447 __FUNCTION__, process->pid, this->trdid, path , cycle ); 1448 #endif 1398 1449 remote_rwlock_wr_release( lock_xp ); 1399 printk("\n[ERROR] in %s : cannot get parent inode for <%s>\n",1400 __FUNCTION__, path );1401 1450 return -1; 1402 1451 } … … 1423 1472 if( error ) 1424 1473 { 1474 1475 #if DEBUG_VFS_ERROR 1476 printk("\n[ERROR] in %s : thread[%x,%x] cannot create dentry in cluster %x for <%s> / cycle %d\n", 1477 __FUNCTION__, process->pid, this->trdid, parent_cxy, path , cycle ); 1478 #endif 1425 1479 remote_rwlock_wr_release( lock_xp ); 1426 printk("\n[ERROR] in %s : cannot create new dentry in cluster %x for <%s>\n",1427 __FUNCTION__, parent_cxy, path );1428 1480 return -1; 1429 1481 } … … 1457 1509 if( error ) 1458 1510 { 1511 1512 #if DEBUG_VFS_ERROR 1513 printk("\n[ERROR] in %s : thread[%x,%x] cannot create inode in cluster %x for <%s> / cycle %d\n", 1514 __FUNCTION__, process->pid, this->trdid, parent_cxy, path , cycle ); 1515 #endif 1459 1516 remote_rwlock_wr_release( lock_xp ); 1460 printk("\n[ERROR] in %s : cannot create new inode in cluster %x for <%s>\n",1461 __FUNCTION__ , inode_cxy , path );1462 1517 vfs_dentry_destroy( dentry_xp ); 1463 1518 return -1; … … 1504 1559 if( error ) 1505 1560 { 1561 1562 #if DEBUG_VFS_ERROR 1563 printk("\n[ERROR] in %s : thread[%x,%x] cannot create <.> & <..> dentries for <%s> / cycle %d\n", 1564 __FUNCTION__, process->pid, this->trdid, path , cycle ); 1565 #endif 1566 vfs_remove_child_from_parent( dentry_xp ); 1506 1567 remote_rwlock_wr_release( lock_xp ); 1507 printk("\n[ERROR] in %s : cannot create new inode in cluster %x for <%s>\n",1508 __FUNCTION__ , inode_cxy , path );1509 vfs_dentry_destroy( dentry_xp );1510 1568 return -1; 1511 1569 } … … 1520 1578 if( error ) 1521 1579 { 1522 printk("\n[ERROR] in %s : cannot update parent directory for <%s>\n", 1523 __FUNCTION__, path ); 1580 1581 #if DEBUG_VFS_ERROR 1582 printk("\n[ERROR] in %s : thread[%x,%x] cannot update parent directory for <%s> / cycle %d\n", 1583 __FUNCTION__, process->pid, this->trdid, path , cycle ); 1584 #endif 1585 vfs_remove_child_from_parent( dentry_xp ); 1524 1586 return -1; 1525 1587 } … … 1527 1589 #if(DEBUG_VFS_MKDIR & 1) 1528 1590 if( DEBUG_VFS_MKDIR < cycle ) 1529 printk("\n[%s] thread[%x,%x] updated parent dir (mapper and IOC) for <%s>\n",1591 printk("\n[%s] thread[%x,%x] created <%s> dir (Inode-Tree, Mapper and IOC)\n", 1530 1592 __FUNCTION__, process->pid, this->trdid, path ); 1531 1593 #endif … … 1565 1627 char new_name[CONFIG_VFS_MAX_NAME_LENGTH]; 1566 1628 1629 #if DEBUG_VFS_LINK || DEBUG_VFS_ERROR 1630 uint32_t cycle = (uint32_t)hal_get_cycles(); 1631 #endif 1632 1567 1633 thread_t * this = CURRENT_THREAD; 1568 1634 process_t * process = this->process; … … 1573 1639 vfs_inode_get_name( old_root_xp , old_root_name ); 1574 1640 vfs_inode_get_name( new_root_xp , new_root_name ); 1575 uint32_t cycle = (uint32_t)hal_get_cycles();1576 1641 if( DEBUG_VFS_LINK < cycle ) 1577 1642 printk("\n[%s] thread[%x,%x] enter / old_root <%s> / old_path <%s> / " … … 1598 1663 if( error ) 1599 1664 { 1665 1666 #if DEBUG_VFS_ERROR 1667 printk("\n[ERROR] in %s : thread[%x,%x] cannot get target inode for <%s> / cycle %d\n", 1668 __FUNCTION__, process->pid, this->trdid, old_path , cycle ); 1669 #endif 1600 1670 remote_rwlock_wr_release( lock_xp ); 1601 printk("\n[ERROR] in %s : cannot get target inode for <%s>\n",1602 __FUNCTION__, old_path );1603 1671 return -1; 1604 1672 } … … 1619 1687 if( error ) 1620 1688 { 1689 1690 #if DEBUG_VFS_ERROR 1691 printk("\n[ERROR] in %s : thread[%x,%x] cannot get parent inode for <%s> / cycle %d\n", 1692 __FUNCTION__, process->pid, this->trdid, new_path , cycle ); 1693 #endif 1621 1694 remote_rwlock_wr_release( lock_xp ); 1622 printk("\n[ERROR] in %s : cannot get parent inode for <%s>\n",1623 __FUNCTION__, new_path );1624 1695 return -1; 1625 1696 } … … 1655 1726 if( error ) 1656 1727 { 1728 1729 #if DEBUG_VFS_ERROR 1730 printk("\n[ERROR] in %s : thread[%x,%x] cannot create new dentry for <%s> / cycle %d\n", 1731 __FUNCTION__, process->pid, this->trdid, new_path , cycle ); 1732 #endif 1657 1733 remote_rwlock_wr_release( lock_xp ); 1658 printk("\n[ERROR] in %s : cannot create new dentry for <%s>\n",1659 __FUNCTION__, new_path );1660 1734 return -1; 1661 1735 } … … 1696 1770 if( error ) 1697 1771 { 1698 printk("\n[ERROR] in %s : cannot update new parent directory for <%s>\n", 1699 __FUNCTION__, new_path ); 1772 1773 #if DEBUG_VFS_ERROR 1774 printk("\n[ERROR] in %s : thread[%x,%x] cannot update parent directory for <%s> / cycle %d\n", 1775 __FUNCTION__, process->pid, this->trdid, new_path , cycle ); 1776 #endif 1700 1777 return -1; 1701 1778 } … … 1710 1787 else 1711 1788 { 1712 // release the lock protecting Inode Tree 1789 1790 #if DEBUG_VFS_ERROR 1791 printk("\n[ERROR] in %s : thread[%x,%x] / unsupported inode type %s / cycle %d\n", 1792 __FUNCTION__, process->pid, this->trdid, vfs_inode_type_str( inode_type ), cycle ); 1793 #endif 1713 1794 remote_rwlock_wr_release( lock_xp ); 1714 1715 printk("\n[ERROR] in %s : unsupported inode type %s\n",1716 __FUNCTION__ , vfs_inode_type_str( inode_type ) );1717 1795 return -1; 1718 1796 } … … 1746 1824 char parent_name[CONFIG_VFS_MAX_NAME_LENGTH]; // name of parent directory 1747 1825 1826 #if DEBUG_VFS_UNLINK || DEBUG_VFS_ERROR 1827 uint32_t cycle = (uint32_t)hal_get_cycles(); 1828 #endif 1829 1748 1830 thread_t * this = CURRENT_THREAD; 1749 1831 process_t * process = this->process; 1750 1832 1751 1833 #if DEBUG_VFS_UNLINK 1752 uint32_t cycle = (uint32_t)hal_get_cycles();1753 1834 char root_name[CONFIG_VFS_MAX_NAME_LENGTH]; 1754 1835 vfs_inode_get_name( root_xp , root_name ); … … 1775 1856 if( error ) 1776 1857 { 1858 1859 #if DEBUG_VFS_ERROR 1860 printk("\n[ERROR] in %s : thread[%x,%x] cannot get parent inode for <%s> / cycle %d\n", 1861 __FUNCTION__, process->pid, this->trdid, path , cycle ); 1862 #endif 1777 1863 remote_rwlock_wr_release( lock_xp ); 1778 printk("\n[ERROR] in %s : cannot get parent inode for <%s> in <%s>\n",1779 __FUNCTION__, child_name, path );1780 1864 return -1; 1781 1865 } … … 1824 1908 if( error ) 1825 1909 { 1826 printk("\n[ERROR] in %s : cannot create inode <%s> in Inode Tree\n", 1827 __FUNCTION__ , child_name ); 1910 1911 #if DEBUG_VFS_ERROR 1912 printk("\n[ERROR] in %s : thread[%x,%x] cannot create node <%s> in Inode_Tree / cycle %d\n", 1913 __FUNCTION__, process->pid, this->trdid, path, cycle ); 1914 #endif 1915 remote_rwlock_wr_release( lock_xp ); 1828 1916 return -1; 1829 1917 } … … 1839 1927 if ( error ) 1840 1928 { 1841 printk("\n[ERROR] in %s : cannot get entry <%s> in parent <%s> mapper\n", 1842 __FUNCTION__ , child_name, parent_name ); 1929 1930 #if DEBUG_VFS_ERROR 1931 printk("\n[ERROR] in %s : thread[%x,%x] cannot get dentry <%s> in parent <%s> mapper / cycle %d\n", 1932 __FUNCTION__, process->pid, this->trdid, child_name, parent_name, cycle ); 1933 #endif 1934 remote_rwlock_wr_release( lock_xp ); 1843 1935 return -1; 1844 1936 } … … 1861 1953 } 1862 1954 1863 // At this point the Inode Tree contains the target dentry and child inode1955 // At this point the Inode-Tree contains the parent dentry and child inode 1864 1956 // we can safely remove this dentry from both the parent mapper, and the Inode Tree. 1865 1957 … … 1897 1989 if( inode_children != 0 ) 1898 1990 { 1991 1992 #if DEBUG_VFS_ERROR 1993 printk("\n[ERROR] in %s : thread[%x,%x] cannot remove <%s> inode that has children / cycle %d\n", 1994 __FUNCTION__, process->pid, this->trdid, path, cycle ); 1995 #endif 1899 1996 remote_rwlock_wr_release( lock_xp ); 1900 printk("\n[ERROR] in %s : cannot remove <%s> inode that has children\n",1901 __FUNCTION__, path );1902 1997 return -1; 1903 1998 } … … 1908 2003 if( error ) 1909 2004 { 2005 2006 #if DEBUG_VFS_ERROR 2007 printk("\n[ERROR] in %s : thread[%x,%x] cannot update FAT mapper to remove <s> / cycle %d\n", 2008 __FUNCTION__, process->pid, this->trdid, path, cycle ); 2009 #endif 1910 2010 remote_rwlock_wr_release( lock_xp ); 1911 printk("\n[ERROR] in %s : cannot update FAT mapper to remove <%s> inode\n",1912 __FUNCTION__ , path );1913 2011 return -1; 1914 2012 } … … 1927 2025 if( error ) 1928 2026 { 2027 2028 #if DEBUG_VFS_ERROR 2029 printk("\n[ERROR] in %s : thread[%x,%x] cannot update parent directory on IOC for <s> / cycle %d\n", 2030 __FUNCTION__, process->pid, this->trdid, path, cycle ); 2031 #endif 1929 2032 remote_rwlock_wr_release( lock_xp ); 1930 printk("\n[ERROR] in %s : cannot update dentry on device for <%s>\n",1931 __FUNCTION__ , path );1932 2033 return -1; 1933 2034 } … … 1979 2080 else 1980 2081 { 2082 2083 #if DEBUG_VFS_ERROR 2084 printk("\n[ERROR] in %s : thread[%x,%x] unsupported inode type %d for <s> / cycle %d\n", 2085 __FUNCTION__, process->pid, this->trdid, vfs_inode_type_str( inode_type ), path, cycle ); 2086 #endif 1981 2087 remote_rwlock_wr_release( lock_xp ); 1982 printk("\n[ERROR] in %s : unsupported inode type %s\n",1983 __FUNCTION__ , vfs_inode_type_str( inode_type ) );1984 2088 return -1; 1985 2089 } … … 2004 2108 process_t * process = this->process; 2005 2109 2110 #if DEBUG_VFS_STAT || DEBUG_VFS_ERROR 2111 uint32_t cycle = (uint32_t)hal_get_cycles(); 2112 #endif 2113 2006 2114 // build extended pointer on lock protecting Inode Tree (in VFS root inode) 2007 2115 vfs_root_xp = process->vfs_root_xp; … … 2025 2133 if( error ) 2026 2134 { 2027 printk("\n[ERROR] in %s : cannot found inode <%s>\n", 2028 __FUNCTION__ , path ); 2135 2136 #if DEBUG_VFS_ERROR 2137 printk("\n[ERROR] in %s : thread[%x,%x] cannot found inode <%s> / cycle %d\n", 2138 __FUNCTION__, process->pid, this->trdid, path, cycle ); 2139 #endif 2029 2140 return -1; 2030 2141 } … … 2050 2161 2051 2162 #if DEBUG_VFS_STAT 2052 uint32_t cycle = (uint32_t)hal_get_cycles();2053 2163 if( DEBUG_VFS_STAT < cycle ) 2054 printk("\n[%s] thread[%x,%x] set stat %x for inode %x in cluster %x / cycle %d\n" 2055 " %s / inum %d / size %d\n", 2056 __FUNCTION__, process->pid, this->trdid, st, inode_ptr, inode_cxy, cycle, 2057 vfs_inode_type_str( type ), inum, size ); 2164 printk("\n[%s] thread[%x,%x] set stat for <%s> / %s / inum %d / size %d / cycle %d\n", 2165 __FUNCTION__, process->pid, this->trdid, path, vfs_inode_type_str( type ), inum, size, cycle ); 2058 2166 #endif 2059 2167 … … 2084 2192 process_t * process = this->process; 2085 2193 2086 #if DEBUG_VFS_CHDIR 2087 uint32_t cycle = (uint32_t)hal_get_cycles(); 2088 if( DEBUG_VFS_CHDIR < cycle ) 2089 printk("\n[%s] thread[%x,%x] enter for path <%s> / cycle %d\n", 2090 __FUNCTION__, process->pid, this->trdid, path, cycle ); 2194 #if DEBUG_VFS_CHDIR || DEBUG_VFS_ERROR 2195 uint32_t cycle = (uint32_t)hal_get_cycles(); 2091 2196 #endif 2092 2197 … … 2112 2217 if( error ) 2113 2218 { 2114 printk("\n[ERROR] in %s : <%s> not found\n", 2115 __FUNCTION__, path ); 2219 2220 #if DEBUG_VFS_ERROR 2221 printk("\n[ERROR] in %s : thread[%x,%x] cannot found inode <%s> / cycle %d\n", 2222 __FUNCTION__, process->pid, this->trdid, path, cycle ); 2223 #endif 2116 2224 return -1; 2117 2225 } … … 2124 2232 if( inode_type != FILE_TYPE_DIR ) 2125 2233 { 2126 printk("\n[ERROR] in %s : <%s> is not a directory\n", 2127 __FUNCTION__, path ); 2234 2235 #if DEBUG_VFS_ERROR 2236 printk("\n[ERROR] in %s : thread[%x,%x] / <%s> is not a directory / cycle %d\n", 2237 __FUNCTION__, process->pid, this->trdid, path, cycle ); 2238 #endif 2128 2239 return -1; 2129 2240 } … … 2146 2257 2147 2258 #if DEBUG_VFS_CHDIR 2148 cycle = (uint32_t)hal_get_cycles();2149 2259 if( DEBUG_VFS_CHDIR < cycle ) 2150 printk("\n[%s] thread[%x,%x] exit : inode (%x,%x) / &cwd_xp (%x,%x) / cycle %d\n", 2151 __FUNCTION__, process->pid, this->trdid, inode_cxy, inode_ptr, 2152 GET_CXY(cwd_xp_xp), GET_PTR(cwd_xp_xp), cycle ); 2260 printk("\n[%s] thread[%x,%x] set new cwd <%s> / inode_xp (%x,%x) / cycle %d\n", 2261 __FUNCTION__, process->pid, this->trdid, path, inode_cxy, inode_ptr, cycle ); 2153 2262 #endif 2154 2263 … … 2163 2272 { 2164 2273 error_t error; 2165 xptr_t inode_xp; // extended pointer on target inode 2166 cxy_t inode_cxy; // inode cluster identifier 2167 vfs_inode_t * inode_ptr; // inode local pointer 2168 2169 // check lookup working mode 2170 assert( __FUNCTION__, (rights == 0), "access rights non implemented yet" ); 2171 2274 xptr_t vfs_root_xp; // extended pointer on VFS root inode 2275 vfs_inode_t * vfs_root_ptr; // local_pointer on VFS root inode 2276 cxy_t vfs_root_cxy; // VFS root inode cluster identifier 2277 xptr_t main_lock_xp; // extended pointer on lock protecting Inode Tree 2278 xptr_t inode_xp; // extended pointer on target inode 2279 cxy_t inode_cxy; // inode cluster identifier 2280 vfs_inode_t * inode_ptr; // inode local pointer 2281 vfs_file_type_t inode_type; // inode type 2282 2283 thread_t * this = CURRENT_THREAD; 2284 process_t * process = this->process; 2285 2286 #if DEBUG_VFS_CHMOD || DEBUG_VFS_ERROR 2287 uint32_t cycle = (uint32_t)hal_get_cycles(); 2288 #endif 2289 2290 // build extended pointer on lock protecting Inode Tree (in VFS root inode) 2291 vfs_root_xp = process->vfs_root_xp; 2292 vfs_root_ptr = GET_PTR( vfs_root_xp ); 2293 vfs_root_cxy = GET_CXY( vfs_root_xp ); 2294 main_lock_xp = XPTR( vfs_root_cxy , &vfs_root_ptr->main_lock ); 2295 2296 // take lock protecting Inode Tree in read mode 2297 remote_rwlock_rd_acquire( main_lock_xp ); 2298 2172 2299 // get extended pointer on target inode 2173 2300 error = vfs_lookup( cwd_xp, … … 2177 2304 NULL ); 2178 2305 2179 if( error ) return error; 2306 // release lock protecting Inode Tree in read mode 2307 remote_rwlock_rd_release( main_lock_xp ); 2308 2309 if( error ) 2310 { 2311 2312 #if DEBUG_VFS_ERROR 2313 printk("\n[ERROR] in %s : thread[%x,%x] cannot found inode <%s> / cycle %d\n", 2314 __FUNCTION__, process->pid, this->trdid, path, cycle ); 2315 #endif 2316 return -1; 2317 } 2180 2318 2181 2319 // get inode cluster and local pointer … … 2184 2322 2185 2323 // get inode type from remote inode 2186 //inode_type = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->type ) );2324 inode_type = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->type ) ); 2187 2325 2188 2326 // TODO finalize implementation 2189 2327 2190 assert( __FUNCTION__, false , "not implemented" );2328 assert( __FUNCTION__, false , "not fully implemented" ); 2191 2329 2192 2330 // set inode rights in remote inode 2193 2331 hal_remote_s32( XPTR( inode_cxy , &inode_ptr->rights ) , rights ); 2332 2333 #if DEBUG_VFS_CHMOD 2334 if( DEBUG_VFS_CHMOD < cycle ) 2335 printk("\n[%s] thread[%x,%x] set access rights %x for <%s> / inode_xp (%x,%x) / cycle %d\n", 2336 __FUNCTION__, process->pid, this->trdid, rights, path, inode_cxy, inode_ptr, cycle ); 2337 #endif 2194 2338 2195 2339 return 0; … … 2212 2356 thread_t * this = CURRENT_THREAD; 2213 2357 process_t * process = this->process; 2358 2359 #if DEBUG_VFS_MKFIFO || DEBUG_VFS_ERROR 2360 uint32_t cycle = (uint32_t)hal_get_cycles(); 2361 #endif 2214 2362 2215 2363 // build extended pointer on lock protecting Inode Tree … … 2230 2378 if( error ) 2231 2379 { 2232 printk("\n[ERROR] in %s : cannot get parent inode for <%s> path\n", 2233 __FUNCTION__ , path ); 2380 2381 #if DEBUG_VFS_ERROR 2382 printk("\n[ERROR] in %s : thread[%x,%x] cannot found parent inode for <%s> / cycle %d\n", 2383 __FUNCTION__, process->pid, this->trdid, path, cycle ); 2384 #endif 2385 remote_rwlock_wr_release( vfs_lock_xp ); 2234 2386 return -1; 2235 2387 } … … 2259 2411 if( error ) 2260 2412 { 2261 printk("\n[ERROR] in %s : cannot create fifo inode for <%s> path\n", 2262 __FUNCTION__ , path ); 2413 2414 #if DEBUG_VFS_ERROR 2415 printk("\n[ERROR] in %s : thread[%x,%x] cannot create fifo inode for <%s> / cycle %d\n", 2416 __FUNCTION__, process->pid, this->trdid, path, cycle ); 2417 #endif 2418 remote_rwlock_wr_release( vfs_lock_xp ); 2263 2419 return -1; 2264 2420 } … … 2270 2426 if( pipe == NULL ) 2271 2427 { 2272 printk("\n[ERROR] in %s : cannot create pipe for <%s> path\n", 2273 __FUNCTION__ , path ); 2428 2429 #if DEBUG_VFS_ERROR 2430 printk("\n[ERROR] in %s : thread[%x,%x] cannot create pipe for <%s> / cycle %d\n", 2431 __FUNCTION__, process->pid, this->trdid, path, cycle ); 2432 #endif 2433 vfs_remove_child_from_parent( fifo_dentry_xp ); 2434 remote_rwlock_wr_release( vfs_lock_xp ); 2274 2435 return -1; 2275 2436 } … … 2282 2443 // release the lock protecting the Inode-Tree from write mode 2283 2444 remote_rwlock_wr_release( vfs_lock_xp ); 2445 2446 #if DEBUG_VFS_MKDIR 2447 if( DEBUG_VFS_MKDIR < cycle ) 2448 printk("\n[%s] thread[%x,%x] creared fifo <%s> / inode_xp [%x,%x] / cycle %d\n", 2449 __FUNCTION__, process->pid, this->trdid, path, fifo_cxy, fifo_inode_ptr, cycle ); 2450 #endif 2284 2451 2285 2452 return 0; … … 2746 2913 2747 2914 #if DEBUG_VFS_ERROR 2748 if( DEBUG_VFS_ERROR < cycle ) 2749 printk("\n[ERROR] in %s : thread[%x,%x] cannot create inode <%s> in path <%s>\n", 2750 __FUNCTION__ , process->pid, this->trdid, name, pathname ); 2915 printk("\n[ERROR] in %s : thread[%x,%x] cannot create inode <%s> in path <%s> / cycle %d\n", 2916 __FUNCTION__ , process->pid, this->trdid, name, pathname, cycle ); 2751 2917 #endif 2752 2918 return -1; … … 2777 2943 2778 2944 #if DEBUG_VFS_ERROR 2779 if( DEBUG_VFS_ERROR < cycle ) 2780 printk("\n[ERROR] in %s : thread[%x,%x] cannot add dentry <%s> in parent dir\n", 2781 __FUNCTION__, process->pid, this->trdid, name ); 2945 printk("\n[ERROR] in %s : thread[%x,%x] cannot add dentry <%s> in parent dir / cycle %d\n", 2946 __FUNCTION__, process->pid, this->trdid, name, cycle ); 2782 2947 #endif 2783 2948 vfs_remove_child_from_parent( dentry_xp ); … … 2795 2960 2796 2961 #if DEBUG_VFS_ERROR 2797 if( DEBUG_VFS_ERROR < cycle ) 2798 printk("\n[ERROR] in %s : thread[%x,%x] cannot found node <%s> in parent for <%s>\n", 2799 __FUNCTION__ , process->pid, this->trdid, name, pathname ); 2962 printk("\n[ERROR] in %s : thread[%x,%x] cannot found node <%s> in parent for <%s> / cycle %d\n", 2963 __FUNCTION__ , process->pid, this->trdid, name, pathname, cycle ); 2800 2964 #endif 2801 2965 vfs_remove_child_from_parent( dentry_xp ); … … 2810 2974 2811 2975 #if DEBUG_VFS_ERROR 2812 if( DEBUG_VFS_ERROR < cycle ) 2813 printk("\n[ERROR] in %s : thread[%x,%x] found an existing node <%s> %\n", 2814 __FUNCTION__ , process->pid, this->trdid, pathname ); 2976 printk("\n[ERROR] in %s : thread[%x,%x] found an existing node <%s> / cycle %d\n", 2977 __FUNCTION__ , process->pid, this->trdid, pathname, cycle ); 2815 2978 #endif 2816 2979 return -1; … … 2831 2994 { 2832 2995 #if DEBUG_VFS_ERROR 2833 if( DEBUG_VFS_ERROR < cycle ) 2834 printk("\n[ERROR] in %s : thread[%x,%x] cannot load <%s> from device\n", 2835 __FUNCTION__ , process->pid, this->trdid, name ); 2996 printk("\n[ERROR] in %s : thread[%x,%x] cannot load <%s> from device / cycle %d\n", 2997 __FUNCTION__ , process->pid, this->trdid, name, cycle ); 2836 2998 #endif 2837 2999 vfs_remove_child_from_parent( dentry_xp ); … … 2864 3026 2865 3027 #if DEBUG_VFS_ERROR 2866 if( DEBUG_VFS_ERROR < cycle ) 2867 printk("\n[ERROR] in %s : thread[%x,%x] found an existing node <%s>\n", 2868 __FUNCTION__ , process->pid, this->trdid, pathname ); 3028 printk("\n[ERROR] in %s : thread[%x,%x] found an existing node <%s> / cycle %d\n", 3029 __FUNCTION__ , process->pid, this->trdid, pathname, cycle ); 2869 3030 #endif 2870 3031 return -1; … … 2946 3107 xptr_t children_entry_xp; // extended pointer on dentry "children" field 2947 3108 3109 #if DEBUG_VFS_ADD_SPECIAL || DEBUG_VFS_ERROR 3110 uint32_t cycle = (uint32_t)hal_get_cycles(); 3111 thread_t * this = CURRENT_THREAD; 3112 process_t * process = this->process; 3113 #endif 3114 2948 3115 #if DEBUG_VFS_ADD_SPECIAL 2949 uint32_t cycle = (uint32_t)hal_get_cycles();2950 thread_t * this = CURRENT_THREAD;2951 3116 char child_name[CONFIG_VFS_MAX_NAME_LENGTH]; 2952 3117 char parent_name[CONFIG_VFS_MAX_NAME_LENGTH]; … … 2955 3120 if( DEBUG_VFS_ADD_SPECIAL < cycle ) 2956 3121 printk("\n[%s] thread[%x,%x] enter for child <%s> in parent <%s> / cycle %d\n", 2957 __FUNCTION__, this->process->pid, this->trdid, child_name, parent_name, cycle );3122 __FUNCTION__, process->pid, this->trdid, child_name, parent_name, cycle ); 2958 3123 #endif 2959 3124 … … 2973 3138 if( error ) 2974 3139 { 2975 printk("\n[ERROR] in %s : cannot create dentry <.> in cluster %x\n", 2976 __FUNCTION__ , child_cxy ); 3140 3141 #if DEBUG_VFS_ERROR 3142 printk("\n[ERROR] in %s : thread[%x,%x] cannot create dentry <.> in cluster %x / cycle %d\n", 3143 __FUNCTION__ , process->pid, this->trdid, child_cxy, cycle ); 3144 #endif 2977 3145 return -1; 2978 3146 } … … 2982 3150 2983 3151 #if(DEBUG_VFS_ADD_SPECIAL & 1) 2984 cycle = (uint32_t)hal_get_cycles();2985 3152 if( DEBUG_VFS_ADD_SPECIAL < cycle ) 2986 3153 printk("\n[%s] thread[%x,%x] created dentry <.> (%x,%x) / cycle %d\n", 2987 __FUNCTION__, this->process->pid, this->trdid, child_cxy, dentry_ptr, cycle );3154 __FUNCTION__, process->pid, this->trdid, child_cxy, dentry_ptr, cycle ); 2988 3155 #endif 2989 3156 … … 2996 3163 if( error ) 2997 3164 { 2998 printk("\n[ERROR] in %s : cannot register dentry <.> in xhtab\n", 2999 __FUNCTION__ ); 3165 3166 #if DEBUG_VFS_ERROR 3167 printk("\n[ERROR] in %s : thread[%x,%x] cannot register dentry <.> in xhtab / cycle %d\n", 3168 __FUNCTION__ , process->pid, this->trdid, cycle ); 3169 #endif 3000 3170 return -1; 3001 3171 } … … 3009 3179 if( DEBUG_VFS_ADD_SPECIAL < cycle ) 3010 3180 printk("\n[%s] thread[%x,%x] linked dentry <.> to parent and child inodes / cycle %d\n", 3011 __FUNCTION__, this->process->pid, this->trdid, cycle );3181 __FUNCTION__, process->pid, this->trdid, cycle ); 3012 3182 #endif 3013 3183 … … 3020 3190 if( error ) 3021 3191 { 3022 printk("\n[ERROR] in %s : cannot introduce dentry <..> in mapper %x\n", 3023 __FUNCTION__ ); 3192 3193 #if DEBUG_VFS_ERROR 3194 printk("\n[ERROR] in %s : thread[%x,%x] cannot register dentry <.> in mapper / cycle %d\n", 3195 __FUNCTION__ , process->pid, this->trdid, cycle ); 3196 #endif 3024 3197 return -1; 3025 3198 } … … 3029 3202 if( DEBUG_VFS_ADD_SPECIAL < cycle ) 3030 3203 printk("\n[%s] thread[%x,%x] registered dentry <.> in child mapper / cycle %d\n", 3031 __FUNCTION__, this->process->pid, this->trdid, cycle );3204 __FUNCTION__, process->pid, this->trdid, cycle ); 3032 3205 #endif 3033 3206 … … 3041 3214 if( error ) 3042 3215 { 3043 printk("\n[ERROR] in %s : cannot create dentry <..> in cluster %x\n", 3044 __FUNCTION__ , child_cxy ); 3216 3217 #if DEBUG_VFS_ERROR 3218 printk("\n[ERROR] in %s : thread[%x,%x] cannot create dentry <..> in cluster %x / cycle %d\n", 3219 __FUNCTION__ , process->pid, this->trdid, child_cxy, cycle ); 3220 #endif 3045 3221 return -1; 3046 3222 } … … 3053 3229 if( DEBUG_VFS_ADD_SPECIAL < cycle ) 3054 3230 printk("\n[%s] thread[%x,%x] created dentry <..> (%x,%x) / cycle %d\n", 3055 __FUNCTION__, this->process->pid, this->trdid, child_cxy, dentry_ptr, cycle );3231 __FUNCTION__, process->pid, this->trdid, child_cxy, dentry_ptr, cycle ); 3056 3232 #endif 3057 3233 … … 3059 3235 children_xhtab_xp = XPTR( child_cxy , &child_ptr->children ); 3060 3236 children_entry_xp = XPTR( child_cxy , &dentry_ptr->children ); 3237 3061 3238 error = xhtab_insert( children_xhtab_xp , ".." , children_entry_xp ); 3239 3062 3240 if( error ) 3063 3241 { 3064 printk("\n[ERROR] in %s : cannot register dentry <..> in xhtab\n", 3065 __FUNCTION__ ); 3242 3243 #if DEBUG_VFS_ERROR 3244 printk("\n[ERROR] in %s : thread[%x,%x] cannot register dentry <..> in xhtab / cycle %d\n", 3245 __FUNCTION__ , process->pid, this->trdid, cycle ); 3246 #endif 3066 3247 return -1; 3067 3248 } … … 3077 3258 if( DEBUG_VFS_ADD_SPECIAL < cycle ) 3078 3259 printk("\n[%s] thread[%x,%x] linked dentry <..> to parent and child inodes / cycle %d\n", 3079 __FUNCTION__, this->process->pid, this->trdid, cycle );3260 __FUNCTION__, process->pid, this->trdid, cycle ); 3080 3261 #endif 3081 3262 … … 3088 3269 if( error ) 3089 3270 { 3090 printk("\n[ERROR] in %s : cannot introduce dentry <..> in mapper %x\n", 3091 __FUNCTION__ ); 3271 3272 #if DEBUG_VFS_ERROR 3273 printk("\n[ERROR] in %s : thread[%x,%x] cannot register dentry <..> in mapper / cycle %d\n", 3274 __FUNCTION__ , process->pid, this->trdid, cycle ); 3275 #endif 3092 3276 return -1; 3093 3277 } … … 3097 3281 if( DEBUG_VFS_ADD_SPECIAL < cycle ) 3098 3282 printk("\n[%s] thread[%x,%x] registered dentry <..> in child mapper / cycle %d\n", 3099 __FUNCTION__, this->process->pid, this->trdid, cycle );3283 __FUNCTION__, process->pid, this->trdid, cycle ); 3100 3284 #endif 3101 3285 … … 3106 3290 if( DEBUG_VFS_ADD_SPECIAL < cycle ) 3107 3291 printk("\n[%s] thread[%x,%x] exit for child <%s> in parent <%s> / cycle %d\n", 3108 __FUNCTION__, this->process->pid, this->trdid, child_name, parent_name, cycle );3292 __FUNCTION__, process->pid, this->trdid, child_name, parent_name, cycle ); 3109 3293 #endif 3110 3294 … … 3139 3323 3140 3324 #if DEBUG_VFS_GET_PATH 3141 uint32_t cycle = (uint32_t)hal_get_cycles(); 3325 uint32_t cycle = (uint32_t)hal_get_cycles(); 3326 #endif 3327 3328 #if DEBUG_VFS_GET_PATH 3142 3329 if( DEBUG_VFS_GET_PATH < cycle ) 3143 3330 printk("\n[%s] thread[%x,%x] enter : inode (%x,%x) / cycle %d\n", … … 3296 3483 3297 3484 #if DEBUG_VFS_ERROR 3298 if( DEBUG_VFS_ERROR < cycle ) 3299 printk("\n[ERROR] in %s : thread[%x,%x] cannot create dentry <%s> in cluster %x\n", 3300 __FUNCTION__ , this->process->pid, this->trdid , name , parent_cxy ); 3485 printk("\n[ERROR] in %s : thread[%x,%x] cannot create dentry <%s> in cluster %x / cycle %d\n", 3486 __FUNCTION__ , this->process->pid, this->trdid , name , parent_cxy, cycle ); 3301 3487 #endif 3302 3488 return -1; … … 3330 3516 3331 3517 #if DEBUG_VFS_ERROR 3332 if( DEBUG_VFS_ERROR < cycle ) 3333 printk("\n[ERROR] in %s : thread[%x,%x] cannot create inode in cluster %x\n", 3334 __FUNCTION__ , this->process->pid , this->trdid , child_cxy ); 3518 printk("\n[ERROR] in %s : thread[%x,%x] cannot create inode in cluster %x / cycle %d\n", 3519 __FUNCTION__ , this->process->pid , this->trdid , child_cxy, cycle ); 3335 3520 #endif 3336 3521 … … 3428 3613 3429 3614 #if DEBUG_VFS_REMOVE_CHILD 3430 if( DEBUG_VFS_REMOVE_CHILD < cycle )3431 3615 printk("\n[%s] thread[%x,%x] enter for dentry[%x,%x] / inode[%x,%x] / cycle %d\n", 3432 3616 __FUNCTION__, this->process->pid, this->trdid, … … 3441 3625 if( error ) 3442 3626 { 3443 printk("\n[WARNING] in %s] thread[%x,%x] cannot remove dentry %s from parent dir\n", 3444 __FUNCTION__, this->process->pid, this->trdid, dentry_name ); 3445 } 3446 3447 #if DEBUG_VFS_REMOVE_CHILD 3448 cycle = (uint32_t)hal_get_cycles(); 3627 printk("\n[WARNING] in %s : thread[%x,%x] cannot remove dentry <%s> from parent\n", 3628 __FUNCTION__ , this->process->pid , this->trdid , dentry_name ); 3629 } 3630 3631 #if(DEBUG_VFS_REMOVE_CHILD & 1) 3449 3632 if( DEBUG_VFS_REMOVE_CHILD < cycle ) 3450 printk("\n[%s] thread[%x,%x] removed dentry from parent inode / cycle %d\n",3451 __FUNCTION__, this->process->pid, this->trdid , cycle);3633 printk("\n[%s] thread[%x,%x] removed dentry from parent inode\n", 3634 __FUNCTION__, this->process->pid, this->trdid ); 3452 3635 #endif 3453 3636 … … 3458 3641 links = hal_remote_atomic_add( XPTR( child_cxy , &child_inode_ptr->links ) , -1 ); 3459 3642 3460 #if DEBUG_VFS_REMOVE_CHILD 3461 cycle = (uint32_t)hal_get_cycles(); 3643 #if(DEBUG_VFS_REMOVE_CHILD & 1) 3462 3644 if( DEBUG_VFS_REMOVE_CHILD < cycle ) 3463 printk("\n[%s] thread[%x,%x] removed dentry from child inode / cycle %d\n",3464 __FUNCTION__, this->process->pid, this->trdid , cycle);3645 printk("\n[%s] thread[%x,%x] removed dentry from child inode\n", 3646 __FUNCTION__, this->process->pid, this->trdid ); 3465 3647 #endif 3466 3648 … … 3723 3905 assert( __FUNCTION__, (array != NULL) , "child pointer is NULL"); 3724 3906 assert( __FUNCTION__, (detailed == false) , "detailed argument not supported\n"); 3725 3726 // check inode type 3727 if( inode->type != FILE_TYPE_DIR ) 3728 { 3729 printk("\n[ERROR] in %s : target inode is not a directory\n", 3730 __FUNCTION__ ); 3731 return -1; 3732 } 3907 assert( __FUNCTION__, (inode->type == FILE_TYPE_DIR), "inode is not a directory\n"); 3733 3908 3734 3909 // get parent inode FS type -
trunk/kernel/fs/vfs.h
r673 r683 168 168 *****************************************************************************************/ 169 169 170 /* this enum define the VFS inode types values*/170 /* this enum define the VFS file types */ 171 171 /* WARNING : this enum must be kept consistent with macros in <shared_stat.h> file */ 172 172 /* and with types in <shared_dirent.h> file. */ … … 174 174 typedef enum 175 175 { 176 FILE_TYPE_REG = 0, /*! regular file */177 FILE_TYPE_DIR = 1, /*! directory */178 FILE_TYPE_FIFO = 2, /*! POSIX named fifo */179 FILE_TYPE_PIPE = 3, /*! POSIX anonymous pipe */180 FILE_TYPE_SOCK = 4, /*! POSIX anonymous socket */181 FILE_TYPE_DEV = 5, /*! character device */182 FILE_TYPE_BLK = 6, /*! block device */183 FILE_TYPE_SYML = 7, /*! symbolic link */176 FILE_TYPE_REG = 0, /*! regular file */ 177 FILE_TYPE_DIR = 1, /*! directory */ 178 FILE_TYPE_FIFO = 2, /*! POSIX named fifo */ 179 FILE_TYPE_PIPE = 3, /*! POSIX anonymous pipe */ 180 FILE_TYPE_SOCK = 4, /*! POSIX anonymous socket */ 181 FILE_TYPE_DEV = 5, /*! character device */ 182 FILE_TYPE_BLK = 6, /*! block device */ 183 FILE_TYPE_SYML = 7, /*! symbolic link */ 184 184 } 185 185 vfs_file_type_t; … … 200 200 struct vfs_ctx_s * ctx; /*! local pointer on FS context. */ 201 201 vfs_file_attr_t attr; /*! file attributes bit vector (see above) */ 202 vfs_file_type_t type; /*! same type as inode */202 vfs_file_type_t type; /*! same type as inode */ 203 203 uint32_t offset; /*! seek position in file */ 204 204 remote_rwlock_t lock; /*! protect offset modifications */ … … 285 285 uint32_t inum; /*! inode identifier (unique in file system) */ 286 286 uint32_t attr; /*! inode attributes (see above) */ 287 vfs_file_type_t type; /*! inode type (see above)*/287 vfs_file_type_t type; /*! inode type (see vfs_file_t) */ 288 288 uint32_t size; /*! number of bytes */ 289 289 uint32_t uid; /*! user owner identifier */ … … 829 829 /****************************************************************************************** 830 830 * This function returns, in the structure pointed by the <st> pointer, various 831 * informations on the inodeidentified by the <root_inode_xp> and <patname> arguments.831 * informations on the file identified by the <root_inode_xp> and <patname> arguments. 832 832 * 833 833 * TODO : only partially implemented yet (only size and inum fields).
Note: See TracChangeset
for help on using the changeset viewer.