Changeset 635 for trunk/kernel/fs
- Timestamp:
- Jun 26, 2019, 11:42:37 AM (5 years ago)
- Location:
- trunk/kernel/fs
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/fs/devfs.c
r624 r635 58 58 kmem_req_t req; 59 59 60 req.type = KMEM_ DEVFS_CTX;61 req. size = sizeof(devfs_ctx_t);60 req.type = KMEM_KCM; 61 req.order = bits_log2( sizeof(devfs_ctx_t) ); 62 62 req.flags = AF_KERNEL | AF_ZERO; 63 63 64 return (devfs_ctx_t *)kmem_alloc( &req );64 return kmem_alloc( &req ); 65 65 } 66 66 … … 81 81 kmem_req_t req; 82 82 83 req.type = KMEM_ DEVFS_CTX;83 req.type = KMEM_KCM; 84 84 req.ptr = devfs_ctx; 85 85 kmem_free( &req ); -
trunk/kernel/fs/fatfs.c
r633 r635 1069 1069 { 1070 1070 kmem_req_t req; 1071 req.type = KMEM_ FATFS_CTX;1072 req. size = sizeof(fatfs_ctx_t);1071 req.type = KMEM_KCM; 1072 req.order = bits_log2( sizeof(fatfs_ctx_t) ); 1073 1073 req.flags = AF_KERNEL | AF_ZERO; 1074 1074 1075 return (fatfs_ctx_t *)kmem_alloc( &req );1075 return kmem_alloc( &req ); 1076 1076 } 1077 1077 … … 1101 1101 // - temporarily the BOOT sector 1102 1102 // - permanently the FS_INFO sector 1103 req.type = KMEM_512_BYTES; 1103 req.type = KMEM_KCM; 1104 req.order = 9; // 512 bytes 1104 1105 req.flags = AF_KERNEL | AF_ZERO; 1105 buffer = (uint8_t *)kmem_alloc( &req ); 1106 buffer_xp = XPTR( local_cxy , buffer ); 1106 buffer = kmem_alloc( &req ); 1107 1107 1108 1108 if( buffer == NULL ) … … 1112 1112 } 1113 1113 1114 buffer_xp = XPTR( local_cxy , buffer ); 1115 1114 1116 // load the BOOT record from device 1115 1117 error = dev_ioc_sync_read( buffer_xp , 0 , 1 ); … … 1242 1244 { 1243 1245 kmem_req_t req; 1244 req.type = KMEM_ FATFS_CTX;1246 req.type = KMEM_KCM; 1245 1247 req.ptr = fatfs_ctx; 1246 1248 kmem_free( &req ); -
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 ); -
trunk/kernel/fs/vfs.h
r633 r635 306 306 /****************************************************************************************** 307 307 * This function allocates memory from local cluster for an inode descriptor and the 308 * associated mapper. It initialise these descriptors from arguments values. 308 * associated mapper, and partially initialise this inode from arguments values. 309 * It does NOT link it to the Inode Tree, as this is done by add_child_in_parent(). 309 310 * It must called by a local thread. Use the RPC_INODE_CREATE if client thread is remote. 310 311 ******************************************************************************************
Note: See TracChangeset
for help on using the changeset viewer.