Changeset ab77928 in mainline for uspace/lib/ext4/libext4_directory.c
- Timestamp:
- 2011-10-26T09:27:01Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0dc91833
- Parents:
- aaedaba
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_directory.c
raaedaba rab77928 328 328 } 329 329 330 for (p = entries; p < entries + count; ++p) {331 EXT4FS_DBG("hash = \%u && block = \%u", ext4_directory_dx_entry_get_hash(p), ext4_directory_dx_entry_get_block(p));332 }333 334 330 p = entries + 1; 335 331 q = entries + count - 1; 336 332 337 EXT4FS_DBG("hash = \%u", hinfo->hash);338 339 333 while (p <= q) { 340 334 m = p + (q - p) / 2; 341 EXT4FS_DBG("p = \%x, q = \%x, m = \%x", (uint32_t)p, (uint32_t)q, (uint32_t)m);342 EXT4FS_DBG("node hash = \%u", ext4_directory_dx_entry_get_hash(m));343 335 if (ext4_directory_dx_entry_get_hash(m) > hinfo->hash) { 344 336 q = m - 1; … … 411 403 } 412 404 413 if ( name_len == ext4_directory_entry_ll_get_name_length(sb, dentry)) {414 415 if (bcmp((uint8_t *)name, dentry->name, name_len) == 0) {416 // TODO check entry ??417 EXT4FS_DBG("found entry name = \%s", dentry->name);418 *block_offset = offset;419 *res_entry = dentry;420 return 1;405 if (dentry->inode != 0) { 406 if (name_len == ext4_directory_entry_ll_get_name_length(sb, dentry)) { 407 // Compare names 408 if (bcmp((uint8_t *)name, dentry->name, name_len) == 0) { 409 *block_offset = offset; 410 *res_entry = dentry; 411 return 1; 412 } 421 413 } 422 414 } 415 423 416 424 417 // Goto next entry 425 418 dentry_len = ext4_directory_entry_ll_get_entry_length(dentry); 426 427 uint16_t nl = ext4_directory_entry_ll_get_name_length(sb, dentry);428 dentry->name[nl] = 0;429 430 // EXT4FS_DBG("dentry_len = \%u",(uint32_t)dentry_len);431 EXT4FS_DBG("dentry_name = \%s", dentry->name);432 419 433 420 if (dentry_len == 0) { … … 475 462 476 463 current_hash = ext4_directory_dx_entry_get_hash(p->position); 477 478 EXT4FS_DBG("hash = \%u, curr = \%u", hash, current_hash);479 464 480 465 if ((hash & 1) == 0) { … … 521 506 ext4_directory_dx_handle_t handles[2], *handle; 522 507 523 524 508 // get direct block 0 (index root) 525 509 rc = ext4_filesystem_get_inode_data_block_index(fs, inode_ref->inode, 0, &root_block_addr); … … 548 532 do { 549 533 550 EXT4FS_DBG("pos = \%u", (uint32_t)handle->position);551 552 534 leaf_block_idx = ext4_directory_dx_entry_get_block(handle->position); 553 535 … … 557 539 } 558 540 559 EXT4FS_DBG("bloxk = \%u", leaf_block_idx);560 561 541 rc = block_get(&leaf_block, fs->device, leaf_block_addr, BLOCK_FLAGS_NONE); 562 542 if (rc != EOK) { … … 566 546 rc = ext4_dirextory_dx_find_dir_entry(leaf_block, fs->superblock, len, name, 567 547 &res_dentry, &block_offset); 568 569 EXT4FS_DBG("entry \%s", rc == 1 ? "found" : "not found");570 548 571 549 // Found => return it … … 593 571 } 594 572 595 EXT4FS_DBG("can\%s continue", rc == 1 ? "" : "not");596 597 573 } while (rc == 1); 598 574 599 // TODO return ENOENT; 600 return EXT4_ERR_BAD_DX_DIR; 575 return ENOENT; 601 576 } 602 577
Note:
See TracChangeset
for help on using the changeset viewer.