コード例 #1
0
void ext4_create_resize_inode()
{
	struct block_allocation *reserve_inode_alloc = create_allocation();
	u32 reserve_inode_len = 0;
	unsigned int i;

	struct ext4_inode *inode = get_inode(EXT4_RESIZE_INO);
	if (inode == NULL) {
		error("failed to get resize inode");
		return;
	}

	for (i = 0; i < aux_info.groups; i++) {
		if (ext4_bg_has_super_block(i)) {
			u64 group_start_block = aux_info.first_data_block + i *
				info.blocks_per_group;
			u32 reserved_block_start = group_start_block + 1 +
				aux_info.bg_desc_blocks;
			u32 reserved_block_len = info.bg_desc_reserve_blocks;
			append_region(reserve_inode_alloc, reserved_block_start,
				reserved_block_len, i);
			reserve_inode_len += reserved_block_len;
		}
	}

	inode_attach_resize(inode, reserve_inode_alloc);

	inode->i_mode = S_IFREG | S_IRUSR | S_IWUSR;
	inode->i_links_count = 1;

	free_alloc(reserve_inode_alloc);
}
コード例 #2
0
ファイル: profiler.c プロジェクト: schmurfy/probe
void* profiler_allocf(mrb_state *mrb, void *p, size_t size, void *ud, const char *file, uint32_t line)
{ 
  if (size == 0) {
    allocation_t *prev = NULL;
    allocation_t *curr = allocations_list;
    // find associated entry
    while( (curr != NULL) && (curr->address != p) ){
      prev = curr;
      curr = curr->next;
    }
    
    if( curr != NULL ){
      // printf("[%s][%s:%d] free()\n", (const char *)ud, file, line);
      if( prev ){
        prev->next = curr->next;
      }
      else {
        allocations_list = NULL;
      }
      
      destroy_allocation(curr);
    }
    else {
      // printf("allocation not found: %s:%d !!! \n", file, line);
    }
    
    free(p);
    return NULL;
  }
  else {
    void *addr = realloc(p, size);
    allocation_t *curr = create_allocation(mrb, file, line, addr, size);
    
    if( allocations_list == NULL ){
      allocations_list = curr;
    }
    else {
      // find tip
      allocation_t *tip = allocations_list_tip();
      // and add it at the end
      tip->next = curr;
    }
    
    // printf("[%s][%s:%d] malloc(%zd)\n", (const char *)ud, file, line, size);
    // print_backtrace();
    return addr;
  }
}