Changeset 9104bb5 in mainline for uspace/lib/ext4/libext4_inode.c


Ignore:
Timestamp:
2012-03-20T20:22:19Z (12 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a4419e7
Parents:
cd581120
Message:

changes according to reading inode data with extent

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext4/libext4_inode.c

    rcd581120 r9104bb5  
    278278}
    279279
    280 
    281 uint32_t ext4_inode_get_extent_block(ext4_inode_t *inode, uint64_t idx, service_id_t service_id)
    282 {
    283         int rc;
    284 
    285         block_t* block = NULL;
    286 
    287         ext4_extent_header_t *header = ext4_inode_get_extent_header(inode);
    288         while (ext4_extent_header_get_depth(header) != 0) {
    289 
    290                 ext4_extent_index_t *extent_index = EXT4_EXTENT_FIRST_INDEX(header);
    291 
    292                 for (uint16_t i = 0; i < ext4_extent_header_get_entries_count(header); ++i) {
    293                         if (idx >= ext4_extent_index_get_first_block(extent_index)) {
    294 
    295                                 uint64_t child = ext4_extent_index_get_leaf(extent_index);
    296 
    297                                 if (block != NULL) {
    298                                         block_put(block);
    299                                 }
    300 
    301                                 rc = block_get(&block, service_id, child, BLOCK_FLAGS_NONE);
    302                                 if (rc != EOK) {
    303                                         return 0;
    304                                 }
    305 
    306                                 header = (ext4_extent_header_t *)block->data;
    307                                 break;
    308                         }
    309                 }
    310         }
    311 
    312         ext4_extent_t *extent = EXT4_EXTENT_FIRST(header);
    313         uint64_t phys_block = 0;
    314 
    315         for (uint16_t i = 0; i < ext4_extent_header_get_entries_count(header); ++i) {
    316 
    317                 uint32_t first_block = ext4_extent_get_first_block(extent);
    318                 uint16_t block_count = ext4_extent_get_block_count(extent);
    319 
    320                 if ((idx >= first_block) && (idx < first_block + block_count)) {
    321                          phys_block = ext4_extent_get_start(extent) + idx;
    322                          phys_block -= ext4_extent_get_first_block(extent);
    323 
    324                          // Memory leak prevention
    325                          if (block != NULL) {
    326                                  block_put(block);
    327                          }
    328                          return phys_block;
    329                 }
    330                 // Go to the next extent
    331                 ++extent;
    332         }
    333 
    334 
    335         EXT4FS_DBG("ERROR - reached function end");
    336         return phys_block;
    337 }
    338 
    339280bool ext4_inode_is_type(ext4_superblock_t *sb, ext4_inode_t *inode, uint32_t type)
    340281{
Note: See TracChangeset for help on using the changeset viewer.