Changeset 598 for trunk/kernel
- Timestamp:
- Nov 10, 2018, 3:06:00 PM (6 years ago)
- Location:
- trunk/kernel/fs
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/fs/devfs.c
r568 r598 104 104 105 105 #if DEBUG_DEVFS_INIT 106 uint32_t cycle = (uint32_t)hal_get_cycles(); 107 if( DEBUG_DEVFS_INIT < cycle ) 108 printk("\n[DBG] %s : thread %x in process %x created <dev> inode / cycle %d\n", 109 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid ,cycle ); 106 uint32_t cycle = (uint32_t)hal_get_cycles(); 107 thread_t * this = CURRENT_THREAD; 108 if( DEBUG_DEVFS_INIT < cycle ) 109 printk("\n[%s] thread[%x,%x] created <dev> inode / cycle %d\n", 110 __FUNCTION__, this->process->pid, this->trdid, cycle ); 110 111 #endif 111 112 … … 124 125 cycle = (uint32_t)hal_get_cycles(); 125 126 if( DEBUG_DEVFS_INIT < cycle ) 126 printk("\n[ DBG] %s : thread %x in process %xcreated <external> inode / cycle %d\n",127 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, cycle );127 printk("\n[%s] thread[%x,%x] created <external> inode / cycle %d\n", 128 __FUNCTION__, this->process->pid, this->trdid, cycle ); 128 129 #endif 129 130 … … 152 153 devfs_internal_inode_xp ); 153 154 #if DEBUG_DEVFS_INIT 154 uint32_t cycle = (uint32_t)hal_get_cycles(); 155 trdid_t trdid = CURRENT_THREAD->trdid; 156 pid_t pid = CURRENT_THREAD->process->pid; 157 if( DEBUG_DEVFS_INIT < cycle ) 158 printk("\n[DBG] %s : thread %x in process %x created <%s> in cluster %x / cycle %d\n", 159 __FUNCTION__, trdid, pid, node_name, local_cxy, cycle ); 155 uint32_t cycle = (uint32_t)hal_get_cycles(); 156 thread_t * this = CURRENT_THREAD; 157 if( DEBUG_DEVFS_INIT < cycle ) 158 printk("\n[%s] thread[%x,%x] created <%s> inode in cluster %x / cycle %d\n", 159 __FUNCTION__, this->process->pid, this->trdid, node_name, local_cxy, cycle ); 160 160 #endif 161 161 … … 175 175 cycle = (uint32_t)hal_get_cycles(); 176 176 if( DEBUG_DEVFS_INIT < cycle ) 177 printk("\n[ DBG] %s : thread %x in process %xcreated <mmc> inode in cluster %x\n",178 __FUNCTION__, t rdid, pid, local_cxy, cycle );177 printk("\n[%s] thread[%x,%x] created <mmc> inode in cluster %x\n", 178 __FUNCTION__, this->process->pid, this->trdid, local_cxy, cycle ); 179 179 #endif 180 180 … … 198 198 cycle = (uint32_t)hal_get_cycles(); 199 199 if( DEBUG_DEVFS_INIT < cycle ) 200 printk("\n[ DBG] %s : thread %x in process %xcreated <dma[%d]> inode in cluster %x\n",201 __FUNCTION__, t rdid, pid, channel, local_cxy, cycle );200 printk("\n[%s] thread [%x,%x] created <dma[%d]> inode in cluster %x\n", 201 __FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle ); 202 202 #endif 203 203 } … … 222 222 cycle = (uint32_t)hal_get_cycles(); 223 223 if( DEBUG_DEVFS_INIT < cycle ) 224 printk("\n[ DBG] %s : thread %x in process %xcreated <iob> inode in cluster %x\n",225 __FUNCTION__, t rdid, pid, local_cxy, cycle );224 printk("\n[%s] thread[%x,%x] created <iob> inode in cluster %x\n", 225 __FUNCTION__, this->process->pid, this->trdid, local_cxy, cycle ); 226 226 #endif 227 227 } … … 246 246 cycle = (uint32_t)hal_get_cycles(); 247 247 if( DEBUG_DEVFS_INIT < cycle ) 248 printk("\n[ DBG] %s : thread %x in process %xcreated <pic> inode in cluster %x\n",249 __FUNCTION__, t rdid, pid, local_cxy, cycle );248 printk("\n[%s] thread[%x,%x] created <pic> inode in cluster %x\n", 249 __FUNCTION__, this->process->pid, this->trdid, local_cxy, cycle ); 250 250 #endif 251 251 } … … 272 272 cycle = (uint32_t)hal_get_cycles(); 273 273 if( DEBUG_DEVFS_INIT < cycle ) 274 printk("\n[ DBG] %s : thread %x in process %xcreated <txt_rx[%d]> inode in cluster %x\n",275 __FUNCTION__, t rdid, pid, channel, local_cxy, cycle );274 printk("\n[%s] thread[%x,%x] created <txt_rx[%d]> inode in cluster %x\n", 275 __FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle ); 276 276 #endif 277 277 } … … 299 299 cycle = (uint32_t)hal_get_cycles(); 300 300 if( DEBUG_DEVFS_INIT < cycle ) 301 printk("\n[ DBG] %s : thread %x in process %xcreated <txt_tx[%d]> inode in cluster %x\n",302 __FUNCTION__, t rdid, pid, channel, local_cxy, cycle );301 printk("\n[%s] thread[%x,%x] created <txt_tx[%d]> inode in cluster %x\n", 302 __FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle ); 303 303 #endif 304 304 } … … 326 326 cycle = (uint32_t)hal_get_cycles(); 327 327 if( DEBUG_DEVFS_INIT < cycle ) 328 printk("\n[ DBG] %s : thread %x in process %xcreated <ioc[%d]> inode in cluster %x\n",329 __FUNCTION__, t rdid, pid, channel, local_cxy, cycle );328 printk("\n[%s] thread[%x,%x] created <ioc[%d]> inode in cluster %x\n", 329 __FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle ); 330 330 #endif 331 331 } … … 353 353 cycle = (uint32_t)hal_get_cycles(); 354 354 if( DEBUG_DEVFS_INIT < cycle ) 355 printk("\n[ DBG] %s : thread %x in process %xcreated <fbf[%d]> inode in cluster %x\n",356 __FUNCTION__, t rdid, pid, channel, local_cxy, cycle );355 printk("\n[%s] thread[%x,%x] created <fbf[%d]> inode in cluster %x\n", 356 __FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle ); 357 357 #endif 358 358 } … … 380 380 cycle = (uint32_t)hal_get_cycles(); 381 381 if( DEBUG_DEVFS_INIT < cycle ) 382 printk("\n[ DBG] %s : thread %x in process %xcreated <nic_rx[%d]> inode in cluster %x\n",383 __FUNCTION__, t rdid, pid, channel, local_cxy, cycle );382 printk("\n[%s] thread[%x,%x] created <nic_rx[%d]> inode in cluster %x\n", 383 __FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle ); 384 384 #endif 385 385 } … … 407 407 cycle = (uint32_t)hal_get_cycles(); 408 408 if( DEBUG_DEVFS_INIT < cycle ) 409 printk("\n[ DBG] %s : thread %x in process %xcreated <nic_tx[%d]> inode in cluster %x\n",410 __FUNCTION__, t rdid, pid, channel, local_cxy, cycle );409 printk("\n[%s] thread[%x,%x] created <nic_tx[%d]> inode in cluster %x\n", 410 __FUNCTION__, this->process->pid, this->trdid, channel, local_cxy, cycle ); 411 411 #endif 412 412 } … … 418 418 int devfs_user_move( bool_t to_buffer, 419 419 xptr_t file_xp, 420 void* u_buf,420 char * u_buf, 421 421 uint32_t size ) 422 422 { 423 assert( ( file_xp != XPTR_NULL ) , "file_xp == XPTR_NULL" ); 424 425 assert( ( size < CONFIG_TXT_KBUF_SIZE ) , "string size too large" ); 426 427 xptr_t chdev_xp; 428 cxy_t chdev_cxy; 429 chdev_t * chdev_ptr; // associated chdev type 430 uint32_t func; // chdev functionnal type 431 uint32_t channel; // chdev channel index 432 error_t error; 433 434 char k_buf[CONFIG_TXT_KBUF_SIZE]; // local kernel buffer 423 xptr_t chdev_xp; 424 cxy_t chdev_cxy; 425 chdev_t * chdev_ptr; // associated chdev type 426 uint32_t func; // chdev functionnal type 427 uint32_t channel; // chdev channel index 428 uint32_t burst; // number of bytes in a burst 429 uint32_t todo; // number of bytes not yet moved 430 error_t error; 431 uint32_t i; 432 433 char k_buf[CONFIG_TXT_KBUF_SIZE]; // local kernel buffer 434 435 assert( ( file_xp != XPTR_NULL ) , "file_xp == XPTR_NULL" ); 435 436 436 437 #if (DEBUG_SYS_READ & 1) … … 443 444 444 445 #if DEBUG_DEVFS_MOVE 445 uint32_t cycle = (uint32_t)hal_get_cycles(); 446 uint32_t cycle = (uint32_t)hal_get_cycles(); 447 thread_t * this = CURRENT_THREAD; 446 448 if( DEBUG_DEVFS_MOVE < cycle ) 447 printk("\n[ DBG] %s : thread %xenter / to_mem %d / cycle %d\n",448 __FUNCTION__ , CURRENT_THREAD , to_buffer, cycle );449 printk("\n[%s] thread[%x,%x] enter / to_mem %d / cycle %d\n", 450 __FUNCTION__, this->process->pid, this->trdid, to_buffer, cycle ); 449 451 #endif 450 452 … … 460 462 channel = hal_remote_l32( XPTR( chdev_cxy , &chdev_ptr->channel ) ); 461 463 462 // action depends on "func" and "to_buffer" 463 if( func == DEV_FUNC_TXT ) 464 { 465 if( to_buffer ) // TXT read 466 { 467 uint32_t i; 468 for( i = 0 ; i < size ; i++ ) 464 assert( ( func == DEV_FUNC_TXT ) , __FUNCTION__, "illegal device func_type"); 465 466 // initialise number of bytes to move 467 todo = size; 468 469 /////////////// TXT read 470 if( to_buffer ) 471 { 472 while( todo ) 473 { 474 // set burst size 475 if( todo > CONFIG_TXT_KBUF_SIZE ) burst = CONFIG_TXT_KBUF_SIZE; 476 else burst = todo; 477 478 // read burst bytes from TXT device to kernel buffer 479 for( i = 0 ; i < burst ; i++ ) 469 480 { 470 481 error = dev_txt_read( channel , &k_buf[i] ); 471 482 472 if( error ) 473 { 474 return -1; 475 } 476 else 477 { 478 hal_strcpy_to_uspace( u_buf , k_buf , size ); 479 } 480 } 483 if( error ) return -1; 484 } 485 486 // move burst bytes from k_buf to u_buf 487 hal_strcpy_to_uspace( u_buf , k_buf , burst ); 488 489 // update loop variables 490 todo -= burst; 491 u_buf += burst; 492 } 481 493 482 494 #if DEBUG_DEVFS_MOVE 483 495 cycle = (uint32_t)hal_get_cycles(); 484 496 if( DEBUG_DEVFS_MOVE < cycle ) 485 printk("\n[ DBG] %s : thread %xexit / to_mem %d / cycle %d\n",486 __FUNCTION__ , CURRENT_THREAD , to_buffer /cycle );497 printk("\n[%s] thread[%x,%x] exit / to_mem %d / cycle %d\n", 498 __FUNCTION__, this->process->pid, this->trdid, to_buffer, cycle ); 487 499 #endif 488 500 … … 491 503 #endif 492 504 return size; 505 } 506 ///////////// TXT write 507 else 508 { 509 while( todo ) 510 { 511 // set burst size 512 if( todo > CONFIG_TXT_KBUF_SIZE ) burst = CONFIG_TXT_KBUF_SIZE; 513 else burst = todo; 514 515 // move burst bytes from u_buf to k_buf 516 hal_strcpy_from_uspace( k_buf , u_buf , burst ); 517 518 // write burst bytes from kernel buffer to TXT device 519 error = dev_txt_write( channel , k_buf , burst ); 520 521 if( error ) return -1; 522 523 // update loop variables 524 todo -= burst; 525 u_buf += burst; 493 526 } 494 else // TXT write495 {496 hal_strcpy_from_uspace( k_buf , u_buf , size );497 498 error = dev_txt_write( channel , k_buf , size );499 if( error )500 {501 return -1;502 }503 else504 {505 527 506 528 #if DEBUG_DEVFS_MOVE 507 529 cycle = (uint32_t)hal_get_cycles(); 508 530 if( DEBUG_DEVFS_MOVE < cycle ) 509 printk("\n[ DBG] %s : thread %xexit / to_mem %d / cycle %d\n",510 __FUNCTION__ , CURRENT_THREAD , to_buffer /cycle );531 printk("\n[%s] thread[%x,%x] exit / to_mem %d / cycle %d\n", 532 __FUNCTION__, this->process->pid, this->trdid, to_buffer, cycle ); 511 533 #endif 512 534 … … 514 536 exit_devfs_write = hal_time_stamp(); 515 537 #endif 516 return size; 517 } 518 } 519 } 520 else 521 { 522 assert( false , "%s does not support direct user access", 523 chdev_func_str(func) ); 524 525 return -1; 538 return size; 526 539 } 527 540 -
trunk/kernel/fs/devfs.h
r568 r598 119 119 120 120 /****************************************************************************************** 121 * This function moves <size> bytes between a device, and a - possibly distributed - 122 * user space <buffer>. It uses the <file_xp> and <to_buffer> arguments, to call the 123 * relevant device access function. 124 * It is called by the sys_read() and sys_write() functions. 125 * The <size> argument cannot be larger than the CONFIG_TXT_KBUF_SIZE configuration 126 * parameter, as this function makes a copy between the user space buffer, and a local 127 * kernel buffer allocated in the kernel stack. 121 * This function is called by the sys_read() and sys_write() functions. 122 * It moves <size> bytes between a TXT device, and an user space <u_buf> buffer. 123 * It uses the <file_xp> and <to_buffer> arguments, to call the relevant device function. 124 * It uses a kernel buffer allocated in the calling thread kernel stack. 125 * If the <size> argument is larger than CONFIG_TXT_KBUF_SIZE, the user buffer is split 126 * in smaller chunks to be copied from the user buffer to this kernel buffer. 128 127 ****************************************************************************************** 129 128 * @ to_buffer : device -> buffer if true / buffer -> device if false. … … 135 134 int devfs_user_move( bool_t to_buffer, 136 135 xptr_t file_xp, 137 void* u_buf,136 char * u_buf, 138 137 uint32_t size ); 139 138 -
trunk/kernel/fs/vfs.c
r568 r598 126 126 ////////////////////////////////////////////////////////////////////////////////////////// 127 127 128 static const char * vfs_inode_type_str( vfs_inode_type_t type ) 129 { 130 switch ( type ) { 131 case INODE_TYPE_FILE: return "FILE"; 132 case INODE_TYPE_DIR: return "DIR "; 133 case INODE_TYPE_FIFO: return "FIFO"; 134 case INODE_TYPE_PIPE: return "PIPE"; 135 case INODE_TYPE_SOCK: return "SOCK"; 136 case INODE_TYPE_DEV: return "DEV "; 137 case INODE_TYPE_SYML: return "SYML"; 138 default: return "undefined"; 128 const char * vfs_inode_type_str( vfs_inode_type_t type ) 129 { 130 switch ( type ) 131 { 132 case INODE_TYPE_FILE: return "FILE"; 133 case INODE_TYPE_DIR: return "DIR "; 134 case INODE_TYPE_FIFO: return "FIFO"; 135 case INODE_TYPE_PIPE: return "PIPE"; 136 case INODE_TYPE_SOCK: return "SOCK"; 137 case INODE_TYPE_DEV: return "DEV "; 138 case INODE_TYPE_SYML: return "SYML"; 139 default: return "undefined"; 139 140 } 140 141 } … … 168 169 else strcpy( name , "/" ); 169 170 if( DEBUG_VFS_INODE_CREATE < cycle ) 170 printk("\n[ DBG] %s : thread %x in process %xenter for <%s> / cycle %d\n",171 __FUNCTION__, this-> trdid, this->process->pid, name, cycle );171 printk("\n[%s] thread[%x,%x] enter for <%s> / cycle %d\n", 172 __FUNCTION__, this->process->pid, this->trdid, name, cycle ); 172 173 #endif 173 174 … … 247 248 cycle = (uint32_t)hal_get_cycles(); 248 249 if( DEBUG_VFS_INODE_CREATE < cycle ) 249 printk("\n[ DBG] %s : thread %x in process %xexit for <%s> / inode [%x,%x] / cycle %d\n",250 __FUNCTION__, this-> trdid, this->process->pid, name, local_cxy, inode, cycle );250 printk("\n[%s] thread[%x,%x] exit for <%s> / inode [%x,%x] / cycle %d\n", 251 __FUNCTION__, this->process->pid, this->trdid, name, local_cxy, inode, cycle ); 251 252 #endif 252 253 … … 284 285 uint32_t cycle = (uint32_t)hal_get_cycles(); 285 286 if( DEBUG_VFS_INODE_LOAD < cycle ) 286 printk("\n[ DBG] %s :thread %x enter for <%s> / cycle %d\n",287 printk("\n[%s] thread %x enter for <%s> / cycle %d\n", 287 288 __FUNCTION__, CURRENT_THREAD , name , cycle ); 288 289 #endif … … 318 319 cycle = (uint32_t)hal_get_cycles(); 319 320 if( DEBUG_VFS_INODE_LOAD < cycle ) 320 printk("\n[ DBG] %s :thread %x exit for <%s> / cycle %d\n",321 printk("\n[%s] thread %x exit for <%s> / cycle %d\n", 321 322 __FUNCTION__, CURRENT_THREAD , name , cycle ); 322 323 #endif … … 444 445 445 446 #if DEBUG_VFS_DENTRY_CREATE 447 thread_t * this = CURRENT_THREAD; 446 448 uint32_t cycle = (uint32_t)hal_get_cycles(); 447 449 if( DEBUG_VFS_DENTRY_CREATE < cycle ) 448 printk("\n[ DBG] %s : thread %x in process %xenter for <%s> / parent_inode %x / cycle %d\n",449 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, name, parent, cycle );450 printk("\n[%s] thread[%x,%x] enter for <%s> / parent_inode %x / cycle %d\n", 451 __FUNCTION__, this->process->pid, this->trdid, name, parent, cycle ); 450 452 #endif 451 453 … … 483 485 cycle = (uint32_t)hal_get_cycles(); 484 486 if( DEBUG_VFS_DENTRY_CREATE < cycle ) 485 printk("\n[ DBG] %s : thread %x in process %x/ dentry <%s> initialised / cycle %d\n",486 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, dentry->name, cycle );487 printk("\n[%s] thread[%x,%x] / dentry <%s> initialised / cycle %d\n", 488 __FUNCTION__, this->process->pid, this->trdid, dentry->name, cycle ); 487 489 #endif 488 490 … … 497 499 cycle = (uint32_t)hal_get_cycles(); 498 500 if( DEBUG_VFS_DENTRY_CREATE < cycle ) 499 printk("\n[ DBG] %s : thread %x in process %x/ dentry <%s> registered / cycle %d\n",500 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, dentry->name, cycle );501 printk("\n[%s] thread[%x,%x] / dentry <%s> registered / cycle %d\n", 502 __FUNCTION__, this->process->pid, this->trdid, dentry->name, cycle ); 501 503 #endif 502 504 … … 507 509 cycle = (uint32_t)hal_get_cycles(); 508 510 if( DEBUG_VFS_DENTRY_CREATE < cycle ) 509 printk("\n[ DBG] %s : thread %x in process %xexit for <%s> / dentry %x / cycle %d\n",510 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, name, dentry, cycle );511 printk("\n[%s] thread[%x,%x] exit for <%s> / dentry %x / cycle %d\n", 512 __FUNCTION__, this->process->pid, this->trdid, name, dentry, cycle ); 511 513 #endif 512 514 … … 556 558 557 559 #if DEBUG_VFS_FILE_CREATE 560 thread_t * this = CURRENT_THREAD; 558 561 uint32_t cycle = (uint32_t)hal_get_cycles(); 559 562 if( DEBUG_VFS_OPEN < cycle ) 560 printk("\n[ DBG] %s : thread %x in process %xenter for inode %x in cluster %x / cycle %d\n",561 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, inode, local_cxy, cycle );563 printk("\n[%s] thread[%x,%x] enter for inode %x in cluster %x / cycle %d\n", 564 __FUNCTION__, this->process->pid, this->trdid, inode, local_cxy, cycle ); 562 565 #endif 563 566 … … 587 590 cycle = (uint32_t)hal_get_cycles(); 588 591 if( DEBUG_VFS_OPEN < cycle ) 589 printk("\n[ DBG] %s : thread %x in process %xcreated file %x in cluster %x / cycle %d\n",590 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, file, local_cxy, cycle );592 printk("\n[%s] thread[%x,%x] created file %x in cluster %x / cycle %d\n", 593 __FUNCTION__, this->process->pid, this->trdid, file, local_cxy, cycle ); 591 594 #endif 592 595 … … 609 612 610 613 #if DEBUG_VFS_CLOSE 614 thread_t * this = CURRENT_THREAD; 611 615 uint32_t cycle = (uint32_t)hal_get_cycles(); 612 616 if( DEBUG_VFS_CLOSE < cycle ) 613 printk("\n[ DBG] %s : thread %x in process %xdeleted file %x in cluster %x / cycle %d\n",614 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, file, local_cxy, cycle );617 printk("\n[%s] thread[%x,%x] deleted file %x in cluster %x / cycle %d\n", 618 __FUNCTION__, this->process->pid, this->trdid, file, local_cxy, cycle ); 615 619 #endif 616 620 … … 665 669 666 670 #if DEBUG_VFS_OPEN 671 thread_t * this = CURRENT_THREAD; 667 672 uint32_t cycle = (uint32_t)hal_get_cycles(); 668 673 if( DEBUG_VFS_OPEN < cycle ) 669 printk("\n[ DBG] %s : thread %x in process %xenter for <%s> / cycle %d\n",670 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, path, cycle );674 printk("\n[%s] thread[%x,%x] enter for <%s> / cycle %d\n", 675 __FUNCTION__, this->process->pid, this->trdid, path, cycle ); 671 676 #endif 672 677 … … 714 719 cycle = (uint32_t)hal_get_cycles(); 715 720 if( DEBUG_VFS_OPEN < cycle ) 716 printk("\n[DBG] %s : thread %x in process %x exit for <%s> / fdid %d / cluster %x / cycle %d\n", 717 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, path, 718 file_id, GET_CXY( file_xp ), cycle ); 721 printk("\n[%s] thread[%x,%x] exit for <%s> / fdid %d / cluster %x / cycle %d\n", 722 __FUNCTION__, this->process->pid, this->trdid, path, file_id, GET_CXY( file_xp ), cycle ); 719 723 #endif 720 724 … … 928 932 uint32_t cycle = (uint32_t)hal_get_cycles(); 929 933 if( DEBUG_VFS_CLOSE < cycle ) 930 printk("\n[ DBG] %s : thread %x in process %xenter / fdid %d / cycle %d\n",931 __FUNCTION__, this->trdid, process->pid, file_id, cycle );934 printk("\n[%s] thread[%x,%x] enter / fdid %d / cycle %d\n", 935 __FUNCTION__, process->pid, this->trdid, file_id, cycle ); 932 936 #endif 933 937 … … 956 960 #if (DEBUG_VFS_CLOSE & 1 ) 957 961 if( DEBUG_VFS_CLOSE < cycle ) 958 printk("\n[ DBG] %s :reset fd_array[%d] for process %x in cluster %x\n",962 printk("\n[%s] reset fd_array[%d] for process %x in cluster %x\n", 959 963 __FUNCTION__, file_id, process_ptr, process_cxy ); 960 964 #endif … … 981 985 #if (DEBUG_VFS_CLOSE & 1) 982 986 if( DEBUG_VFS_CLOSE < cycle ) 983 printk("\n[ DBG] %s : thread %x in process %xreset all fd-array copies\n",984 __FUNCTION__, this->trdid, process->pid );987 printk("\n[%s] thread[%x,%x] reset all fd-array copies\n", 988 __FUNCTION__, process->pid, this->trdid ); 985 989 #endif 986 990 … … 1003 1007 cycle = (uint32_t)hal_get_cycles(); 1004 1008 if( DEBUG_VFS_CLOSE < cycle ) 1005 printk("\n[ DBG] %s : thread %x in process %xexit / fdid %d closed / cycle %d\n",1006 __FUNCTION__, this->trdid, process->pid, file_id, cycle );1009 printk("\n[%s] thread[%x,%x] exit / fdid %d closed / cycle %d\n", 1010 __FUNCTION__, process->pid, this->trdid, file_id, cycle ); 1007 1011 #endif 1008 1012 … … 1020 1024 } 1021 1025 1022 //////////////////////////////////////// 1023 error_t vfs_stat( xptr_t file_xp, 1024 struct stat * k_stat ) 1025 { 1026 assert( false , "not implemented file_xp: %x, k_stat ptr %x\n", 1027 file_xp, k_stat ); 1026 ////////////////////////////////////// 1027 error_t vfs_stat( xptr_t inode_xp, 1028 stat_t * st ) 1029 { 1030 // get cluster and local pointer on inode descriptor 1031 vfs_inode_t * inode_ptr = GET_PTR( inode_xp ); 1032 cxy_t inode_cxy = GET_CXY( inode_xp ); 1033 1034 // get relevant infos from inode descriptor 1035 uint32_t inum = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->inum ) ); 1036 uint32_t size = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->size ) ); 1037 uint32_t uid = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->uid ) ); 1038 uint32_t gid = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->gid ) ); 1039 uint32_t type = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->type ) ); 1040 uint32_t rights = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->rights ) ); 1041 1042 // set stat structure fields 1043 st->st_ino = inum; 1044 st->st_gid = gid; 1045 st->st_uid = uid; 1046 st->st_size = size; 1047 st->st_mode = (type << 16) | rights; 1048 1049 #if DEBUG_VFS_STAT 1050 uint32_t cycle = (uint32_t)hal_get_cycles(); 1051 thread_t * this = CURRENT_THREAD; 1052 if( DEBUG_VFS_STAT < cycle ) 1053 printk("\n[%s] thread[%x,%x] set stat %x for inode %x in cluster %x / cycle %d\n" 1054 " %s / inum %d / size %d\n", 1055 __FUNCTION__, this->process->pid, this->trdid, st, inode_ptr, inode_cxy, cycle, 1056 vfs_inode_type_str( type ), inum, size ); 1057 #endif 1058 1028 1059 return 0; 1029 1060 } … … 1155 1186 vfs_inode_t * inode_ptr; 1156 1187 vfs_inode_type_t inode_type; 1188 uint32_t inode_size; 1189 uint32_t inode_inum; 1190 uint32_t inode_attr; 1191 uint32_t inode_dirty; 1157 1192 xptr_t children_xp; // extended pointer on children xhtab 1158 1193 … … 1162 1197 xptr_t child_inode_xp; 1163 1198 xptr_t child_dentry_name_xp; 1199 mapper_t * mapper_ptr; 1164 1200 1165 1201 char name[CONFIG_VFS_MAX_NAME_LENGTH]; … … 1182 1218 " " }; // level 15 1183 1219 1184 1185 1186 1220 assert( (inode_xp != XPTR_NULL) , "inode_xp cannot be NULL\n" ); 1221 assert( (name_xp != XPTR_NULL) , "name_xp cannot be NULL\n" ); 1222 assert( (indent < 16) , "depth cannot be larger than 15\n" ); 1187 1223 1188 1224 // get inode cluster and local pointer … … 1190 1226 inode_ptr = GET_PTR( inode_xp ); 1191 1227 1192 // get inode type 1193 inode_type = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->type ) ); 1194 1195 // get local pointer on associated mapper 1196 mapper_t * mapper_ptr = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->mapper ) ); 1228 // get inode type, size, attr, mapper, and inum 1229 inode_type = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->type ) ); 1230 inode_size = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->size ) ); 1231 inode_inum = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->inum ) ); 1232 inode_attr = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->attr ) ); 1233 mapper_ptr = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->mapper ) ); 1197 1234 1198 1235 // make a local copy of node name 1199 1236 hal_remote_strcpy( XPTR( local_cxy , name ) , name_xp ); 1200 1237 1238 // compute dirty 1239 inode_dirty = ((inode_attr & INODE_ATTR_DIRTY) != 0); 1240 1201 1241 // display inode 1202 nolock_printk("%s%s <%s> : in ode = %x / mapper = %x / cluster %x\n",1242 nolock_printk("%s%s <%s> : inum %d / %d bytes / dirty %d / cxy %x (inode %x / mapper %x)\n", 1203 1243 indent_str[indent], vfs_inode_type_str( inode_type ), name, 1204 inode_ ptr , mapper_ptr , inode_cxy);1244 inode_inum, inode_size, inode_dirty, inode_cxy, inode_ptr, mapper_ptr ); 1205 1245 1206 1246 // scan directory entries … … 1447 1487 uint32_t cycle = (uint32_t)hal_get_cycles(); 1448 1488 if( DEBUG_VFS_LOOKUP < cycle ) 1449 printk("\n[ DBG] %s : thread %x in process %xenter for <%s> / cycle %d\n",1450 __FUNCTION__, this->trdid, process->pid, pathname, cycle );1489 printk("\n[%s] thread[%x,%x] enter for <%s> / cycle %d\n", 1490 __FUNCTION__, process->pid, this->trdid, pathname, cycle ); 1451 1491 #endif 1452 1492 … … 1479 1519 #if (DEBUG_VFS_LOOKUP & 1) 1480 1520 if( DEBUG_VFS_LOOKUP < cycle ) 1481 printk("\n[ DBG] %s :look for <%s> / last = %d\n",1521 printk("\n[%s] look for <%s> / last = %d\n", 1482 1522 __FUNCTION__ , name , last ); 1483 1523 #endif … … 1493 1533 #if (DEBUG_VFS_LOOKUP & 1) 1494 1534 if( DEBUG_VFS_LOOKUP < cycle ) 1495 printk("\n[ DBG] %s :miss <%s> node => try to create it\n",1535 printk("\n[%s] miss <%s> node => try to create it\n", 1496 1536 __FUNCTION__ , name ); 1497 1537 #endif … … 1540 1580 #if (DEBUG_VFS_LOOKUP & 1) 1541 1581 if( DEBUG_VFS_LOOKUP < cycle ) 1542 printk("\n[ DBG] %s :missing <%s> inode speculatively created / cxy %x / ptr %x\n",1582 printk("\n[%s] missing <%s> inode speculatively created / cxy %x / ptr %x\n", 1543 1583 __FUNCTION__ , name , child_cxy, child_ptr ); 1544 1584 #endif … … 1567 1607 #if (DEBUG_VFS_LOOKUP & 1) 1568 1608 if( DEBUG_VFS_LOOKUP < cycle ) 1569 printk("\n[ DBG] %s :created node <%s> in path %s / type DIR\n",1609 printk("\n[%s] created node <%s> in path %s / type DIR\n", 1570 1610 __FUNCTION__ , name, pathname ); 1571 1611 #endif … … 1577 1617 #if (DEBUG_VFS_LOOKUP & 1) 1578 1618 if( DEBUG_VFS_LOOKUP < cycle ) 1579 printk("\n[ DBG] %s :created node <%s> in path %s / type FILE\n",1619 printk("\n[%s] created node <%s> in path %s / type FILE\n", 1580 1620 __FUNCTION__ , name, pathname ); 1581 1621 #endif … … 1614 1654 #if (DEBUG_VFS_LOOKUP & 1) 1615 1655 if( DEBUG_VFS_LOOKUP < cycle ) 1616 printk("\n[ DBG] %s :load mapper from device for node <%s> in path %s\n",1656 printk("\n[%s] load mapper from device for node <%s> in path %s\n", 1617 1657 __FUNCTION__ , name, pathname ); 1618 1658 #endif … … 1628 1668 #if (DEBUG_VFS_LOOKUP & 1) 1629 1669 if( DEBUG_VFS_LOOKUP < cycle ) 1630 printk("\n[ DBG] %s :found <%s> / inode %x in cluster %x\n",1670 printk("\n[%s] found <%s> / inode %x in cluster %x\n", 1631 1671 __FUNCTION__ , name , GET_PTR(child_xp) , GET_CXY(child_xp) ); 1632 1672 #endif … … 1670 1710 cycle = (uint32_t)hal_get_cycles(); 1671 1711 if( DEBUG_VFS_LOOKUP < cycle ) 1672 printk("\n[ DBG] %s : thread %x in process %xexit for <%s>\n"1712 printk("\n[%s] thread[%x,%x] exit for <%s>\n" 1673 1713 " parent %x in cluster %x / child %x in cluster %x / cycle %d\n", 1674 __FUNCTION__ , this->trdid, process->pid, pathname,1714 __FUNCTION__ , process->pid, this->trdid, pathname, 1675 1715 parent_ptr, parent_cxy, child_ptr, child_cxy, cycle ); 1676 1716 #endif … … 1777 1817 thread_t * this = CURRENT_THREAD; 1778 1818 if( DEBUG_VFS_ADD_CHILD < cycle ) 1779 printk("\n[DBG] %s : thread %x in process %x enter for <%s>\n" 1780 " child_cxy = %x / parent_cxy = %x / cycle %d\n", 1781 __FUNCTION__, this->trdid, this->process->pid, name, 1819 printk("\n[%s] thread[%x,%x] enter for <%s> / child_cxy %x / parent_cxy %x / cycle %d\n", 1820 __FUNCTION__, this->process->pid, this->trdid, name, 1782 1821 child_cxy, parent_cxy, (uint32_t)hal_get_cycles() ); 1783 1822 #endif … … 1810 1849 #if(DEBUG_VFS_ADD_CHILD & 1) 1811 1850 if( DEBUG_VFS_ADD_CHILD < cycle ) 1812 printk("\n[ DBG] %s : thread %x in process %x/ dentry <%s> created in cluster %x\n",1813 __FUNCTION__, this-> trdid, this->process->pid, name, parent_cxy );1851 printk("\n[%s] thread[%x,%x] / dentry <%s> created in cluster %x\n", 1852 __FUNCTION__, this->process->pid, this->trdid, name, parent_cxy ); 1814 1853 #endif 1815 1854 … … 1860 1899 #if(DEBUG_VFS_ADD_CHILD & 1) 1861 1900 if( DEBUG_VFS_ADD_CHILD < cycle ) 1862 printk("\n[ DBG] %s : thread %x in process %x/ inode <%s> created in cluster %x\n",1863 __FUNCTION__ , this-> trdid, this->process->pid, name , child_cxy );1901 printk("\n[%s] thread[%x,%x] / inode <%s> created in cluster %x\n", 1902 __FUNCTION__ , this->process->pid, this->trdid, name , child_cxy ); 1864 1903 #endif 1865 1904 … … 1872 1911 cycle = (uint32_t)hal_get_cycles(); 1873 1912 if( DEBUG_VFS_ADD_CHILD < cycle ) 1874 printk("\n[ DBG] %s : thread %x in process %xexit for <%s> / cycle %d\n",1875 __FUNCTION__, this-> trdid, this->process->pid, name, (uint32_t)hal_get_cycles() );1913 printk("\n[%s] thread[%x,%x] exit for <%s> / cycle %d\n", 1914 __FUNCTION__, this->process->pid, this->trdid, name, (uint32_t)hal_get_cycles() ); 1876 1915 #endif 1877 1916 … … 1952 1991 1953 1992 #if DEBUG_VFS_MAPPER_MOVE 1954 uint32_t cycle = (uint32_t)hal_get_cycles(); 1993 uint32_t cycle = (uint32_t)hal_get_cycles(); 1994 thread_t * this = CURRENT_THREAD; 1955 1995 if( DEBUG_VFS_MAPPER_MOVE < cycle ) 1956 printk("\n[ DBG] %s : thread %xenter for page %d / mapper %x / inode %x / cycle %d\n",1957 __FUNCTION__, CURRENT_THREAD, page->index, mapper, mapper->inode, cycle );1996 printk("\n[%s] thread[%x,%x] enter for page %d / mapper %x / inode %x / cycle %d\n", 1997 __FUNCTION__, this->process->pid, this->trdid, page->index, mapper, mapper->inode, cycle ); 1958 1998 #endif 1959 1999 … … 1989 2029 cycle = (uint32_t)hal_get_cycles(); 1990 2030 if( DEBUG_VFS_MAPPER_MOVE < cycle ) 1991 printk("\n[ DBG] %s : thread %xexit for page %d / mapper %x / inode %x / cycle %d\n",1992 __FUNCTION__, CURRENT_THREAD, page->index, mapper, mapper->inode, cycle );2031 printk("\n[%s] thread[%x,%x] exit for page %d / mapper %x / inode %x / cycle %d\n", 2032 __FUNCTION__, this->process->pid, this->trdid, page->index, mapper, mapper->inode, cycle ); 1993 2033 #endif 1994 2034 … … 2008 2048 uint32_t size = inode->size; 2009 2049 2010 2050 assert( (mapper != NULL) , "mapper pointer is NULL\n" ); 2011 2051 2012 2052 #if DEBUG_VFS_MAPPER_LOAD 2013 uint32_t cycle = (uint32_t)hal_get_cycles(); 2053 uint32_t cycle = (uint32_t)hal_get_cycles(); 2054 thread_t * this = CURRENT_THREAD; 2014 2055 if( DEBUG_VFS_MAPPER_MOVE < cycle ) 2015 printk("\n[ DBG] %s : thread %xenter for inode %x in cluster %x / cycle %d\n",2016 __FUNCTION__, CURRENT_THREAD, inode, local_cxy, cycle );2056 printk("\n[%s] thread[%x,%x] enter for inode %x in cluster %x / cycle %d\n", 2057 __FUNCTION__, this->process->pid, this->trdid, inode, local_cxy, cycle ); 2017 2058 #endif 2018 2059 … … 2034 2075 cycle = (uint32_t)hal_get_cycles(); 2035 2076 if( DEBUG_VFS_MAPPER_MOVE < cycle ) 2036 printk("\n[ DBG] %s : thread %xexit for inode %x in cluster %x / cycle %d\n",2037 __FUNCTION__, CURRENT_THREAD, inode, local_cxy, cycle );2077 printk("\n[%s] thread[%x,%x] exit for inode %x in cluster %x / cycle %d\n", 2078 __FUNCTION__, this->process->pid, this->trdid, inode, local_cxy, cycle ); 2038 2079 #endif 2039 2080 -
trunk/kernel/fs/vfs.h
r568 r598 76 76 77 77 /****************************************************************************************** 78 * This define the masks for the POSIX access rights to inodes79 *****************************************************************************************/80 81 #define VFS_ISUID 0x000400082 #define VFS_ISGID 0x000200083 #define VFS_ISVTX 0x000100084 85 #define VFS_IRWXU 0x000070086 #define VFS_IRUSR 0x000040087 #define VFS_IWUSR 0x000020088 #define VFS_IXUSR 0x000010089 90 #define VFS_IRWXG 0x000007091 #define VFS_IRGRP 0x000004092 #define VFS_IWGRP 0x000002093 #define VFS_IXGRP 0x000001094 95 #define VFS_IRWXO 0x000000796 #define VFS_IROTH 0x000000497 #define VFS_IWOTH 0x000000298 #define VFS_IXOTH 0x000000199 100 #define VFS_IREAD VFS_IRUSR101 #define VFS_IWRITE VFS_IWUSR102 #define VFS_IEXEC VFS_IXUSR103 104 105 /******************************************************************************************106 78 * This structure defines a VFS context, that contains informations common to all inodes 107 79 * and dentries for a given file system. As it is declared as a global variable in the … … 155 127 156 128 /* this enum define the VFS inode types values */ 129 /* WARNING : this enum must be kept consistent with macros in <shared_stat.h> file */ 157 130 158 131 typedef enum 159 132 { 160 INODE_TYPE_FILE = 0, /*! file*/133 INODE_TYPE_FILE = 0, /*! regular file */ 161 134 INODE_TYPE_DIR = 1, /*! directory */ 162 135 INODE_TYPE_FIFO = 2, /*! POSIX named pipe */ 163 136 INODE_TYPE_PIPE = 3, /*! POSIX anonymous pipe */ 164 137 INODE_TYPE_SOCK = 4, /*! POSIX socket */ 165 INODE_TYPE_DEV = 5, /*! device channel*/138 INODE_TYPE_DEV = 5, /*! character device */ 166 139 INODE_TYPE_SYML = 6, /*! symbolic link */ 167 140 } … … 187 160 uint32_t size; /*! number of bytes */ 188 161 uint32_t links; /*! number of alias dentry */ 189 ui d_tuid; /*! user owner identifier */190 gid_tgid; /*! group owner identifier */162 uint32_t uid; /*! user owner identifier */ 163 uint32_t gid; /*! group owner identifier */ 191 164 uint32_t rights; /*! access rights */ 192 165 uint32_t refcount; /*! reference counter (all pointers) */ … … 201 174 } 202 175 vfs_inode_t; 176 177 /* This define the masks for the inode <rights> field */ 178 179 #define VFS_ISUID 0x0004000 180 #define VFS_ISGID 0x0002000 181 #define VFS_ISVTX 0x0001000 182 183 #define VFS_IRWXU 0x0000700 184 #define VFS_IRUSR 0x0000400 185 #define VFS_IWUSR 0x0000200 186 #define VFS_IXUSR 0x0000100 187 188 #define VFS_IRWXG 0x0000070 189 #define VFS_IRGRP 0x0000040 190 #define VFS_IWGRP 0x0000020 191 #define VFS_IXGRP 0x0000010 192 193 #define VFS_IRWXO 0x0000007 194 #define VFS_IROTH 0x0000004 195 #define VFS_IWOTH 0x0000002 196 #define VFS_IXOTH 0x0000001 203 197 204 198 /****************************************************************************************** … … 514 508 /******************* Inode-Tree related functions ****************************************/ 515 509 /*****************************************************************************************/ 510 511 /****************************************************************************************** 512 * This function returns a printable string for the inode type. 513 *****************************************************************************************/ 514 const char * vfs_inode_type_str( vfs_inode_type_t type ); 516 515 517 516 /****************************************************************************************** … … 712 711 713 712 /****************************************************************************************** 714 * This function returns, in the structure pointed by the < k_stat> kernelpointer,715 * various informations on the file descriptor identified by the <file_xp> argument.716 * TODO notimplemented yet...717 ****************************************************************************************** 718 * @ file_xp : extended pointer on the file descriptor of the searched directory.719 * @ k_stat: local pointer on the stat structure in kernel space.713 * This function returns, in the structure pointed by the <st> pointer, 714 * various informations on the inode identified by the <inode_xp> argument. 715 * TODO : only partially implemented yet... 716 ****************************************************************************************** 717 * @ inode_xp : extended pointer on the remote inode. 718 * @ st : local pointer on the stat structure in kernel space. 720 719 * @ returns 0 if success / -1 if error. 721 720 *****************************************************************************************/ 722 error_t vfs_stat( xptr_t file_xp,723 struct stat * k_stat );721 error_t vfs_stat( xptr_t inode_xp, 722 struct stat * st ); 724 723 725 724 /******************************************************************************************
Note: See TracChangeset
for help on using the changeset viewer.