Changeset 673 for trunk/kernel/fs
- Timestamp:
- Nov 19, 2020, 11:54:16 PM (4 years ago)
- Location:
- trunk/kernel/fs
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/fs/devfs.c
r657 r673 3 3 * 4 4 * Author Mohamed Lamine Karaoui (2014,2015) 5 * Alain Greiner (2016,2017,2018,2019,2020)5 * Alain Greiner (2016,2017,2018,2019,2020) 6 6 * 7 7 * Copyright (c) Sorbonne Universites … … 124 124 // update inode "type" field 125 125 inode = GET_PTR( *devfs_dev_inode_xp ); 126 inode->type = INODE_TYPE_DIR;126 inode->type = FILE_TYPE_DIR; 127 127 128 128 // create dentries <.> and <..> in <dev> … … 154 154 // update inode "type" field 155 155 inode = GET_PTR( *devfs_external_inode_xp ); 156 inode->type = INODE_TYPE_DIR;156 inode->type = FILE_TYPE_DIR; 157 157 158 158 // create dentries <.> and <..> in <external> … … 201 201 202 202 // create <internal> directory 203 snprint f( node_name , 16 , "internal_%x" , local_cxy );203 snprintk( node_name , 16 , "internal_%x" , local_cxy ); 204 204 205 205 error = vfs_add_child_in_parent( local_cxy, // target cluster … … 212 212 // set <internal> inode "type" field 213 213 internal_inode_ptr = GET_PTR( internal_inode_xp ); 214 internal_inode_ptr->type = INODE_TYPE_DEV;214 internal_inode_ptr->type = FILE_TYPE_DEV; 215 215 216 216 // create dentries <.> and <..> in <internal> … … 262 262 inode_ptr = GET_PTR( inode_xp ); 263 263 inode_ptr->extend = chdev_ptr; 264 inode_ptr->type = INODE_TYPE_DEV;264 inode_ptr->type = FILE_TYPE_DEV; 265 265 266 266 #if DEBUG_DEVFS_LOCAL_INIT … … 305 305 inode_ptr = GET_PTR( inode_xp ); 306 306 inode_ptr->extend = chdev_ptr; 307 inode_ptr->type = INODE_TYPE_DEV;307 inode_ptr->type = FILE_TYPE_DEV; 308 308 309 309 #if DEBUG_DEVFS_LOCAL_INIT … … 341 341 inode_ptr = GET_PTR( inode_xp ); 342 342 inode_ptr->extend = chdev_ptr; 343 inode_ptr->type = INODE_TYPE_DEV;343 inode_ptr->type = FILE_TYPE_DEV; 344 344 345 345 #if DEBUG_DEVFS_LOCAL_INIT … … 378 378 inode_ptr = GET_PTR( inode_xp ); 379 379 inode_ptr->extend = chdev_ptr; 380 inode_ptr->type = INODE_TYPE_DEV;380 inode_ptr->type = FILE_TYPE_DEV; 381 381 382 382 #if DEBUG_DEVFS_LOCAL_INIT … … 417 417 inode_ptr = GET_PTR( inode_xp ); 418 418 inode_ptr->extend = chdev_ptr; 419 inode_ptr->type = INODE_TYPE_DEV;419 inode_ptr->type = FILE_TYPE_DEV; 420 420 421 421 #if DEBUG_DEVFS_LOCAL_INIT … … 456 456 inode_ptr = GET_PTR( inode_xp ); 457 457 inode_ptr->extend = chdev_ptr; 458 inode_ptr->type = INODE_TYPE_DEV;458 inode_ptr->type = FILE_TYPE_DEV; 459 459 460 460 #if DEBUG_DEVFS_LOCAL_INIT … … 495 495 inode_ptr = GET_PTR( inode_xp ); 496 496 inode_ptr->extend = chdev_ptr; 497 inode_ptr->type = INODE_TYPE_DEV;497 inode_ptr->type = FILE_TYPE_DEV; 498 498 499 499 #if DEBUG_DEVFS_LOCAL_INIT … … 534 534 inode_ptr = GET_PTR( inode_xp ); 535 535 inode_ptr->extend = chdev_ptr; 536 inode_ptr->type = INODE_TYPE_DEV;536 inode_ptr->type = FILE_TYPE_DEV; 537 537 538 538 #if DEBUG_DEVFS_LOCAL_INIT … … 573 573 inode_ptr = GET_PTR( inode_xp ); 574 574 inode_ptr->extend = chdev_ptr; 575 inode_ptr->type = INODE_TYPE_DEV;575 inode_ptr->type = FILE_TYPE_DEV; 576 576 577 577 #if DEBUG_DEVFS_LOCAL_INIT … … 612 612 inode_ptr = GET_PTR( inode_xp ); 613 613 inode_ptr->extend = chdev_ptr; 614 inode_ptr->type = INODE_TYPE_DEV;614 inode_ptr->type = FILE_TYPE_DEV; 615 615 616 616 #if DEBUG_DEVFS_LOCAL_INIT … … 643 643 char k_buf[CONFIG_TXT_KBUF_SIZE]; // local kernel buffer 644 644 645 assert( ( file_xp != XPTR_NULL ) , "file_xp == XPTR_NULL" );645 assert( __FUNCTION__, ( file_xp != XPTR_NULL ) , "file_xp == XPTR_NULL" ); 646 646 647 647 #if (DEBUG_SYS_READ & 1) … … 673 673 674 674 // Only TXT devices are associated to a pseudo-file 675 assert( ( func == DEV_FUNC_TXT ) , __FUNCTION__, "illegal device func_type");675 assert( __FUNCTION__, ( func == DEV_FUNC_TXT ) , "illegal device func_type"); 676 676 677 677 // initialise number of bytes to move … … 770 770 771 771 // detailed argument unused 772 assert( (detailed == false) , "detailed argument not supported\n");772 assert( __FUNCTION__, (detailed == false) , "detailed argument not supported\n"); 773 773 774 774 // One loop to scan the target inode xhtab containing the set of dentries -
trunk/kernel/fs/devfs.h
r657 r673 3 3 * 4 4 * Authors Mohamed Lamine Karaoui (2014,2015) 5 * Alain Greiner (2016,2017,2018,2019,2020)5 * Alain Greiner (2016,2017,2018,2019,2020) 6 6 * 7 7 * Copyright (c) 2011,2012 UPMC Sorbonne Universites -
trunk/kernel/fs/fatfs.c
r657 r673 1098 1098 error_t error; 1099 1099 1100 assert( (searched_page_id > first_page_id) ,1100 assert( __FUNCTION__, (searched_page_id > first_page_id) , 1101 1101 "searched_page_id must be larger than first_page_id\n"); 1102 1102 … … 1239 1239 1240 1240 // check arguments 1241 assert( (mapper_xp != XPTR_NULL) , "mapper pointer is NULL\n" );1242 assert( (name != NULL ) , "child name is undefined\n" );1241 assert( __FUNCTION__, (mapper_xp != XPTR_NULL) , "mapper pointer is NULL\n" ); 1242 assert( __FUNCTION__, (name != NULL ) , "child name is undefined\n" ); 1243 1243 1244 1244 #if DEBUG_FATFS_SCAN_DIRECTORY … … 1882 1882 1883 1883 // check arguments 1884 assert( (parent_inode_xp != XPTR_NULL) , "parent_inode_xp argument is NULL\n" );1885 assert( (dentry_ptr != NULL) , "dentry_ptr argument is NULL\n" );1884 assert( __FUNCTION__, (parent_inode_xp != XPTR_NULL) , "parent_inode_xp argument is NULL\n" ); 1885 assert( __FUNCTION__, (dentry_ptr != NULL) , "dentry_ptr argument is NULL\n" ); 1886 1886 1887 1887 // get directory inode cluster and local pointer … … 2153 2153 else if (i == 11) // ATTR 2154 2154 { 2155 if (type == INODE_TYPE_DIR) buf[i] = 0x10;2155 if (type == FILE_TYPE_DIR) buf[i] = 0x10; 2156 2156 else buf[i] = 0x20; 2157 2157 } … … 2236 2236 2237 2237 // check arguments 2238 assert( (parent_inode_xp != XPTR_NULL) , "parent_inode_xp argument is NULL\n" );2239 assert( (dentry_ptr != NULL) , "dentry_ptr argument is NULL\n" );2238 assert( __FUNCTION__, (parent_inode_xp != XPTR_NULL) , "parent_inode_xp argument is NULL\n" ); 2239 assert( __FUNCTION__, (dentry_ptr != NULL) , "dentry_ptr argument is NULL\n" ); 2240 2240 2241 2241 // get directory inode cluster and local pointer … … 2344 2344 2345 2345 // check for LFN entry 2346 assert( (fatfs_get_remote_record( DIR_ATTR, base_xp + offset ) == ATTR_LONG_NAME_MASK ),2346 assert( __FUNCTION__, (fatfs_get_remote_record( DIR_ATTR, base_xp + offset ) == ATTR_LONG_NAME_MASK ), 2347 2347 "this directory entry must be a LFN\n"); 2348 2348 … … 2395 2395 2396 2396 // check arguments 2397 assert( (parent_inode_xp != XPTR_NULL) , "parent_inode_xp is NULL\n" );2398 assert( (dentry_ptr != NULL ) , "dentry_ptr is NULL\n" );2397 assert( __FUNCTION__, (parent_inode_xp != XPTR_NULL) , "parent_inode_xp is NULL\n" ); 2398 assert( __FUNCTION__, (dentry_ptr != NULL ) , "dentry_ptr is NULL\n" ); 2399 2399 2400 2400 // get parent inode cluster and local pointer … … 2445 2445 2446 2446 // update the child inode "type", "size", and "extend" fields 2447 vfs_ inode_type_t type = (is_dir) ? INODE_TYPE_DIR : INODE_TYPE_FILE;2447 vfs_file_type_t type = (is_dir) ? FILE_TYPE_DIR : FILE_TYPE_REG; 2448 2448 2449 2449 hal_remote_s32( XPTR( child_cxy , &child_inode_ptr->type ) , type ); … … 2486 2486 2487 2487 // check arguments 2488 assert( (parent_inode_xp != XPTR_NULL) , "parent_inode_xp argument is NULL\n" );2489 assert( (dentry_ptr != NULL) , "dentry_ptr argument NULL\n" );2488 assert( __FUNCTION__, (parent_inode_xp != XPTR_NULL) , "parent_inode_xp argument is NULL\n" ); 2489 assert( __FUNCTION__, (dentry_ptr != NULL) , "dentry_ptr argument NULL\n" ); 2490 2490 2491 2491 // get child inode cluster and local pointer … … 2574 2574 2575 2575 // check arguments 2576 assert( (parent_inode_xp != XPTR_NULL) , "parent_inode_xp argument is NULL\n" );2577 assert( (dentry_ptr != NULL) , "dentry_ptr argument is NULL\n" );2576 assert( __FUNCTION__, (parent_inode_xp != XPTR_NULL) , "parent_inode_xp argument is NULL\n" ); 2577 assert( __FUNCTION__, (dentry_ptr != NULL) , "dentry_ptr argument is NULL\n" ); 2578 2578 2579 2579 // get parent directory cluster ans local pointer … … 2680 2680 2681 2681 // check mapper pointer 2682 assert( (mapper != NULL) , "mapper is NULL\n");2682 assert( __FUNCTION__, (mapper != NULL) , "mapper is NULL\n"); 2683 2683 2684 2684 // TODO handle the detailed flag 2685 assert( (detailed == false), "detailed argument not supported/n");2685 assert( __FUNCTION__, (detailed == false), "detailed argument not supported/n"); 2686 2686 2687 2687 char cname[CONFIG_VFS_MAX_NAME_LENGTH]; // name extracted from each dentry … … 2829 2829 2830 2830 // check inode pointer and cluster index 2831 assert( (inode_xp != XPTR_NULL) , "inode pointer undefined\n" );2831 assert( __FUNCTION__, (inode_xp != XPTR_NULL) , "inode pointer undefined\n" ); 2832 2832 2833 2833 #if DEBUG_FATFS_SYNC_INODE … … 2848 2848 mapper = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->mapper ) ); 2849 2849 2850 assert( (mapper != NULL) , "mapper pointer is NULL\n" );2850 assert( __FUNCTION__, (mapper != NULL) , "mapper pointer is NULL\n" ); 2851 2851 2852 2852 // get inode type and size … … 2854 2854 type = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->type ) ); 2855 2855 2856 assert( (type == INODE_TYPE_FILE) , "inode is not a file\n" );2856 assert( __FUNCTION__, (type == FILE_TYPE_REG) , "inode is not a file\n" ); 2857 2857 2858 2858 // compute number of pages … … 3009 3009 3010 3010 // check inode pointer 3011 assert( (inode_xp != XPTR_NULL) , "inode pointer is NULL\n" );3011 assert( __FUNCTION__, (inode_xp != XPTR_NULL) , "inode pointer is NULL\n" ); 3012 3012 3013 3013 // get inode cluster and local pointer … … 3020 3020 3021 3021 // check first cluster index 3022 assert( (first_cluster_id != 0) , "inode extend is NULL\n" );3022 assert( __FUNCTION__, (first_cluster_id != 0) , "inode extend is NULL\n" ); 3023 3023 3024 3024 #if DEBUG_FATFS_RELEASE_INODE -
trunk/kernel/fs/ramfs.c
r623 r673 50 50 // update inode type field 51 51 inode_ptr = GET_PTR( inode_xp ); 52 inode_ptr->type = INODE_TYPE_DIR;52 inode_ptr->type = FILE_TYPE_DIR; 53 53 } 54 54 -
trunk/kernel/fs/vfs.c
r657 r673 2 2 * vfs.c - Virtual File System implementation. 3 3 * 4 * Author Mohamed Lamine Karaoui (201 5)5 * Alain Greiner (2016,2017,2018,2019,2020)4 * Author Mohamed Lamine Karaoui (2014,2015) 5 * Alain Greiner (2016,2017,2018,2019,2020) 6 6 * 7 7 * Copyright (c) UPMC Sorbonne Universites … … 38 38 #include <thread.h> 39 39 #include <chdev.h> 40 #include <pipe.h> 40 41 #include <process.h> 41 42 #include <cluster.h> … … 155 156 ////////////////////////////////////////////////////////////////////////////////////////// 156 157 157 const char * vfs_inode_type_str( vfs_ inode_type_t type )158 const char * vfs_inode_type_str( vfs_file_type_t type ) 158 159 { 159 160 switch ( type ) 160 161 { 161 case INODE_TYPE_FILE: return "FILE";162 case INODE_TYPE_DIR: return "DIR ";163 case INODE_TYPE_FIFO: return "FIFO";164 case INODE_TYPE_PIPE: return "PIPE";165 case INODE_TYPE_SOCK: return "SOCK";166 case INODE_TYPE_DEV: return "DEV ";167 case INODE_TYPE_BLK: return "BLK ";168 case INODE_TYPE_SYML: return "SYML";162 case FILE_TYPE_REG: return "FILE"; 163 case FILE_TYPE_DIR: return "DIR "; 164 case FILE_TYPE_FIFO: return "FIFO"; 165 case FILE_TYPE_PIPE: return "PIPE"; 166 case FILE_TYPE_SOCK: return "SOCK"; 167 case FILE_TYPE_DEV: return "DEV "; 168 case FILE_TYPE_BLK: return "BLK "; 169 case FILE_TYPE_SYML: return "SYML"; 169 170 default: return "undefined"; 170 171 } … … 188 189 error_t error; 189 190 191 #if DEBUG_VFS_INODE_CREATE || DEBUG_VFS_ERROR 192 uint32_t cycle = (uint32_t)hal_get_cycles(); 193 thread_t * this = CURRENT_THREAD; 194 #endif 195 190 196 // check fs type and get pointer on context 191 197 if ( fs_type == FS_TYPE_FATFS ) ctx = &fs_context[FS_TYPE_FATFS]; … … 194 200 else 195 201 { 196 printk("\n[ERROR] in %s : illegal FS type\n", __FUNCTION__ ); 202 203 #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 ); 207 #endif 197 208 return -1; 198 209 } 199 210 200 211 // check inode descriptor contained in one page 201 assert( (sizeof(vfs_inode_t) <= CONFIG_PPM_PAGE_SIZE),212 assert( __FUNCTION__, (sizeof(vfs_inode_t) <= CONFIG_PPM_PAGE_SIZE), 202 213 "inode descriptor must fit in one page" ); 203 214 … … 207 218 if( error ) 208 219 { 209 printk("\n[ERROR] in %s : cannot allocate inum\n", __FUNCTION__ ); 220 221 #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 ); 225 #endif 210 226 return -1; 211 227 } … … 216 232 if( mapper_xp == XPTR_NULL ) 217 233 { 218 printk("\n[ERROR] in %s : cannot allocate mapper\n", __FUNCTION__ ); 234 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 ); 239 #endif 219 240 vfs_ctx_inum_release( XPTR( cxy , ctx ) , inum ); 220 241 return -1; … … 232 253 if( inode_ptr == NULL ) 233 254 { 234 printk("\n[ERROR] in %s : cannot allocate inode descriptor\n", __FUNCTION__ ); 255 256 #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 ); 260 #endif 235 261 vfs_ctx_inum_release( XPTR( cxy , ctx ) , inum ); 236 262 mapper_destroy( mapper_xp ); … … 242 268 243 269 // initialize inode descriptor 244 hal_remote_s32( XPTR( cxy , &inode_ptr->type ) , INODE_TYPE_FILE); // default value270 hal_remote_s32( XPTR( cxy , &inode_ptr->type ) , FILE_TYPE_REG ); // default value 245 271 hal_remote_s32( XPTR( cxy , &inode_ptr->inum ) , inum ); 246 272 hal_remote_s32( XPTR( cxy , &inode_ptr->attr ) , attr ); … … 269 295 270 296 #if DEBUG_VFS_INODE_CREATE 271 uint32_t cycle = (uint32_t)hal_get_cycles();272 thread_t * this = CURRENT_THREAD;273 297 if( DEBUG_VFS_INODE_CREATE < cycle ) 274 298 printk("\n[%s] thread[%x,%x] created inode (%x,%x) / ctx %x / fs_type %d / cycle %d\n", … … 287 311 cxy_t inode_cxy = GET_CXY( inode_xp ); 288 312 313 // get local pointer on mapper 314 mapper_t * mapper_ptr = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->mapper )); 315 289 316 // release memory allocated for mapper 290 mapper_destroy( XPTR( inode_cxy , &inode_ptr->mapper ) );317 mapper_destroy( XPTR( inode_cxy , mapper_ptr ) ); 291 318 292 319 // release memory allocated for inode descriptor … … 458 485 void vfs_inode_display( xptr_t inode_xp ) 459 486 { 460 assert( (inode_xp != XPTR_NULL), "inode pointer is NULL");487 assert( __FUNCTION__, (inode_xp != XPTR_NULL), "inode pointer is NULL"); 461 488 462 489 char name[CONFIG_VFS_MAX_NAME_LENGTH]; … … 468 495 vfs_inode_t * inode_ptr = GET_PTR( inode_xp ); 469 496 470 vfs_ inode_type_t type = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->type ) );497 vfs_file_type_t type = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->type ) ); 471 498 uint32_t attr = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->attr ) ); 472 499 uint32_t size = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->size ) ); … … 511 538 vfs_dentry_t * dentry_ptr; // dentry descriptor (to be allocated) 512 539 513 #if DEBUG_VFS_DENTRY_CREATE 540 #if DEBUG_VFS_DENTRY_CREATE || DEBUG_VFS_ERROR 514 541 thread_t * this = CURRENT_THREAD; 515 542 uint32_t cycle = (uint32_t)hal_get_cycles(); 543 #endif 544 545 #if DEBUG_VFS_DENTRY_CREATE 516 546 if( DEBUG_VFS_DENTRY_CREATE < cycle ) 517 547 printk("\n[%s] thread[%x,%x] enters for <%s> / fs_type %x / cycle %d\n", … … 525 555 else 526 556 { 527 printk("\n[ERROR] in %s undefined fs_type %d\n", __FUNCTION__, fs_type ); 557 558 #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 ); 562 #endif 528 563 return -1; 529 564 } … … 542 577 if( dentry_ptr == NULL ) 543 578 { 544 printk("\n[ERROR] in %s : cannot allocate dentry descriptor\n", 545 __FUNCTION__ ); 579 580 #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 ); 584 #endif 546 585 return -1; 547 586 } … … 594 633 xptr_t * file_xp ) 595 634 { 596 vfs_file_t * file_ptr; 597 kmem_req_t req; 598 uint32_t type; 599 mapper_t * mapper; 600 vfs_ctx_t * ctx; 635 vfs_file_t * file_ptr; 636 kmem_req_t req; 637 uint32_t type; 638 mapper_t * mapper; 639 pipe_t * pipe; 640 vfs_ctx_t * ctx; 601 641 602 642 // get inode cluster and local pointer … … 607 647 thread_t * this = CURRENT_THREAD; 608 648 uint32_t cycle = (uint32_t)hal_get_cycles(); 609 if( DEBUG_VFS_ OPEN< cycle )649 if( DEBUG_VFS_FILE_CREATE < cycle ) 610 650 printk("\n[%s] thread[%x,%x] enter for inode (%x,%x) / cycle %d\n", 611 651 __FUNCTION__, this->process->pid, this->trdid, inode_cxy, inode_ptr, cycle ); … … 620 660 if( file_ptr == NULL ) return -1; 621 661 622 // get type, ctx and mapper from inode descriptor662 // get type, ctx, mapper, and buffer from inode descriptor 623 663 type = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->type ) ); 624 664 ctx = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->ctx ) ); 625 665 mapper = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->mapper ) ); 666 pipe = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->pipe ) ); 626 667 627 668 // initializes new file descriptor 628 669 hal_remote_s32( XPTR( inode_cxy , &file_ptr->type ) , type ); 629 670 hal_remote_s32( XPTR( inode_cxy , &file_ptr->attr ) , attr ); 671 hal_remote_spt( XPTR( inode_cxy , &file_ptr->ctx ) , ctx ); 630 672 hal_remote_s32( XPTR( inode_cxy , &file_ptr->offset ) , 0 ); 631 hal_remote_s32( XPTR( inode_cxy , &file_ptr->refcount ) , 1 );632 673 hal_remote_spt( XPTR( inode_cxy , &file_ptr->inode ) , inode_ptr ); 633 hal_remote_spt( XPTR( inode_cxy , &file_ptr->ctx ) , ctx );634 674 hal_remote_spt( XPTR( inode_cxy , &file_ptr->mapper ) , mapper ); 675 hal_remote_spt( XPTR( inode_cxy , &file_ptr->pipe ) , pipe ); 635 676 636 677 remote_rwlock_init( XPTR( inode_cxy , &file_ptr->lock ), LOCK_VFS_FILE ); … … 639 680 640 681 #if DEBUG_VFS_FILE_CREATE 641 cycle = (uint32_t)hal_get_cycles(); 642 if( DEBUG_VFS_OPEN < cycle ) 643 printk("\n[%s] thread[%x,%x] created file (%x,%x) %x\n", 644 __FUNCTION__, this->process->pid, this->trdid, inode_cxy, file_ptr, cycle ); 682 if( (DEBUG_VFS_FILE_CREATE < cycle) && (type == FILE_TYPE_REG)) 683 { 684 char name[CONFIG_VFS_MAX_NAME_LENGTH]; 685 vfs_file_get_name( XPTR( inode_cxy , file_ptr ) , name ); 686 printk("\n[%s] thread[%x,%x] created file (%x,%x) / %s (%s)\n", 687 __FUNCTION__, this->process->pid, this->trdid, 688 inode_cxy, file_ptr, vfs_inode_type_str(type), name ); 689 } 690 if( (DEBUG_VFS_FILE_CREATE < cycle) && (type != FILE_TYPE_REG)) 691 { 692 printk("\n[%s] thread[%x,%x] created file (%x,%x) / %s\n", 693 __FUNCTION__, this->process->pid, this->trdid, 694 inode_cxy, file_ptr, vfs_inode_type_str(type) ); 695 } 645 696 #endif 646 697 … … 655 706 vfs_file_t * file_ptr = GET_PTR( file_xp ); 656 707 cxy_t file_cxy = GET_CXY( file_xp ); 708 709 #if DEBUG_VFS_FILE_DESTROY 710 char name[CONFIG_VFS_MAX_NAME_LENGTH]; 711 vfs_file_get_name( file_xp , name ); 712 thread_t * this = CURRENT_THREAD; 713 uint32_t cycle = (uint32_t)hal_get_cycles(); 714 if( DEBUG_VFS_FILE_DESTROY < cycle ) 715 printk("\n[%s] thread[%x,%x] enter / file_ptr %x / file_cxy %x / <%s> / cycle %d\n", 716 __FUNCTION__, this->process->pid, this->trdid, file_ptr, file_cxy, name, cycle ); 717 #endif 657 718 658 719 // release file descriptor … … 662 723 kmem_remote_free( file_cxy , &req ); 663 724 664 #if DEBUG_VFS_CLOSE 665 char name[CONFIG_VFS_MAX_NAME_LENGTH]; 666 vfs_file_get_name( file_xp , name ); 667 thread_t * this = CURRENT_THREAD; 668 uint32_t cycle = (uint32_t)hal_get_cycles(); 669 if( DEBUG_VFS_CLOSE < cycle ) 670 printk("\n[%s] thread[%x,%x] deleted file <%s> in cluster %x / cycle %d\n", 671 __FUNCTION__, this->process->pid, this->trdid, name, file_cxy, cycle ); 725 #if DEBUG_VFS_FILE_DESTROY 726 cycle = (uint32_t)hal_get_cycles(); 727 if( DEBUG_VFS_FILE_DESTROY < cycle ) 728 printk("\n[%s] thread[%x,%x] exit for <%s> / cycle %d\n", 729 __FUNCTION__, this->process->pid, this->trdid, file_ptr, file_cxy, name, cycle ); 672 730 #endif 673 731 674 732 } // end vfs_file_destroy() 675 676 677 ////////////////////////////////////////678 void vfs_file_count_up( xptr_t file_xp )679 {680 // get file cluster and local pointer681 cxy_t file_cxy = GET_CXY( file_xp );682 vfs_file_t * file_ptr = GET_PTR( file_xp );683 684 // atomically increment count685 hal_remote_atomic_add( XPTR( file_cxy , &file_ptr->refcount ) , 1 );686 }687 688 //////////////////////////////////////////689 void vfs_file_count_down( xptr_t file_xp )690 {691 // get file cluster and local pointer692 cxy_t file_cxy = GET_CXY( file_xp );693 vfs_file_t * file_ptr = GET_PTR( file_xp );694 695 // atomically decrement count696 hal_remote_atomic_add( XPTR( file_cxy , &file_ptr->refcount ) , -1 );697 }698 733 699 734 /////////////////////////////////////// … … 755 790 if( (flags & O_EXCL ) ) lookup_mode |= VFS_LOOKUP_EXCL; 756 791 792 #if DEBUG_VFS_OPEN || DEBUG_VFS_ERROR 793 uint32_t cycle = (uint32_t)hal_get_cycles(); 794 #endif 795 757 796 #if DEBUG_VFS_OPEN 758 uint32_t cycle = (uint32_t)hal_get_cycles();759 797 if( DEBUG_VFS_OPEN < cycle ) 760 798 printk("\n[%s] thread[%x,%x] enter for <%s> / root_inode (%x,%x) / cycle %d\n", … … 791 829 if( error ) 792 830 { 793 printk("\n[ERROR] in %s : cannot get inode <%s>\n", 794 __FUNCTION__ , path ); 831 832 #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 ); 836 #endif 795 837 return -1; 796 838 } … … 824 866 if( error ) return error; 825 867 868 // get new file descriptor cluster and local pointer 869 cxy_t file_cxy = GET_CXY( file_xp ); 870 vfs_file_t * file_ptr = GET_PTR( file_xp ); 871 872 //get file type 873 uint32_t file_type = hal_remote_l32( XPTR( file_cxy , &file_ptr->type )); 874 875 // link the client thead to the pipe for a FIFO type 876 if( file_type == FILE_TYPE_FIFO ) 877 { 878 // get local pointer on attached pipe 879 pipe_t * pipe = hal_remote_lpt( XPTR( file_cxy , &file_ptr->pipe )); 880 881 // build extended pointer on client thread 882 xptr_t thread_xp = XPTR( local_cxy , this ); 883 884 // update pipe descriptor 885 if( flags & O_RDONLY ) hal_remote_s64( XPTR(file_cxy,&pipe->reader_xp) , thread_xp ); 886 if( flags & O_WRONLY ) hal_remote_s64( XPTR(file_cxy,&pipe->writer_xp) , thread_xp ); 887 } 888 826 889 #if DEBUG_VFS_OPEN 827 890 cycle = (uint32_t)hal_get_cycles(); … … 849 912 mapper_t * mapper; // local pointer on file mapper 850 913 vfs_inode_t * inode; // local pointer on file inode 851 vfs_ inode_type_t type; // inode type914 vfs_file_type_t type; // inode type 852 915 uint32_t offset; // current offset in file 853 916 uint32_t size; // current file size … … 856 919 857 920 // check argument 858 assert( (file_xp != XPTR_NULL), "file_xp == XPTR_NULL" );921 assert( __FUNCTION__, (file_xp != XPTR_NULL), "file_xp == XPTR_NULL" ); 859 922 860 923 // get cluster and local pointer on remote file descriptor … … 870 933 871 934 // check inode type 872 assert( (type == INODE_TYPE_FILE), "bad inode type" ); 935 assert( __FUNCTION__, (type == FILE_TYPE_REG), "bad inode type" ); 936 937 #if DEBUG_VFS_USER_MOVE || DEBUG_VFS_ERROR 938 uint32_t cycle = (uint32_t)hal_get_cycles(); 939 thread_t * this = CURRENT_THREAD; 940 #endif 873 941 874 942 #if DEBUG_VFS_USER_MOVE 875 943 char name[CONFIG_VFS_MAX_NAME_LENGTH]; 876 uint32_t cycle = (uint32_t)hal_get_cycles();877 thread_t * this = CURRENT_THREAD;878 944 vfs_inode_get_name( XPTR( file_cxy , inode ) , name ); 879 945 if( cycle > DEBUG_VFS_USER_MOVE ) … … 929 995 if( error ) 930 996 { 931 printk("\n[ERROR] in %s : cannot move data", __FUNCTION__ ); 997 998 #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 ); 1002 #endif 932 1003 return -1; 933 1004 } … … 961 1032 cxy_t file_cxy; // remote file descriptor cluster 962 1033 vfs_file_t * file_ptr; // remote file descriptor local pointer 963 vfs_ inode_type_t inode_type; // remote file type1034 vfs_file_type_t inode_type; // remote file type 964 1035 uint32_t file_offset; // current offset in file 965 1036 mapper_t * mapper_ptr; // remote mapper local pointer … … 968 1039 969 1040 // check argument 970 assert( (file_xp != XPTR_NULL) , "file_xp == XPTR_NULL" );1041 assert( __FUNCTION__, (file_xp != XPTR_NULL) , "file_xp == XPTR_NULL" ); 971 1042 972 1043 // get cluster and local pointer on remote file descriptor … … 978 1049 979 1050 // check inode type 980 assert( (inode_type == INODE_TYPE_FILE), "bad file type" );1051 assert( __FUNCTION__, (inode_type == FILE_TYPE_REG), "bad file type" ); 981 1052 982 1053 // get mapper pointers and file offset from file descriptor … … 1035 1106 1036 1107 // check arguments 1037 assert( (file_xp != XPTR_NULL) , "file_xp == XPTR_NULL" );1038 assert( (new_offset != NULL ) , "new_offset == NULL" );1108 assert( __FUNCTION__, (file_xp != XPTR_NULL) , "file_xp == XPTR_NULL" ); 1109 assert( __FUNCTION__, (new_offset != NULL ) , "new_offset == NULL" ); 1039 1110 1040 1111 // get cluster and local pointer on remote file descriptor … … 1114 1185 1115 1186 // check argument 1116 assert( (file_xp != XPTR_NULL) , "file_xp is XPTR_NULL" );1187 assert( __FUNCTION__, (file_xp != XPTR_NULL) , "file_xp is XPTR_NULL" ); 1117 1188 1118 1189 thread_t * this = CURRENT_THREAD; … … 1241 1312 xptr_t entry_xp = XPTR( process_cxy , &process_ptr->fd_array.array[file_id] ); 1242 1313 hal_remote_s64( entry_xp , XPTR_NULL ); 1243 vfs_file_count_down( file_xp );1244 1314 hal_fence(); 1245 1315 } … … 1309 1379 #endif 1310 1380 1311 // build extended pointer on lock protecting Inode 1381 // build extended pointer on lock protecting Inode-Tree (in VFS root inode) 1312 1382 vfs_root_xp = process->vfs_root_xp; 1313 1383 vfs_root_ptr = GET_PTR( vfs_root_xp ); … … 1398 1468 1399 1469 // update inode "type" field 1400 hal_remote_s32( XPTR( inode_cxy , &inode_ptr->type ) , INODE_TYPE_DIR );1470 hal_remote_s32( XPTR( inode_cxy , &inode_ptr->type ) , FILE_TYPE_DIR ); 1401 1471 1402 1472 #if(DEBUG_VFS_MKDIR & 1) … … 1576 1646 1577 1647 /////////////////////////////////////////////////////////////////////// 1578 if( (inode_type == INODE_TYPE_FILE) || (inode_type == INODE_TYPE_DIR) )1648 if( (inode_type == FILE_TYPE_REG) || (inode_type == FILE_TYPE_DIR) ) 1579 1649 { 1580 1650 // 1. create one new dentry … … 1666 1736 vfs_inode_t * inode_ptr; // target inode local pointer 1667 1737 uint32_t inode_links; // target inode links count 1668 vfs_ inode_type_t inode_type; // target inode type1738 vfs_file_type_t inode_type; // target inode type 1669 1739 uint32_t inode_children; // target inode number of children 1670 1740 xptr_t dentry_xp; // extended pointer on dentry to unlink … … 1805 1875 1806 1876 /////////////////////////////////////////////////////////////////////// 1807 if( (inode_type == INODE_TYPE_FILE) || (inode_type == INODE_TYPE_DIR) )1877 if( (inode_type == FILE_TYPE_REG) || (inode_type == FILE_TYPE_DIR) ) 1808 1878 { 1809 1879 … … 1814 1884 vfs_inode_type_str(inode_type), inode_links ); 1815 1885 #endif 1816 1817 // 1. Release clusters allocated to target inode 1886 // 1. Release space allocated to inode on IOC device 1818 1887 // and synchronize the FAT on IOC device if last link. 1819 1888 if( inode_links == 1 ) … … 1834 1903 } 1835 1904 1836 // release clusterson IOC device1905 // release space on IOC device 1837 1906 error = vfs_fs_release_inode( inode_xp ); 1838 1907 … … 1869 1938 __FUNCTION__, process->pid, this->trdid, path ); 1870 1939 #endif 1871 // 3. remove dentry from Inode Tree (and associated chil sinode when last link)1940 // 3. remove dentry from Inode Tree (and associated child inode when last link) 1872 1941 vfs_remove_child_from_parent( dentry_xp ); 1873 1942 … … 1876 1945 1877 1946 #if DEBUG_VFS_UNLINK 1947 if( DEBUG_VFS_UNLINK < cycle ) 1948 printk("\n[%s] thread[%x,%x] exit / removed <%s> inode from Inode Tree / cycle %d\n", 1949 __FUNCTION__, process->pid, this->trdid, path, cycle ); 1950 #endif 1951 return 0; 1952 } 1953 //////////////////////////////////////// 1954 else if( inode_type == FILE_TYPE_FIFO ) 1955 { 1956 // 1. destroy the associated pipe 1957 pipe_t * pipe = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->pipe )); 1958 pipe_destroy( XPTR( inode_cxy , pipe ) ); 1959 1960 #if(DEBUG_VFS_UNLINK & 1) 1961 if( DEBUG_VFS_UNLINK < cycle ) 1962 printk("\n[%s] thread[%x,%x] released <%s> pipe\n", 1963 __FUNCTION__, process->pid, this->trdid, path ); 1964 #endif 1965 1966 // 2. remove dentry from Inode Tree (and associated child inode when last link) 1967 vfs_remove_child_from_parent( dentry_xp ); 1968 1969 // release the lock protecting Inode Tree 1970 remote_rwlock_wr_release( lock_xp ); 1971 1972 #if DEBUG_VFS_UNLINK 1878 1973 if( DEBUG_VFS_UNLINK < cycle ) 1879 1974 printk("\n[%s] thread[%x,%x] exit / removed <%s> inode from Inode Tree / cycle %d\n", … … 1975 2070 cxy_t inode_cxy; // target inode cluster identifier 1976 2071 vfs_inode_t * inode_ptr; // target inode local pointer 1977 vfs_ inode_type_t inode_type; // target inode type2072 vfs_file_type_t inode_type; // target inode type 1978 2073 xptr_t vfs_root_xp; // extended pointer on VFS root inode 1979 2074 vfs_inode_t * vfs_root_ptr; // local_pointer on VFS root inode … … 2027 2122 inode_type = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->type ) ); 2028 2123 2029 if( inode_type != INODE_TYPE_DIR )2124 if( inode_type != FILE_TYPE_DIR ) 2030 2125 { 2031 2126 printk("\n[ERROR] in %s : <%s> is not a directory\n", … … 2073 2168 2074 2169 // check lookup working mode 2075 assert( (rights == 0), "access rights non implemented yet" );2170 assert( __FUNCTION__, (rights == 0), "access rights non implemented yet" ); 2076 2171 2077 2172 // get extended pointer on target inode … … 2093 2188 // TODO finalize implementation 2094 2189 2095 assert( false , "not implemented" );2190 assert( __FUNCTION__, false , "not implemented" ); 2096 2191 2097 2192 // set inode rights in remote inode … … 2099 2194 2100 2195 return 0; 2101 } 2102 2103 /////////////////////////////////// 2104 error_t vfs_mkfifo( xptr_t cwd_xp, 2196 2197 } // end vfs_chmod() 2198 2199 ///////////////////////////////////// 2200 error_t vfs_mkfifo( xptr_t root_xp, 2105 2201 char * path, 2106 uint32_t rights ) 2107 { 2108 assert( false , "not implemented %l %x %x", cwd_xp, path, rights ); 2202 uint32_t mode ) 2203 { 2204 error_t error; 2205 xptr_t parent_inode_xp; // extended pointer on parent inode in path 2206 xptr_t fifo_dentry_xp; // extended pointer on created dentry 2207 xptr_t fifo_inode_xp; // extended pointer on created inode 2208 cxy_t fifo_cxy; // selected cluster for fifo inode 2209 2210 char fifo_name[CONFIG_VFS_MAX_NAME_LENGTH]; 2211 2212 thread_t * this = CURRENT_THREAD; 2213 process_t * process = this->process; 2214 2215 // build extended pointer on lock protecting Inode Tree 2216 xptr_t vfs_root_xp = process->vfs_root_xp; 2217 vfs_inode_t * vfs_root_ptr = GET_PTR( vfs_root_xp ); 2218 cxy_t vfs_root_cxy = GET_CXY( vfs_root_xp ); 2219 xptr_t vfs_lock_xp = XPTR( vfs_root_cxy , &vfs_root_ptr->main_lock ); 2220 2221 // take the lock protecting the Inode-Tree in write mode 2222 remote_rwlock_wr_acquire( vfs_lock_xp ); 2223 2224 // 1. get extended pointer on parent inode and fifo name from vfs 2225 error = vfs_lookup( root_xp, 2226 path, 2227 VFS_LOOKUP_PARENT, 2228 &parent_inode_xp, 2229 fifo_name ); 2230 if( error ) 2231 { 2232 printk("\n[ERROR] in %s : cannot get parent inode for <%s> path\n", 2233 __FUNCTION__ , path ); 2234 return -1; 2235 } 2236 2237 // get parent inode cluster and local pointer 2238 cxy_t parent_cxy = GET_CXY( parent_inode_xp ); 2239 vfs_inode_t * parent_ptr = GET_PTR( parent_inode_xp ); 2240 2241 // 2. select a cluster for new fifo inode 2242 fifo_cxy = cluster_random_select(); 2243 2244 // get parent inode FS type 2245 vfs_ctx_t * ctx_ptr = hal_remote_lpt( XPTR( parent_cxy , &parent_ptr->ctx ) ); 2246 vfs_fs_type_t fs_type = hal_remote_l32( XPTR( parent_cxy , &ctx_ptr->type ) ); 2247 2248 // 3. insert a new inode and dentry in Inode-Tree 2249 error = vfs_add_child_in_parent( fifo_cxy, 2250 fs_type, 2251 parent_inode_xp, 2252 fifo_name, 2253 &fifo_dentry_xp, 2254 &fifo_inode_xp ); 2255 2256 // get fifo inode local pointer 2257 vfs_inode_t * fifo_inode_ptr = GET_PTR( fifo_inode_xp ); 2258 2259 if( error ) 2260 { 2261 printk("\n[ERROR] in %s : cannot create fifo inode for <%s> path\n", 2262 __FUNCTION__ , path ); 2263 return -1; 2264 } 2265 2266 // 4. allocate memory for a pipe descriptor, for the 2267 // remote_buf_t descriptor, and for the associated data buffer 2268 pipe_t * pipe = pipe_create( fifo_cxy, 2269 CONFIG_PIPE_BUF_SIZE ); 2270 if( pipe == NULL ) 2271 { 2272 printk("\n[ERROR] in %s : cannot create pipe for <%s> path\n", 2273 __FUNCTION__ , path ); 2274 return -1; 2275 } 2276 2277 // 5. update fifo_inode "type", "pipe", and "rights" fields 2278 hal_remote_s32( XPTR( fifo_cxy , &fifo_inode_ptr->type ) , FILE_TYPE_FIFO ); 2279 hal_remote_s32( XPTR( fifo_cxy , &fifo_inode_ptr->rights ) , mode ); 2280 hal_remote_spt( XPTR( fifo_cxy , &fifo_inode_ptr->pipe ) , pipe ); 2281 2282 // release the lock protecting the Inode-Tree from write mode 2283 remote_rwlock_wr_release( vfs_lock_xp ); 2284 2109 2285 return 0; 2110 } 2286 2287 } // end vfs_mkfifo() 2111 2288 2112 2289 … … 2126 2303 cxy_t inode_cxy; 2127 2304 vfs_inode_t * inode_ptr; 2128 vfs_ inode_type_t inode_type;2305 vfs_file_type_t inode_type; 2129 2306 uint32_t inode_size; 2130 2307 uint32_t inode_attr; … … 2159 2336 " " }; // level 15 2160 2337 2161 assert( (inode_xp != XPTR_NULL) , "inode_xp cannot be NULL" );2162 assert( (name_xp != XPTR_NULL) , "name_xp cannot be NULL" );2163 assert( (indent < 16) , "depth cannot be larger than 15" );2338 assert( __FUNCTION__, (inode_xp != XPTR_NULL) , "inode_xp cannot be NULL" ); 2339 assert( __FUNCTION__, (name_xp != XPTR_NULL) , "name_xp cannot be NULL" ); 2340 assert( __FUNCTION__, (indent < 16) , "depth cannot be larger than 15" ); 2164 2341 2165 2342 // get current inode cluster and local pointer … … 2187 2364 // scan directory entries when current inode is a directory 2188 2365 // don't scan the the "." and ".." directories to break loops 2189 if( (inode_type == INODE_TYPE_DIR) &&2366 if( (inode_type == FILE_TYPE_DIR) && 2190 2367 (strcmp( name , "." ) != 0) && 2191 2368 (strcmp( name , ".." ) != 0) ) … … 2449 2626 2450 2627 // check pathname / root_xp consistency 2451 assert( ((pathname[0] != '/') || (root_xp == process->vfs_root_xp)),2628 assert( __FUNCTION__, ((pathname[0] != '/') || (root_xp == process->vfs_root_xp)), 2452 2629 "root inode must be VFS root for path <%s>", pathname ); 2453 2630 2631 #if DEBUG_VFS_LOOKUP || DEBUG_VFS_ERROR 2632 uint32_t cycle = (uint32_t)hal_get_cycles(); 2633 #endif 2634 2454 2635 #if DEBUG_VFS_LOOKUP 2455 uint32_t cycle = (uint32_t)hal_get_cycles();2456 2636 char root_name[CONFIG_VFS_MAX_NAME_LENGTH]; 2457 2637 vfs_inode_get_name( root_xp , root_name ); … … 2564 2744 if( error ) 2565 2745 { 2566 printk("\n[ERROR] in %s : cannot create inode <%s> in path <%s>\n", 2567 __FUNCTION__ , name, pathname ); 2746 2747 #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 ); 2751 #endif 2568 2752 return -1; 2569 2753 } … … 2575 2759 #if (DEBUG_VFS_LOOKUP & 1) 2576 2760 if( DEBUG_VFS_LOOKUP < cycle ) 2577 printk("\n[%s] thread[%x,%x] created missinginode <%s> in cluster %x\n",2761 printk("\n[%s] thread[%x,%x] created dentry/inode <%s> in cluster %x\n", 2578 2762 __FUNCTION__, process->pid, this->trdid, name, child_cxy ); 2579 2763 #endif … … 2591 2775 if ( error ) 2592 2776 { 2593 printk("\n[ERROR] in %s : cannot add dentry <%s> in parent dir\n", 2594 __FUNCTION__, name ); 2777 2778 #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 ); 2782 #endif 2595 2783 vfs_remove_child_from_parent( dentry_xp ); 2596 2784 return -1; … … 2601 2789 printk("\n[%s] thread[%x,%x] child <%s> not found in parent mapper => created it\n", 2602 2790 __FUNCTION__, process->pid, this->trdid, name ); 2603 vfs_inode_display( child_xp );2604 2791 #endif 2605 2792 } 2606 2793 else // not last or not create => error 2607 2794 { 2608 printk("\n[ERROR] in %s : <%s> node not found in parent for <%s>\n", 2609 __FUNCTION__ , name , pathname ); 2795 2796 #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 ); 2800 #endif 2610 2801 vfs_remove_child_from_parent( dentry_xp ); 2611 2802 return -1; … … 2617 2808 if( last && create && excl ) 2618 2809 { 2619 printk("\n[ERROR] in %s : node already exist <%s>\n", 2620 __FUNCTION__, name ); 2810 2811 #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 ); 2815 #endif 2621 2816 return -1; 2622 2817 } … … 2629 2824 // load child mapper from device if child is a directory (prefetch) 2630 2825 uint32_t type = hal_remote_l32( XPTR( child_cxy , &child_ptr->type ) ); 2631 if( type == INODE_TYPE_DIR )2826 if( type == FILE_TYPE_DIR ) 2632 2827 { 2633 2828 error = vfs_inode_load_all_pages( child_xp ); … … 2635 2830 if ( error ) 2636 2831 { 2637 printk("\n[ERROR] in %s : cannot load <%s> from device\n", 2638 __FUNCTION__ , name ); 2832 #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 ); 2836 #endif 2639 2837 vfs_remove_child_from_parent( dentry_xp ); 2640 2838 return -1; … … 2664 2862 if( last && create && excl ) 2665 2863 { 2666 printk("\n[ERROR] in %s : node <%s> already exist\n", 2667 __FUNCTION__, name ); 2864 2865 #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 ); 2869 #endif 2668 2870 return -1; 2669 2871 } … … 2676 2878 // if( error ) 2677 2879 // { 2678 // printk("\n[ERROR] in %s : thread %x / permission denied for %s\n", 2679 // __FUNCTION__ , this , name ); 2680 // return EACCES; 2880 // #if DEBUG_VFS_ERROR 2881 // if( DEBUG_VFS_ERROR < cycle ) 2882 // printk("\n[ERROR] in %s : thread[%x,%x] / permission denied for <%s>\n", 2883 // __FUNCTION__ , process->pid, this->trdid , pathname ); 2884 // #endif 2885 // 2886 // return -1; 2681 2887 // } 2682 2888 … … 2983 3189 2984 3190 // check buffer overflow 2985 assert( (index >= 0) , "kernel buffer too small" );3191 assert( __FUNCTION__, (index >= 0) , "kernel buffer too small" ); 2986 3192 2987 3193 } … … 3009 3215 3010 3216 // check buffer overflow 3011 assert( (index >= 0) , "kernel buffer too small" );3217 assert( __FUNCTION__, (index >= 0) , "kernel buffer too small" ); 3012 3218 3013 3219 // update pathname … … 3067 3273 parent_inode_ptr = GET_PTR( parent_inode_xp ); 3068 3274 3275 #if DEBUG_VFS_ADD_CHILD || DEBUG_VFS_ERROR 3276 uint32_t cycle = (uint32_t)hal_get_cycles(); 3277 thread_t * this = CURRENT_THREAD; 3278 #endif 3279 3069 3280 #if DEBUG_VFS_ADD_CHILD 3070 3281 char parent_name[CONFIG_VFS_MAX_NAME_LENGTH]; 3071 3282 vfs_inode_get_name( parent_inode_xp , parent_name ); 3072 uint32_t cycle = (uint32_t)hal_get_cycles();3073 thread_t * this = CURRENT_THREAD;3074 3283 if( DEBUG_VFS_ADD_CHILD < cycle ) 3075 3284 printk("\n[%s] thread[%x,%x] enter / child <%s> / parent <%s> / cycle %d\n", … … 3085 3294 if( error ) 3086 3295 { 3087 printk("\n[ERROR] in %s : cannot create dentry <%s> in cluster %x\n", 3088 __FUNCTION__ , name , parent_cxy ); 3296 3297 #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 ); 3301 #endif 3089 3302 return -1; 3090 3303 } … … 3115 3328 if( error ) 3116 3329 { 3117 printk("\n[ERROR] in %s : cannot create inode in cluster %x\n", 3118 __FUNCTION__ , child_cxy ); 3330 3331 #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 ); 3335 #endif 3119 3336 3120 3337 vfs_dentry_destroy( new_dentry_xp ); … … 3184 3401 vfs_inode_t * parent_inode_ptr; // local pointer on parent inode 3185 3402 uint32_t links; // number of child inode parents 3403 error_t error; 3404 3405 #if DEBUG_VFS_REMOVE_CHILD 3406 uint32_t cycle = (uint32_t)hal_get_cycles(); 3407 #endif 3186 3408 3187 3409 char dentry_name[CONFIG_VFS_MAX_NAME_LENGTH]; 3188 3410 3411 thread_t * this = CURRENT_THREAD; 3412 3189 3413 // get parent cluster and dentry local pointer 3190 3414 parent_cxy = GET_CXY( dentry_xp ); … … 3203 3427 child_inode_ptr = GET_PTR( child_inode_xp ); 3204 3428 3429 #if DEBUG_VFS_REMOVE_CHILD 3430 if( DEBUG_VFS_REMOVE_CHILD < cycle ) 3431 printk("\n[%s] thread[%x,%x] enter for dentry[%x,%x] / inode[%x,%x] / cycle %d\n", 3432 __FUNCTION__, this->process->pid, this->trdid, 3433 parent_cxy, dentry_ptr, child_cxy, child_inode_ptr, cycle ); 3434 #endif 3435 3205 3436 // remove dentry from parent_inode 3206 xhtab_remove( XPTR( parent_cxy , &parent_inode_ptr->children ), 3207 dentry_name, 3208 XPTR( parent_cxy , &dentry_ptr->children ) ); 3437 error = xhtab_remove( XPTR( parent_cxy , &parent_inode_ptr->children ), 3438 dentry_name, 3439 XPTR( parent_cxy , &dentry_ptr->children ) ); 3440 3441 if( error ) 3442 { 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(); 3449 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 ); 3452 #endif 3209 3453 3210 3454 // remove dentry from child_inode 3211 3455 xlist_unlink( XPTR( parent_cxy , &dentry_ptr->parents ) ); 3456 3457 // get and update number of parents dentries 3212 3458 links = hal_remote_atomic_add( XPTR( child_cxy , &child_inode_ptr->links ) , -1 ); 3459 3460 #if DEBUG_VFS_REMOVE_CHILD 3461 cycle = (uint32_t)hal_get_cycles(); 3462 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 ); 3465 #endif 3213 3466 3214 3467 // delete dentry descriptor 3215 3468 vfs_dentry_destroy( dentry_xp ); 3216 3469 3470 #if DEBUG_VFS_REMOVE_CHILD 3471 cycle = (uint32_t)hal_get_cycles(); 3472 if( DEBUG_VFS_REMOVE_CHILD < cycle ) 3473 printk("\n[%s] thread[%x,%x] deleted dentry descriptor / cycle %d\n", 3474 __FUNCTION__, this->process->pid, this->trdid, cycle ); 3475 #endif 3476 3217 3477 // delete child_inode descriptor if last link 3218 if( links == 1 ) vfs_inode_destroy( child_inode_xp ); 3219 3478 if( links == 1 ) 3479 { 3480 vfs_inode_destroy( child_inode_xp ); 3481 3482 #if DEBUG_VFS_REMOVE_CHILD 3483 cycle = (uint32_t)hal_get_cycles(); 3484 if( DEBUG_VFS_REMOVE_CHILD < cycle ) 3485 printk("\n[%s] thread[%x,%x] deleted child inode descriptor / cycle %d\n", 3486 __FUNCTION__, this->process->pid, this->trdid, cycle ); 3487 #endif 3488 3489 } 3220 3490 } // end vfs_remove_child_from_parent() 3221 3491 … … 3233 3503 error_t error = 0; 3234 3504 3235 assert( (inode_xp != XPTR_NULL) , "inode_xp argument is NULL" );3236 assert( (dentry_ptr != NULL ) , "dentry_ptr argument is NULL" );3505 assert( __FUNCTION__, (inode_xp != XPTR_NULL) , "inode_xp argument is NULL" ); 3506 assert( __FUNCTION__, (dentry_ptr != NULL ) , "dentry_ptr argument is NULL" ); 3237 3507 3238 3508 vfs_inode_t * inode_ptr = GET_PTR( inode_xp ); … … 3242 3512 mapper_t * mapper = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->mapper ) ); 3243 3513 3244 assert( (mapper != NULL) , "mapper pointer is NULL")3514 assert( __FUNCTION__, (mapper != NULL) , "mapper pointer is NULL"); 3245 3515 3246 3516 // get FS type … … 3262 3532 else 3263 3533 { 3264 assert( false , "undefined file system type" );3534 assert( __FUNCTION__, false , "undefined file system type" ); 3265 3535 } 3266 3536 … … 3275 3545 error_t error = 0; 3276 3546 3277 assert( (inode_xp != XPTR_NULL) , "inode_xp argument is NULL" );3278 assert( (dentry_ptr != NULL ) , "dentry_ptr argument is NULL" );3547 assert( __FUNCTION__, (inode_xp != XPTR_NULL) , "inode_xp argument is NULL" ); 3548 assert( __FUNCTION__, (dentry_ptr != NULL ) , "dentry_ptr argument is NULL" ); 3279 3549 3280 3550 vfs_inode_t * inode_ptr = GET_PTR( inode_xp ); … … 3284 3554 mapper_t * mapper = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->mapper ) ); 3285 3555 3286 assert( (mapper != NULL) , "mapper pointer is NULL")3556 assert( __FUNCTION__, (mapper != NULL) , "mapper pointer is NULL"); 3287 3557 3288 3558 // get FS type … … 3305 3575 else 3306 3576 { 3307 assert( false , "undefined file system type" );3577 assert( __FUNCTION__, false , "undefined file system type" ); 3308 3578 } 3309 3579 … … 3318 3588 error_t error = 0; 3319 3589 3320 assert( (inode_xp != XPTR_NULL) , "inode_xp argument is NULL" );3321 assert( (dentry_ptr != NULL ) , "dentry_ptr argument is NULL" );3590 assert( __FUNCTION__, (inode_xp != XPTR_NULL) , "inode_xp argument is NULL" ); 3591 assert( __FUNCTION__, (dentry_ptr != NULL ) , "dentry_ptr argument is NULL" ); 3322 3592 3323 3593 vfs_inode_t * inode_ptr = GET_PTR( inode_xp ); … … 3327 3597 mapper_t * mapper = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->mapper ) ); 3328 3598 3329 assert( (mapper != NULL) , "mapper pointer is NULL")3599 assert( __FUNCTION__, (mapper != NULL) , "mapper pointer is NULL"); 3330 3600 3331 3601 // get FS type … … 3339 3609 else if( fs_type == FS_TYPE_RAMFS ) 3340 3610 { 3341 assert( false , "should not be called for RAMFS" );3611 assert( __FUNCTION__, false , "should not be called for RAMFS" ); 3342 3612 } 3343 3613 else if( fs_type == FS_TYPE_DEVFS ) 3344 3614 { 3345 assert( false , "should not be called for DEVFS" );3615 assert( __FUNCTION__, false , "should not be called for DEVFS" ); 3346 3616 } 3347 3617 else 3348 3618 { 3349 assert( false , "undefined file system type" );3619 assert( __FUNCTION__, false , "undefined file system type" ); 3350 3620 } 3351 3621 … … 3360 3630 error_t error = 0; 3361 3631 3362 assert( (inode_xp != XPTR_NULL) , "inode_xp argument is NULL" );3363 assert( (dentry_ptr != NULL ) , "dentry_ptr argument is NULL" );3632 assert( __FUNCTION__, (inode_xp != XPTR_NULL) , "inode_xp argument is NULL" ); 3633 assert( __FUNCTION__, (dentry_ptr != NULL ) , "dentry_ptr argument is NULL" ); 3364 3634 3365 3635 vfs_inode_t * inode_ptr = GET_PTR( inode_xp ); … … 3369 3639 mapper_t * mapper = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->mapper ) ); 3370 3640 3371 assert( (mapper != NULL) , "mapper pointer is NULL")3641 assert( __FUNCTION__, (mapper != NULL) , "mapper pointer is NULL"); 3372 3642 3373 3643 // get FS type … … 3381 3651 else if( fs_type == FS_TYPE_RAMFS ) 3382 3652 { 3383 assert( false , "should not be called for RAMFS" );3653 assert( __FUNCTION__, false , "should not be called for RAMFS" ); 3384 3654 } 3385 3655 else if( fs_type == FS_TYPE_DEVFS ) 3386 3656 { 3387 assert( false , "should not be called for DEVFS" );3657 assert( __FUNCTION__, false , "should not be called for DEVFS" ); 3388 3658 } 3389 3659 else 3390 3660 { 3391 assert( false , "undefined file system type" );3661 assert( __FUNCTION__, false , "undefined file system type" ); 3392 3662 } 3393 3663 … … 3402 3672 error_t error = 0; 3403 3673 3404 assert( (inode_xp != XPTR_NULL) , "inode_xp argument is NULL" );3405 assert( (dentry_ptr != NULL ) , "dentry_ptr argument is NULL" );3674 assert( __FUNCTION__, (inode_xp != XPTR_NULL) , "inode_xp argument is NULL" ); 3675 assert( __FUNCTION__, (dentry_ptr != NULL ) , "dentry_ptr argument is NULL" ); 3406 3676 3407 3677 vfs_inode_t * inode_ptr = GET_PTR( inode_xp ); … … 3411 3681 mapper_t * mapper = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->mapper ) ); 3412 3682 3413 assert( (mapper != NULL) , "mapper pointer is NULL")3683 assert( __FUNCTION__, (mapper != NULL) , "mapper pointer is NULL"); 3414 3684 3415 3685 // get FS type … … 3423 3693 else if( fs_type == FS_TYPE_RAMFS ) 3424 3694 { 3425 assert( false , "should not be called for RAMFS" );3695 assert( __FUNCTION__, false , "should not be called for RAMFS" ); 3426 3696 } 3427 3697 else if( fs_type == FS_TYPE_DEVFS ) 3428 3698 { 3429 assert( false , "should not be called for DEVFS" );3699 assert( __FUNCTION__, false , "should not be called for DEVFS" ); 3430 3700 } 3431 3701 else 3432 3702 { 3433 assert( false , "undefined file system type" );3703 assert( __FUNCTION__, false , "undefined file system type" ); 3434 3704 } 3435 3705 … … 3450 3720 3451 3721 // check arguments 3452 assert( (inode != NULL) , "parent pointer is NULL");3453 assert( (array != NULL) , "child pointer is NULL");3454 assert( (detailed == false) , "detailed argument not supported\n");3722 assert( __FUNCTION__, (inode != NULL) , "parent pointer is NULL"); 3723 assert( __FUNCTION__, (array != NULL) , "child pointer is NULL"); 3724 assert( __FUNCTION__, (detailed == false) , "detailed argument not supported\n"); 3455 3725 3456 3726 // check inode type 3457 if( inode->type != INODE_TYPE_DIR )3727 if( inode->type != FILE_TYPE_DIR ) 3458 3728 { 3459 3729 printk("\n[ERROR] in %s : target inode is not a directory\n", … … 3478 3748 else if( fs_type == FS_TYPE_RAMFS ) 3479 3749 { 3480 assert( false , "should not be called for RAMFS" );3750 assert( __FUNCTION__, false , "should not be called for RAMFS" ); 3481 3751 } 3482 3752 else if( fs_type == FS_TYPE_DEVFS ) … … 3492 3762 else 3493 3763 { 3494 assert( false , "undefined file system type" );3764 assert( __FUNCTION__, false , "undefined file system type" ); 3495 3765 } 3496 3766 … … 3504 3774 error_t error = 0; 3505 3775 3506 assert( (inode_xp != XPTR_NULL) , "inode_xp argument is NULL");3776 assert( __FUNCTION__, (inode_xp != XPTR_NULL) , "inode_xp argument is NULL"); 3507 3777 3508 3778 vfs_inode_t * inode_ptr = GET_PTR( inode_xp ); … … 3512 3782 mapper_t * mapper = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->mapper ) ); 3513 3783 3514 assert( (mapper != NULL) , "mapper pointer is NULL")3784 assert( __FUNCTION__, (mapper != NULL) , "mapper pointer is NULL"); 3515 3785 3516 3786 // get FS type … … 3524 3794 else if( fs_type == FS_TYPE_RAMFS ) 3525 3795 { 3526 assert( false , "should not be called for RAMFS" );3796 assert( __FUNCTION__, false , "should not be called for RAMFS" ); 3527 3797 } 3528 3798 else if( fs_type == FS_TYPE_DEVFS ) 3529 3799 { 3530 assert( false , "should not be called for DEVFS" );3800 assert( __FUNCTION__, false , "should not be called for DEVFS" ); 3531 3801 } 3532 3802 else 3533 3803 { 3534 assert( false , "undefined file system type" );3804 assert( __FUNCTION__, false , "undefined file system type" ); 3535 3805 } 3536 3806 … … 3551 3821 else if( fs_type == FS_TYPE_RAMFS ) 3552 3822 { 3553 assert( false , "should not be called for RAMFS" );3823 assert( __FUNCTION__, false , "should not be called for RAMFS" ); 3554 3824 } 3555 3825 else if( fs_type == FS_TYPE_DEVFS ) 3556 3826 { 3557 assert( false , "should not be called for DEVFS" );3827 assert( __FUNCTION__, false , "should not be called for DEVFS" ); 3558 3828 } 3559 3829 else 3560 3830 { 3561 assert( false , "undefined file system type" );3831 assert( __FUNCTION__, false , "undefined file system type" ); 3562 3832 } 3563 3833 … … 3571 3841 error_t error = 0; 3572 3842 3573 assert( (inode_xp != XPTR_NULL) , "inode_xp argument is NULL")3843 assert( __FUNCTION__, (inode_xp != XPTR_NULL) , "inode_xp argument is NULL"); 3574 3844 3575 3845 vfs_inode_t * inode_ptr = GET_PTR( inode_xp ); … … 3579 3849 mapper_t * mapper = hal_remote_lpt( XPTR( inode_cxy , &inode_ptr->mapper ) ); 3580 3850 3581 assert( (mapper != NULL) , "mapper pointer is NULL")3851 assert( __FUNCTION__, (mapper != NULL) , "mapper pointer is NULL"); 3582 3852 3583 3853 // get FS type from mapper … … 3591 3861 else if( fs_type == FS_TYPE_RAMFS ) 3592 3862 { 3593 assert( false , "should not be called for RAMFS" );3863 assert( __FUNCTION__, false , "should not be called for RAMFS" ); 3594 3864 } 3595 3865 else if( fs_type == FS_TYPE_DEVFS ) 3596 3866 { 3597 assert( false , "should not be called for DEVFS" );3867 assert( __FUNCTION__, false , "should not be called for DEVFS" ); 3598 3868 } 3599 3869 else 3600 3870 { 3601 assert( false , "undefined file system type" );3871 assert( __FUNCTION__, false , "undefined file system type" ); 3602 3872 } 3603 3873 … … 3612 3882 error_t error = 0; 3613 3883 3614 assert( (page_xp != XPTR_NULL) , "page pointer is NULL" );3884 assert( __FUNCTION__, (page_xp != XPTR_NULL) , "page pointer is NULL" ); 3615 3885 3616 3886 page_t * page_ptr = GET_PTR( page_xp ); … … 3620 3890 mapper_t * mapper = hal_remote_lpt( XPTR( page_cxy , &page_ptr->mapper ) ); 3621 3891 3622 assert( (mapper != NULL) , "no mapper for page" );3892 assert( __FUNCTION__, (mapper != NULL) , "no mapper for page" ); 3623 3893 3624 3894 // get FS type … … 3632 3902 else if( fs_type == FS_TYPE_RAMFS ) 3633 3903 { 3634 assert( false , "should not be called for RAMFS\n" );3904 assert( __FUNCTION__, false , "should not be called for RAMFS\n" ); 3635 3905 } 3636 3906 else if( fs_type == FS_TYPE_DEVFS ) 3637 3907 { 3638 assert( false , "should not be called for DEVFS\n" );3908 assert( __FUNCTION__, false , "should not be called for DEVFS\n" ); 3639 3909 } 3640 3910 else 3641 3911 { 3642 assert( false , "undefined file system type" );3912 assert( __FUNCTION__, false , "undefined file system type" ); 3643 3913 } 3644 3914 -
trunk/kernel/fs/vfs.h
r657 r673 3 3 * 4 4 * Author Mohamed Lamine Karaoui (2014,2015) 5 * Alain Greiner (2016,2017,2018,2019,2020)5 * Alain Greiner (2016,2017,2018,2019,2020) 6 6 * 7 7 * Copyright (c) UPMC Sorbonne Universites … … 49 49 struct vfs_ctx_s; 50 50 struct vfs_file_s; 51 51 struct remote_buf_s; 52 52 struct mapper_s; 53 53 struct process_s; … … 66 66 #define VFS_LOOKUP_CREATE 0x10 /* file must be created if missing */ 67 67 #define VFS_LOOKUP_EXCL 0x20 /* file cannot previously exist */ 68 69 70 68 71 69 72 /****************************************************************************************** … … 105 108 } 106 109 vfs_ctx_t; 110 111 /****************************************************************************************** 112 * These functions access / modify a VFS context. 113 *****************************************************************************************/ 114 115 /****************************************************************************************** 116 * This function initialises a (statically allocated) VFS context in cluster identified 117 * by the <cxy> argument. 118 * It is called by the kernel_init() function. 119 ****************************************************************************************** 120 * @ cxy : target cluster identifier. 121 * @ fs_type : file system type. 122 * @ total_clusters : total number of clusters on device. 123 * @ cluster_size : cluster size on device (bytes). 124 * @ vfs_root_xp : extended pointer on VFS root inode. 125 * @ extend : fs_type_specific extension. 126 *****************************************************************************************/ 127 void vfs_ctx_init( cxy_t cxy, 128 vfs_fs_type_t type, 129 uint32_t total_clusters, 130 uint32_t cluster_size, 131 xptr_t vfs_root_xp, 132 void * extend ); 133 134 /****************************************************************************************** 135 * This function allocates an inode identifier from the local cluster inum allocator. 136 * The inum respects a fixed format: 137 * - the 16 MSB bits contain the cluster identifier : cxy 138 * - the 16 LSB bits contains the local inode identifier : lid 139 ****************************************************************************************** 140 * @ ctx_xp : [in] extended pointer on file system context. 141 * @ inum : [out] buffer for allocated inode identifier. 142 * @ return 0 if success / return non-zero if error. 143 *****************************************************************************************/ 144 error_t vfs_ctx_inum_alloc( xptr_t ctx_xp, 145 uint32_t * inum ); 146 147 /****************************************************************************************** 148 * This function release an inode identifier. 149 ****************************************************************************************** 150 * @ ctx_xp : [in] extended pointer on file system context. 151 * @ inum : [in] released inode identifier. 152 *****************************************************************************************/ 153 void vfs_ctx_inum_release( xptr_t ctx_xp, 154 uint32_t inum ); 155 156 157 158 159 160 161 /****************************************************************************************** 162 * This file structure describes an open file/directory for a given process. 163 * It is not replicated, and is dynamically allocated in the cluster that contains 164 * the associated inode / socket / pipe , when a thread makes an open(), opendir(), 165 * socket(), or pipe() system call. It cannot exist a <file> structure without a 166 * a <mapper>, <socket>, or <pipe> structure (depending on type) in same cluster. 167 * It can exist a <file> structure without an <inode> (for PIPE and SOCK types). 168 *****************************************************************************************/ 169 170 /* this enum define the VFS inode types values */ 171 /* WARNING : this enum must be kept consistent with macros in <shared_stat.h> file */ 172 /* and with types in <shared_dirent.h> file. */ 173 174 typedef enum 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 */ 184 } 185 vfs_file_type_t; 186 187 typedef enum 188 { 189 FD_ATTR_READ_ENABLE = 0x01, /*! read access possible */ 190 FD_ATTR_WRITE_ENABLE = 0x02, /*! write access possible */ 191 FD_ATTR_APPEND = 0x04, /*! append on each write */ 192 FD_ATTR_CLOSE_EXEC = 0x08, /*! close file on exec */ 193 FD_ATTR_SYNC = 0x10, /*! synchronise FS on each write */ 194 FD_ATTR_IS_DIR = 0x20, /*! this is a directory */ 195 } 196 vfs_file_attr_t; 197 198 typedef struct vfs_file_s 199 { 200 struct vfs_ctx_s * ctx; /*! local pointer on FS context. */ 201 vfs_file_attr_t attr; /*! file attributes bit vector (see above) */ 202 vfs_file_type_t type; /*! same type as inode */ 203 uint32_t offset; /*! seek position in file */ 204 remote_rwlock_t lock; /*! protect offset modifications */ 205 struct vfs_inode_s * inode; /*! local pointer on associated inode */ 206 struct mapper_s * mapper; /*! associated mapper (REG or DIR types only) */ 207 struct socket_s * socket; /*! associated socket (SOCK type only) */ 208 struct pipe_s * pipe; /*! associated pipe (FIFO or PIPE types only) */ 209 void * extend; /*! FS specific extension */ 210 } 211 vfs_file_t; 212 213 /****************************************************************************************** 214 * These low-level functions access / modify a VFS file descriptor 215 *****************************************************************************************/ 216 217 /****************************************************************************************** 218 * This function allocates memory and initializes a new file descriptor in the 219 * cluster defined by the <inode_xp> argument. 220 * It can be called by any thread running in any cluster. 221 ****************************************************************************************** 222 * @ inode_xp : [in] extended pointer on associated inode. 223 * @ attr : [in] file descriptor attributes. 224 * @ file_xp : [out] buffer for extended pointer on created file descriptor. 225 * @ return 0 if success / return ENOMEM if error. 226 *****************************************************************************************/ 227 error_t vfs_file_create( xptr_t inode_xp, 228 uint32_t attr, 229 xptr_t * file_xp ); 230 231 /****************************************************************************************** 232 * This function releases memory allocated to file descriptor identified 233 * by the <file_xp> argument. 234 * It can be called by any thread running in any cluster. 235 ****************************************************************************************** 236 * @ file_xp : [in] extended pointer on file descriptor. 237 *****************************************************************************************/ 238 void vfs_file_destroy( xptr_t file_xp ); 239 240 /****************************************************************************************** 241 * This debug function copies the name of a the file identified by <file_xp> 242 * argument to a local buffer identified by the <name> argument. 243 * The local buffer size must be at least CONFIG_VFS_MAX_NAME_LENGTH. 244 ***************************************************************************************** 245 * @ ionde_xp : [in] extended pointer on the remote inode. 246 * @ name : [out] local string. 247 ***************************************************************************************/ 248 void vfs_file_get_name( xptr_t inode_xp, 249 char * name ); 250 251 252 107 253 108 254 /****************************************************************************************** … … 124 270 *****************************************************************************************/ 125 271 126 /* this enum define the VFS inode types values */127 /* WARNING : this enum must be kept consistent with macros in <shared_stat.h> file */128 /* and with types in <shared_dirent.h> file. */129 130 typedef enum131 {132 INODE_TYPE_FILE = 0, /*! regular file */133 INODE_TYPE_DIR = 1, /*! directory */134 INODE_TYPE_FIFO = 2, /*! POSIX named pipe */135 INODE_TYPE_PIPE = 3, /*! POSIX anonymous pipe */136 INODE_TYPE_SOCK = 4, /*! POSIX socket */137 INODE_TYPE_DEV = 5, /*! character device */138 INODE_TYPE_BLK = 6, /*! block device */139 INODE_TYPE_SYML = 7, /*! symbolic link */140 }141 vfs_inode_type_t;142 143 272 /* this enum define the VFS inode attributes values */ 144 273 … … 153 282 typedef struct vfs_inode_s 154 283 { 155 struct vfs_ctx_s * ctx; /*! local pointer on FS context */ 156 uint32_t inum; /*! inode identifier (unique in file system) */ 157 uint32_t attr; /*! inode attributes (see above) */ 158 vfs_inode_type_t type; /*! inode type (see above) */ 159 uint32_t size; /*! number of bytes */ 160 uint32_t uid; /*! user owner identifier */ 161 uint32_t gid; /*! group owner identifier */ 162 uint32_t rights; /*! access rights */ 163 xlist_entry_t parents; /*! root of list of parents dentries */ 164 uint32_t links; /*! number of parent dentries (hard links) */ 165 xhtab_t children; /*! embedded xhtab of children dentries */ 166 remote_rwlock_t size_lock; /*! protect read/write to size */ 167 remote_rwlock_t main_lock; /*! protect inode tree traversal and modifs */ 168 struct mapper_s * mapper; /*! associated file cache */ 169 void * extend; /*! fs_type_specific inode extension */ 284 struct vfs_ctx_s * ctx; /*! local pointer on FS context */ 285 uint32_t inum; /*! inode identifier (unique in file system) */ 286 uint32_t attr; /*! inode attributes (see above) */ 287 vfs_file_type_t type; /*! inode type (see above) */ 288 uint32_t size; /*! number of bytes */ 289 uint32_t uid; /*! user owner identifier */ 290 uint32_t gid; /*! group owner identifier */ 291 uint32_t rights; /*! access rights */ 292 xlist_entry_t parents; /*! root of list of parents dentries */ 293 uint32_t links; /*! number of parent dentries (hard links) */ 294 xhtab_t children; /*! embedded xhtab of children dentries */ 295 remote_rwlock_t size_lock; /*! protect read/write to size */ 296 remote_rwlock_t main_lock; /*! protect inode tree traversal and modifs */ 297 struct mapper_s * mapper; /*! associated file (REG or DIR types only) */ 298 struct remote_buf_s * pipe; /*! associated pipe (FIFO type only) */ 299 void * extend; /*! fs_type_specific inode extension */ 170 300 } 171 301 vfs_inode_t; … … 191 321 #define VFS_IWOTH 0x0000002 192 322 #define VFS_IXOTH 0x0000001 323 324 /****************************************************************************************** 325 * These low-level functions access / modify a VFS inode descriptor 326 *****************************************************************************************/ 327 328 /****************************************************************************************** 329 * This function returns a printable string for the inode type. 330 *****************************************************************************************/ 331 const char * vfs_inode_type_str( vfs_file_type_t type ); 332 333 /****************************************************************************************** 334 * This function allocates memory in cluster identified by the <cxy> argument 335 * for an inode descriptor and for the associated mapper, and partially initialise 336 * this inode from arguments values. 337 * It does NOT link it to the Inode Tree, as this is done by add_child_in_parent(). 338 * It can be called by any thread running in any cluster. 339 ****************************************************************************************** 340 * @ cxy : [in] target cluster identifier 341 * @ fs_type : [in] file system type. 342 * @ attr : [in] inode attributes. 343 * @ rights : [in] inode access rights. 344 * @ uid : [in] user owner ID. 345 * @ gid : [in] group owner ID. 346 * @ inode_xp : [out] buffer for extended pointer on created inode. 347 * @ return 0 if success / return -1 if error. 348 *****************************************************************************************/ 349 error_t vfs_inode_create( cxy_t cxy, 350 vfs_fs_type_t fs_type, 351 uint32_t attr, 352 uint32_t rights, 353 uid_t uid, 354 gid_t gid, 355 xptr_t * inode_xp ); 356 357 /****************************************************************************************** 358 * This function releases memory allocated to an inode descriptor, including 359 * all memory allocated to the mapper (both mapper descriptor and radix tree). 360 * The mapper should not contain any dirty page (should be synchronized before deletion). 361 * It can be called by any thread running in any cluster. 362 ****************************************************************************************** 363 * @ inode_xp : extended pointer on inode descriptor. 364 *****************************************************************************************/ 365 void vfs_inode_destroy( xptr_t inode_xp ); 366 367 /****************************************************************************************** 368 * This function returns the <size> of a file/dir from a remote inode, 369 * taking the remote_rwlock protecting <size> in READ_MODE. 370 * It can be called by any thread running in any cluster. 371 ***************************************************************************************** 372 * @ inode_xp : extended pointer on the remote inode. 373 * @ return the current size. 374 *****************************************************************************************/ 375 uint32_t vfs_inode_get_size( xptr_t inode_xp ); 376 377 /****************************************************************************************** 378 * This function updates the "size" field of a remote inode identified by <inode_xp>. 379 * It takes the rwlock protecting the file size in WRITE_MODE, and set the "size" field 380 * when the current size is smaller than the requested <size> argument. 381 * It can be called by any thread running in any cluster. 382 ***************************************************************************************** 383 * @ inode_xp : extended pointer on the remote inode. 384 * @ size : requested size value. 385 *****************************************************************************************/ 386 void vfs_inode_update_size( xptr_t inode_xp, 387 uint32_t size ); 388 389 /****************************************************************************************** 390 * This function takes the main lock of a remote inode identified by the <inode_xp>. 391 * This lock protect all inode fields, including the children dentries. 392 * It can be called by any thread running in any cluster. 393 ***************************************************************************************** 394 * @ inode_xp : extended pointer on the remote inode. 395 *****************************************************************************************/ 396 void vfs_inode_lock( xptr_t inode_xp ); 397 398 /****************************************************************************************** 399 * This function releases the main lock of a remote inode identified by <inode_xp>. 400 * This lock protect all inode fiels, including the children dentries. 401 * It can be called by any thread running in any cluster. 402 ***************************************************************************************** 403 * @ inode_xp : extended pointer on the remote inode. 404 *****************************************************************************************/ 405 void vfs_inode_unlock( xptr_t inode_xp ); 406 407 /****************************************************************************************** 408 * This debug function copies the name of a remote inode identified by the <inode_xp> 409 * argument to a local buffer identified by the <name> argument. 410 * The local buffer size must be at least CONFIG_VFS_MAX_NAME_LENGTH. 411 * It can be called by any thread running in any cluster. 412 ****************************************************************************************** 413 * @ inode_xp : extended pointer on the remote inode. 414 * @ name : local buffer pointer. 415 *****************************************************************************************/ 416 void vfs_inode_get_name( xptr_t inode_xp, 417 char * name ); 418 419 /****************************************************************************************** 420 * This function accesses successively all pages of a file identified by the <inode_xp>, 421 * argument, to force misses, and load all pages into mapper. 422 * The target inode can be a directory or a file, but this function is mainly used 423 * to prefetch a complete directory to the mapper. 424 * This function does NOT take any lock. 425 * It can be called by any thread running in any cluster. 426 ****************************************************************************************** 427 * @ inode_xp : extended pointer on inode. 428 * @ return 0 if success / return -1 if device access failure. 429 *****************************************************************************************/ 430 error_t vfs_inode_load_all_pages( xptr_t inode_xp ); 431 432 /****************************************************************************************** 433 * This debug function display the curren state of an inode descriptor. 434 * It can be called by any thread running in any cluster. 435 *****************************************************************************************/ 436 void vfs_inode_display( xptr_t inode_xp ); 437 438 439 440 441 193 442 194 443 /****************************************************************************************** … … 215 464 216 465 /****************************************************************************************** 217 * This file structure describes an open file/directory for a given process.218 * It is not replicated, and is dynamically allocated in the cluster that contains219 * the inode, when a thread makes an open() or opendir() system call.220 * It cannot exist a file structure without an inode structure in same cluster.221 * As the fd_array (containing extended pointers on the open file descriptors)222 * is replicated in all process descriptors, we need a references counter.223 *****************************************************************************************/224 225 typedef enum226 {227 FD_ATTR_READ_ENABLE = 0x01, /*! read access possible */228 FD_ATTR_WRITE_ENABLE = 0x02, /*! write access possible */229 FD_ATTR_APPEND = 0x04, /*! append on each write */230 FD_ATTR_CLOSE_EXEC = 0x08, /*! close file on exec */231 FD_ATTR_SYNC = 0x10, /*! synchronise FS on each write */232 FD_ATTR_IS_DIR = 0x20, /*! this is a directory */233 }234 vfs_file_attr_t;235 236 typedef struct vfs_file_s237 {238 struct vfs_ctx_s * ctx; /*! local pointer on FS context. */239 vfs_file_attr_t attr; /*! file attributes bit vector (see above) */240 vfs_inode_type_t type; /*! same type as inode */241 uint32_t offset; /*! seek position in file */242 uint32_t refcount; /*! all pointers on this file descriptor */243 remote_rwlock_t lock; /*! protect offset modifications */244 struct mapper_s * mapper; /*! associated file cache */245 struct vfs_inode_s * inode; /*! local pointer on associated inode */246 struct socket_s * socket; /*! local pointer on associated socket */247 void * extend; /*! FS specific extension */248 }249 vfs_file_t;250 251 252 /******************************************************************************************253 * These functions access / modify a VFS context.254 *****************************************************************************************/255 256 /******************************************************************************************257 * This function initialises a (statically allocated) VFS context in cluster identified258 * by the <cxy> argument.259 * It is called by the kernel_init() function.260 ******************************************************************************************261 * @ cxy : target cluster identifier.262 * @ fs_type : file system type.263 * @ total_clusters : total number of clusters on device.264 * @ cluster_size : cluster size on device (bytes).265 * @ vfs_root_xp : extended pointer on VFS root inode.266 * @ extend : fs_type_specific extension.267 *****************************************************************************************/268 void vfs_ctx_init( cxy_t cxy,269 vfs_fs_type_t type,270 uint32_t total_clusters,271 uint32_t cluster_size,272 xptr_t vfs_root_xp,273 void * extend );274 275 /******************************************************************************************276 * This function allocates an inode identifier from the local cluster inum allocator.277 * The inum respects a fixed format:278 * - the 16 MSB bits contain the cluster identifier : cxy279 * - the 16 LSB bits contains the local inode identifier : lid280 ******************************************************************************************281 * @ ctx_xp : [in] extended pointer on file system context.282 * @ inum : [out] buffer for allocated inode identifier.283 * @ return 0 if success / return non-zero if error.284 *****************************************************************************************/285 error_t vfs_ctx_inum_alloc( xptr_t ctx_xp,286 uint32_t * inum );287 288 /******************************************************************************************289 * This function release an inode identifier.290 ******************************************************************************************291 * @ ctx_xp : [in] extended pointer on file system context.292 * @ inum : [in] released inode identifier.293 *****************************************************************************************/294 void vfs_ctx_inum_release( xptr_t ctx_xp,295 uint32_t inum );296 297 298 299 /******************************************************************************************300 * These low-level functions access / modify a VFS inode descriptor301 *****************************************************************************************/302 303 /******************************************************************************************304 * This function returns a printable string for the inode type.305 *****************************************************************************************/306 const char * vfs_inode_type_str( vfs_inode_type_t type );307 308 /******************************************************************************************309 * This function allocates memory in cluster identified by the <cxy> argument310 * for an inode descriptor and for the associated mapper, and partially initialise311 * this inode from arguments values.312 * It does NOT link it to the Inode Tree, as this is done by add_child_in_parent().313 * It can be called by any thread running in any cluster.314 ******************************************************************************************315 * @ cxy : [in] target cluster identifier316 * @ fs_type : [in] file system type.317 * @ attr : [in] inode attributes.318 * @ rights : [in] inode access rights.319 * @ uid : [in] user owner ID.320 * @ gid : [in] group owner ID.321 * @ inode_xp : [out] buffer for extended pointer on created inode.322 * @ return 0 if success / return -1 if error.323 *****************************************************************************************/324 error_t vfs_inode_create( cxy_t cxy,325 vfs_fs_type_t fs_type,326 uint32_t attr,327 uint32_t rights,328 uid_t uid,329 gid_t gid,330 xptr_t * inode_xp );331 332 /******************************************************************************************333 * This function releases memory allocated to an inode descriptor, including334 * all memory allocated to the mapper (both mapper descriptor and radix tree).335 * The mapper should not contain any dirty page (should be synchronized before deletion).336 * It can be called by any thread running in any cluster.337 ******************************************************************************************338 * @ inode_xp : extended pointer on inode descriptor.339 *****************************************************************************************/340 void vfs_inode_destroy( xptr_t inode_xp );341 342 /******************************************************************************************343 * This function returns the <size> of a file/dir from a remote inode,344 * taking the remote_rwlock protecting <size> in READ_MODE.345 * It can be called by any thread running in any cluster.346 *****************************************************************************************347 * @ inode_xp : extended pointer on the remote inode.348 * @ return the current size.349 *****************************************************************************************/350 uint32_t vfs_inode_get_size( xptr_t inode_xp );351 352 /******************************************************************************************353 * This function updates the "size" field of a remote inode identified by <inode_xp>.354 * It takes the rwlock protecting the file size in WRITE_MODE, and set the "size" field355 * when the current size is smaller than the requested <size> argument.356 * It can be called by any thread running in any cluster.357 *****************************************************************************************358 * @ inode_xp : extended pointer on the remote inode.359 * @ size : requested size value.360 *****************************************************************************************/361 void vfs_inode_update_size( xptr_t inode_xp,362 uint32_t size );363 364 /******************************************************************************************365 * This function takes the main lock of a remote inode identified by the <inode_xp>.366 * This lock protect all inode fields, including the children dentries.367 * It can be called by any thread running in any cluster.368 *****************************************************************************************369 * @ inode_xp : extended pointer on the remote inode.370 *****************************************************************************************/371 void vfs_inode_lock( xptr_t inode_xp );372 373 /******************************************************************************************374 * This function releases the main lock of a remote inode identified by <inode_xp>.375 * This lock protect all inode fiels, including the children dentries.376 * It can be called by any thread running in any cluster.377 *****************************************************************************************378 * @ inode_xp : extended pointer on the remote inode.379 *****************************************************************************************/380 void vfs_inode_unlock( xptr_t inode_xp );381 382 /******************************************************************************************383 * This debug function copies the name of a remote inode identified by the <inode_xp>384 * argument to a local buffer identified by the <name> argument.385 * The local buffer size must be at least CONFIG_VFS_MAX_NAME_LENGTH.386 * It can be called by any thread running in any cluster.387 ******************************************************************************************388 * @ inode_xp : extended pointer on the remote inode.389 * @ name : local buffer pointer.390 *****************************************************************************************/391 void vfs_inode_get_name( xptr_t inode_xp,392 char * name );393 394 /******************************************************************************************395 * This function accesses successively all pages of a file identified by the <inode_xp>,396 * argument, to force misses, and load all pages into mapper.397 * The target inode can be a directory or a file, but this function is mainly used398 * to prefetch a complete directory to the mapper.399 * This function does NOT take any lock.400 * It can be called by any thread running in any cluster.401 ******************************************************************************************402 * @ inode_xp : extended pointer on inode.403 * @ return 0 if success / return -1 if device access failure.404 *****************************************************************************************/405 error_t vfs_inode_load_all_pages( xptr_t inode_xp );406 407 /******************************************************************************************408 * This debug function display the curren state of an inode descriptor.409 * It can be called by any thread running in any cluster.410 *****************************************************************************************/411 void vfs_inode_display( xptr_t inode_xp );412 413 /******************************************************************************************414 466 * These low-level functions access / modify a VFS dentry descriptor 415 467 *****************************************************************************************/ … … 442 494 443 495 444 /****************************************************************************************** 445 * These low-level functions access / modify a VFS file descriptor 446 *****************************************************************************************/ 447 448 /****************************************************************************************** 449 * This function allocates memory and initializes a new file descriptor in the 450 * cluster defined by the <inode_xp> argument. 451 * It can be called by any thread running in any cluster. 452 ****************************************************************************************** 453 * @ inode_xp : [in] extended pointer on associated inode. 454 * @ attr : [in] file descriptor attributes. 455 * @ file_xp : [out] buffer for extended pointer on created file descriptor. 456 * @ return 0 if success / return ENOMEM if error. 457 *****************************************************************************************/ 458 error_t vfs_file_create( xptr_t inode_xp, 459 uint32_t attr, 460 xptr_t * file_xp ); 461 462 /****************************************************************************************** 463 * This function releases memory allocated to file descriptor identified 464 * by the <file_xp> argument. 465 * It can be called by any thread running in any cluster. 466 ****************************************************************************************** 467 * @ file_xp : [in] extended pointer on file descriptor. 468 *****************************************************************************************/ 469 void vfs_file_destroy( xptr_t file_xp ); 470 471 /****************************************************************************************** 472 * These functions increment (resp. decrement) the count field in a remote file 473 * descriptor, using a remote_atomic access. 474 ***************************************************************************************** 475 * @ file_xp : extended pointer on file descriptor. 476 *****************************************************************************************/ 477 void vfs_file_count_up ( xptr_t file_xp ); 478 void vfs_file_count_down( xptr_t file_xp ); 479 480 /****************************************************************************************** 481 * This debug function copies the name of a the file identified by <file_xp> 482 * argument to a local buffer identified by the <name> argument. 483 * The local buffer size must be at least CONFIG_VFS_MAX_NAME_LENGTH. 484 ***************************************************************************************** 485 * @ ionde_xp : [in] extended pointer on the remote inode. 486 * @ name : [out] local string. 487 ***************************************************************************************/ 488 void vfs_file_get_name( xptr_t inode_xp, 489 char * name ); 496 497 490 498 491 499 … … 532 540 * the missing dentry/inode couple, from informations found in the parent directory. 533 541 * - If this directory entry does not exist on IOC, it returns an error. 534 * - If the thefile identified by the pathname does not exist on IOC but the542 * - If the file identified by the pathname does not exist on IOC but the 535 543 * flag CREATE is set, the inode is created. It returns an error otherwise. 536 544 * - If the the file identified by the pathname exist on device, but both flags EXCL … … 539 547 * inode, and copies in <last_name> buffer a string containing the last name in path. 540 548 * 541 * WARNING : The remote_rwlock protecting the Inode Tree must be takenby the caller.549 * WARNING : The lock protecting the Inode Tree must be taken in read mode by the caller. 542 550 * 543 551 * TODO the access rights are not checked yet. … … 558 566 /****************************************************************************************** 559 567 * This function creates a new couple dentry/inode, and insert it in the Inode-Tree. 560 * Only the distributed Inode 568 * Only the distributed Inode-Tree is modified: it does NOT modify the parent mapper, 561 569 * and does NOT update the FS on IOC device. 562 * It set the inode type to the default INODE_TYPE_FILE value570 * It set the inode type to the default FILE_TYPE_REG value. 563 571 * It can be executed by any thread running in any cluster (can be different from both 564 572 * the child cluster and the parent cluster). 565 573 * The new child inode and the parent inode can have different FS types. 566 * [Implementation note] 574 * 575 * WARNING : The lock protecting the Inode Tree must be taken in write mode by the caller. 576 ****************************************************************************************** 577 * Implementation note 567 578 * As there are cross-references between inode and dentry, this function implements 568 579 * a five steps scenario : … … 591 602 592 603 /****************************************************************************************** 593 * This function removes a remote dentry from the Inode-Tree.604 * This function removes a remote dentry and the associated inode from the Inode-Tree. 594 605 * - It removes the dentry from the parent inode xhtab ("children" field), and from the 595 606 * child inode xlist ("parents" field). … … 601 612 * It can be executed by any thread running in any cluster (can be different from both 602 613 * the inode cluster and the dentry cluster). 614 * 615 * WARNING : The lock protecting the Inode Tree must be taken in write mode by the caller. 603 616 ****************************************************************************************** 604 617 * @ dentry_xp : extended pointer on removed dentry. … … 613 626 * This function is called by all functions creating a brand new directory : vfs_mkdir(), 614 627 * devfs_global_init(), and devfs_local_init(). 628 * 629 * WARNING : The lock protecting the Inode Tree must be taken in write mode by the caller. 615 630 ****************************************************************************************** 616 631 * @ child_xp : extended pointer on new directory inode. … … 624 639 * This recursive function diplays a complete inode/dentry sub-tree. 625 640 * Any inode can be selected as the sub-tree root. 626 * WARNING : this function is not protected against a concurrent inode/dentry removal... 641 * 642 * TODO : this function should be protected against a concurrent Inode-Tree change. 627 643 ****************************************************************************************** 628 644 * @ inode_xp : extended pointer on sub-tree root inode. … … 632 648 /****************************************************************************************** 633 649 * This function mount a given file system type for a given process 634 * TODO non implemented yet[AG].650 * TODO non implemented [AG]. 635 651 *****************************************************************************************/ 636 652 error_t vfs_mount_fs_root( struct device_s * device, … … 829 845 830 846 /****************************************************************************************** 831 * This function creates a new directory as defined by the <root_xp> & <path> arguments.832 * TODO not implemented yet...847 * This function creates a new inode/dentry couple for a new directory, and registers it 848 * in the Inode Tree, as defined by the <root_xp>, <path>, and <mode> arguments. 833 849 ****************************************************************************************** 834 850 * @ root_xp : extended pointer on the path root directory. … … 855 871 * This function change the access rigths for the file/directory identified by the 856 872 * <root_xp> and <path> arguments as defined by the <mode> argument value. 873 * TODO not implemented yet 857 874 ****************************************************************************************** 858 875 * @ root_xp : extended pointer on the path root directory. … … 866 883 867 884 /****************************************************************************************** 868 * This function creates a n amed FIFO file.869 * TODO not implemented yet885 * This function creates a new inode/dentry couple of FIFO type, and registers it 886 * in the Inode Tree as specified by the <root_xp>, <path>, and <mode> arguments. 870 887 ****************************************************************************************** 871 * @ root_xp : extended pointer on the path root directory.872 * @ path : pathname (absolute or relative to CWD).873 * @ mode : access rights new value.888 * @ root_xp : [in] extended pointer on the root directory in path. 889 * @ path : [in] pathname (absolute or relative to CWD). 890 * @ mode : [in] access rights new value. 874 891 *****************************************************************************************/ 875 892 error_t vfs_mkfifo( xptr_t root_xp,
Note: See TracChangeset
for help on using the changeset viewer.