Changeset 7689590 in mainline for uspace/lib/ext4/libext4_directory_index.c
- Timestamp:
- 2012-03-03T17:44:38Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e63ce679
- Parents:
- c30a015
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_directory_index.c
rc30a015 r7689590 264 264 265 265 266 static int ext4_directory_dx_find_dir_entry(block_t *block,267 ext4_superblock_t *sb, size_t name_len, const char *name,268 ext4_directory_entry_ll_t **res_entry, aoff64_t *block_offset)269 {270 271 aoff64_t offset = 0;272 ext4_directory_entry_ll_t *dentry = (ext4_directory_entry_ll_t *)block->data;273 uint8_t *addr_limit = block->data + ext4_superblock_get_block_size(sb);274 275 while ((uint8_t *)dentry < addr_limit) {276 277 if ((uint8_t*) dentry + name_len > addr_limit) {278 break;279 }280 281 if (dentry->inode != 0) {282 if (name_len == ext4_directory_entry_ll_get_name_length(sb, dentry)) {283 // Compare names284 if (bcmp((uint8_t *)name, dentry->name, name_len) == 0) {285 *block_offset = offset;286 *res_entry = dentry;287 return 1;288 }289 }290 }291 292 293 // Goto next entry294 uint16_t dentry_len = ext4_directory_entry_ll_get_entry_length(dentry);295 296 if (dentry_len == 0) {297 // Error298 return -1;299 }300 301 offset += dentry_len;302 dentry = (ext4_directory_entry_ll_t *)((uint8_t *)dentry + dentry_len);303 }304 305 return 0;306 }307 308 266 static int ext4_directory_dx_next_block(ext4_filesystem_t *fs, ext4_inode_t *inode, uint32_t hash, 309 267 ext4_directory_dx_block_t *handle, ext4_directory_dx_block_t *handles) … … 368 326 } 369 327 370 int ext4_directory_dx_find_entry(ext4_directory_ iterator_t *it,371 ext4_filesystem_t *fs, ext4_inode_ref_t *inode_ref, size_t len, const char *name)328 int ext4_directory_dx_find_entry(ext4_directory_search_result_t *result, 329 ext4_filesystem_t *fs, ext4_inode_ref_t *inode_ref, size_t name_len, const char *name) 372 330 { 373 331 int rc; … … 383 341 rc = block_get(&root_block, fs->device, root_block_addr, BLOCK_FLAGS_NONE); 384 342 if (rc != EOK) { 385 it->current_block = NULL;386 343 return rc; 387 344 } 388 345 389 346 ext4_hash_info_t hinfo; 390 rc = ext4_directory_hinfo_init(&hinfo, root_block, fs->superblock, len, name);347 rc = ext4_directory_hinfo_init(&hinfo, root_block, fs->superblock, name_len, name); 391 348 if (rc != EOK) { 392 349 block_put(root_block); … … 419 376 } 420 377 421 aoff64_t block_offset;422 378 ext4_directory_entry_ll_t *res_dentry; 423 rc = ext4_directory_ dx_find_dir_entry(leaf_block, fs->superblock, len, name,424 &res_dentry, &block_offset); 379 rc = ext4_directory_find_in_block(leaf_block, fs->superblock, name_len, name, &res_dentry); 380 425 381 426 382 // Found => return it 427 if (rc == 1) { 428 it->fs = fs; 429 it->inode_ref = inode_ref; 430 it->current_block = leaf_block; 431 it->current_offset = block_offset; 432 it->current = res_dentry; 383 if (rc == EOK) { 384 result->block = leaf_block; 385 result->dentry = res_dentry; 433 386 return EOK; 434 387 } … … 572 525 } 573 526 574 // EXT4FS_DBG("new block appended (iblock = \%u, fblock = \%u)", new_iblock, new_fblock);575 576 527 // Load new block 577 528 block_t *new_data_block_tmp; … … 584 535 585 536 // Distribute entries to splitted blocks (by size) 586 587 537 uint32_t new_hash = 0; 588 538 uint32_t current_size = 0;
Note:
See TracChangeset
for help on using the changeset viewer.