Example #1
0
void			Ext4Extents::read_indexes(ext4_extents_header * header,
						  uint8_t * block)
{
  ext4_extents_index *	idx;
  uint64_t		addr;
  uint8_t *		current_block;
  ext4_extents_header *	current_header;

  if (!header)
    return ;
  if (header->magic != 0xF30A)
    return ;
  for (int i = 0; i < header->entries; ++i)
    {
      idx = (ext4_extents_index *)(block + i * sizeof(ext4_extents_index));
      addr = concat_uint16_32(idx->next_level_high,
			      idx->next_level_low) * ((uint64_t)__block_size);
      if (!(current_block = read_block(addr)))
	return ;
      current_header = (ext4_extents_header *)current_block;
      if (current_header->depth)
	read_indexes(current_header,
		     current_block + sizeof(ext4_extents_header));
      else
	read_extents(current_header,
		     current_block + sizeof(ext4_extents_header));
      delete current_block;
    }
}
Example #2
0
void		Ext4Extents::push_extended_blocks(Inode * inode)
  throw (vfsError)
{
  if (!inode)
    throw vfsError("Ext4Extents::push_extended_blocks() : inode is NULL.");
  __inode = inode;
  __size = inode->lower_size();
  __block_size = inode->SB()->block_size();
  __node = inode->extfs()->node();
  __extfs = inode->extfs();
  if (!inode->extent_header()->depth)
    read_extents(inode->extent_header(),
		 (uint8_t *)&inode->block_pointers()[3]);
  else
    read_indexes(inode->extent_header(),
		 (uint8_t *)&inode->block_pointers()[3]);
}
Example #3
0
uint64_t	Ext4Extents::calc_size(Inode * inode)
{
  if (!inode)
    throw vfsError("Ext4Extents::calc_size() : inode is NULL.");
  __inode = inode;
  __size = inode->lower_size();
  __block_size = inode->SB()->block_size();
  __node = inode->extfs()->node();
  __extfs = inode->extfs();
  if (!inode->extent_header())
    __c_size = 0;
  else if (!inode->extent_header()->depth)
    read_extents_x(inode->extent_header(),
		 (uint8_t *)&inode->block_pointers()[3]);
  else
    read_indexes(inode->extent_header(),
		 (uint8_t *)&inode->block_pointers()[3]);
  return __c_size;
}
mtn::status_t
mtn::index_reader_writer_leveldb_t::read_index(mtn_index_partition_t           partition,
                                               const std::vector<mtn::byte_t>& bucket,
                                               const std::vector<mtn::byte_t>& field,
                                               mtn::index_t**                  output)
{
    mtn::index_reader_writer_t::index_container container;
    mtn::status_t status = read_indexes(partition, bucket, field, std::vector<mtn::byte_t>(), std::vector<mtn::byte_t>(), container);

    if (status) {
        if (!container.empty()) {
            *output = container.release(container.begin()).release();
        }
        else {
            *output = new mtn::index_t(partition, bucket, field);
        }
    }

    return status;
}