Changeset 635 for trunk/kernel/fs/vfs.c
- Timestamp:
- Jun 26, 2019, 11:42:37 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/fs/vfs.c
r634 r635 150 150 mapper_t * mapper; // associated mapper( to be allocated) 151 151 vfs_inode_t * inode; // inode descriptor (to be allocated) 152 152 153 uint32_t inum; // inode identifier (to be allocated) 153 154 vfs_ctx_t * ctx; // file system context … … 155 156 error_t error; 156 157 157 #if DEBUG_VFS_INODE_CREATE158 char name[CONFIG_VFS_MAX_NAME_LENGTH];159 uint32_t cycle = (uint32_t)hal_get_cycles();160 cxy_t dentry_cxy = GET_CXY( dentry_xp );161 vfs_dentry_t * dentry_ptr = GET_PTR( dentry_xp );162 thread_t * this = CURRENT_THREAD;163 if( dentry_xp != XPTR_NULL ) hal_remote_strcpy( XPTR( local_cxy , name ),164 XPTR( dentry_cxy , dentry_ptr->name ) );165 else strcpy( name , "/" );166 if( DEBUG_VFS_INODE_CREATE < cycle )167 printk("\n[%s] thread[%x,%x] enter for <%s> / cycle %d\n",168 __FUNCTION__, this->process->pid, this->trdid, name, cycle );169 #endif170 171 158 // check fs type and get pointer on context 172 159 if ( fs_type == FS_TYPE_FATFS ) ctx = &fs_context[FS_TYPE_FATFS]; … … 198 185 } 199 186 200 // allocate memory for VFS inode descriptor 201 req.type = KMEM_VFS_INODE; 202 req.size = sizeof(vfs_inode_t); 187 // check inode descriptor contained in one page 188 assert( (sizeof(vfs_inode_t) <= CONFIG_PPM_PAGE_SIZE), 189 "inode descriptor must fit in one page" ); 190 191 // allocate one page for VFS inode descriptor 192 // because the embedded "children xhtab footprint 193 req.type = KMEM_PPM; 194 req.order = 0; 203 195 req.flags = AF_KERNEL | AF_ZERO; 204 inode = (vfs_inode_t *)kmem_alloc( &req );196 inode = kmem_alloc( &req ); 205 197 206 198 if( inode == NULL ) … … 243 235 244 236 #if DEBUG_VFS_INODE_CREATE 245 cycle = (uint32_t)hal_get_cycles(); 237 char name[CONFIG_VFS_MAX_NAME_LENGTH]; 238 uint32_t cycle = (uint32_t)hal_get_cycles(); 239 thread_t * this = CURRENT_THREAD; 240 vfs_inode_get_name( *inode_xp , name ); 246 241 if( DEBUG_VFS_INODE_CREATE < cycle ) 247 printk("\n[%s] thread[%x,%x] exit for<%s> / inode [%x,%x] / cycle %d\n",242 printk("\n[%s] thread[%x,%x] created <%s> / inode [%x,%x] / cycle %d\n", 248 243 __FUNCTION__, this->process->pid, this->trdid, name, local_cxy, inode, cycle ); 249 244 #endif … … 261 256 // release memory allocate for inode descriptor 262 257 kmem_req_t req; 258 req.type = KMEM_PPM; 263 259 req.ptr = inode; 264 req.type = KMEM_VFS_INODE;265 260 kmem_free( &req ); 266 261 … … 477 472 kmem_req_t req; // request to kernel memory allocator 478 473 479 #if DEBUG_VFS_DENTRY_CREATE480 thread_t * this = CURRENT_THREAD;481 uint32_t cycle = (uint32_t)hal_get_cycles();482 if( DEBUG_VFS_DENTRY_CREATE < cycle )483 printk("\n[%s] thread[%x,%x] enter for <%s> / cycle %d\n",484 __FUNCTION__, this->process->pid, this->trdid, name, cycle );485 #endif486 487 474 // get pointer on context 488 475 if ( fs_type == FS_TYPE_FATFS ) ctx = &fs_context[FS_TYPE_FATFS]; … … 501 488 502 489 // allocate memory for dentry descriptor 503 req.type = KMEM_ VFS_DENTRY;504 req. size = sizeof(vfs_dentry_t);490 req.type = KMEM_KCM; 491 req.order = bits_log2( sizeof(vfs_dentry_t) ); 505 492 req.flags = AF_KERNEL | AF_ZERO; 506 dentry = (vfs_dentry_t *)kmem_alloc( &req );493 dentry = kmem_alloc( &req ); 507 494 508 495 if( dentry == NULL ) … … 523 510 524 511 #if DEBUG_VFS_DENTRY_CREATE 525 cycle = (uint32_t)hal_get_cycles(); 512 thread_t * this = CURRENT_THREAD; 513 uint32_t cycle = (uint32_t)hal_get_cycles(); 526 514 if( DEBUG_VFS_DENTRY_CREATE < cycle ) 527 printk("\n[%s] thread[%x,%x] exit for<%s> / dentry [%x,%x] / cycle %d\n",515 printk("\n[%s] thread[%x,%x] created <%s> / dentry [%x,%x] / cycle %d\n", 528 516 __FUNCTION__, this->process->pid, this->trdid, name, local_cxy, dentry, cycle ); 529 517 #endif … … 538 526 // release memory allocated to dentry 539 527 kmem_req_t req; 528 req.type = KMEM_KCM; 540 529 req.ptr = dentry; 541 req.type = KMEM_VFS_DENTRY;542 530 kmem_free( &req ); 543 531 … … 566 554 567 555 // allocate memory for new file descriptor 568 req.type = KMEM_ VFS_FILE;569 req. size = sizeof(vfs_file_t);556 req.type = KMEM_KCM; 557 req.order = bits_log2( sizeof(vfs_file_t) ); 570 558 req.flags = AF_KERNEL | AF_ZERO; 571 file = (vfs_file_t *)kmem_alloc( &req );559 file = kmem_alloc( &req ); 572 560 573 561 if( file == NULL ) return ENOMEM; … … 602 590 { 603 591 kmem_req_t req; 592 req.type = KMEM_KCM; 604 593 req.ptr = file; 605 req.type = KMEM_VFS_FILE;606 594 kmem_free( &req ); 607 595 … … 3347 3335 #endif 3348 3336 3337 3349 3338 // 3. register new_dentry in new_inode xlist of parents 3350 3339 parents_root_xp = XPTR( child_cxy , &new_inode_ptr->parents );
Note: See TracChangeset
for help on using the changeset viewer.