Changeset d9bbe45 in mainline for uspace/lib/ext4/libext4_inode.c
- Timestamp:
- 2012-01-22T13:22:56Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fcae007
- Parents:
- b7e0260
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_inode.c
rb7e0260 rd9bbe45 160 160 uint64_t ext4_inode_get_blocks_count(ext4_superblock_t *sb, ext4_inode_t *inode) 161 161 { 162 uint64_t count;163 164 162 if (ext4_superblock_has_feature_read_only(sb, EXT4_FEATURE_RO_COMPAT_HUGE_FILE)) { 165 163 166 164 /* 48-bit field */ 167 count = ((uint64_t)uint16_t_le2host(inode->osd2.linux2.blocks_high)) << 32 |165 uint64_t count = ((uint64_t)uint16_t_le2host(inode->osd2.linux2.blocks_high)) << 32 | 168 166 uint32_t_le2host(inode->blocks_count_lo); 169 167 … … 283 281 uint32_t ext4_inode_get_extent_block(ext4_inode_t *inode, uint64_t idx, service_id_t service_id) 284 282 { 283 int rc; 284 285 block_t* block = NULL; 286 285 287 ext4_extent_header_t *header = ext4_inode_get_extent_header(inode); 286 ext4_extent_t *extent;287 ext4_extent_index_t *extent_index;288 289 uint32_t first_block;290 uint16_t block_count;291 uint64_t phys_block = 0;292 uint64_t child;293 294 int rc;295 block_t* block = NULL;296 297 288 while (ext4_extent_header_get_depth(header) != 0) { 298 289 299 ext ent_index = EXT4_EXTENT_FIRST_INDEX(header);290 ext4_extent_index_t *extent_index = EXT4_EXTENT_FIRST_INDEX(header); 300 291 301 292 for (uint16_t i = 0; i < ext4_extent_header_get_entries_count(header); ++i) { 302 if (idx >= ext4_extent_index_get_first_block(extent_index)) {303 304 child = ext4_extent_index_get_leaf(extent_index);293 if (idx >= ext4_extent_index_get_first_block(extent_index)) { 294 295 uint64_t child = ext4_extent_index_get_leaf(extent_index); 305 296 306 297 if (block != NULL) { … … 319 310 } 320 311 321 extent = EXT4_EXTENT_FIRST(header); 312 ext4_extent_t *extent = EXT4_EXTENT_FIRST(header); 313 uint64_t phys_block = 0; 322 314 323 315 for (uint16_t i = 0; i < ext4_extent_header_get_entries_count(header); ++i) { 324 316 325 first_block = ext4_extent_get_first_block(extent);326 block_count = ext4_extent_get_block_count(extent);317 uint32_t first_block = ext4_extent_get_first_block(extent); 318 uint16_t block_count = ext4_extent_get_block_count(extent); 327 319 328 320 if ((idx >= first_block) && (idx < first_block + block_count)) { 329 phys_block = ext4_extent_get_start(extent) + idx;330 phys_block -= ext4_extent_get_first_block(extent);331 332 // Memory leak prevention333 if (block != NULL) {334 block_put(block);335 }336 return phys_block;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; 337 329 } 338 330 // Go to the next extent
Note:
See TracChangeset
for help on using the changeset viewer.