Changeset ab77928 in mainline
- 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
- Location:
- uspace/lib/ext4
- Files:
-
- 2 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 -
uspace/lib/ext4/libext4_hash.c
raaedaba rab77928 49 49 #define H(x, y, z) ((x) ^ (y) ^ (z)) 50 50 51 51 52 /* 52 53 * The generic round function. The application is so specific that … … 62 63 63 64 64 static void tea_transform(uint32_t buf[4], uint32_t const in[])65 static void tea_transform(uint32_t buf[4], uint32_t const in[]) 65 66 { 66 67 uint32_t sum = 0; … … 233 234 int i; 234 235 uint32_t in[8], buf[4]; 235 bool unsigned_version = false; 236 void (*str2hashbuf)(const char *, int, uint32_t *, int) = str2hashbuf_signed; 237 238 /* 239 for (i = 0; i < 8; ++i) { 240 in[i] = 0; 241 } 242 */ 236 243 237 244 /* Initialize the default seed for the hash checksum functions */ … … 247 254 break; 248 255 } 249 if (i < 4) {250 memcpy(buf, hinfo->seed, sizeof(buf));251 }256 } 257 if (i < 4) { 258 memcpy(buf, hinfo->seed, sizeof(buf)); 252 259 } 253 260 } … … 264 271 265 272 case EXT4_HASH_VERSION_HALF_MD4_UNSIGNED: 266 unsigned_version = true;273 str2hashbuf = str2hashbuf_unsigned; 267 274 268 275 case EXT4_HASH_VERSION_HALF_MD4: 269 276 p = name; 270 277 while (len > 0) { 271 if (unsigned_version) { 272 str2hashbuf_unsigned(p, len, in, 8); 273 } else { 274 str2hashbuf_signed(p, len, in, 8); 275 } 278 (*str2hashbuf)(p, len, in, 8); 276 279 half_md4_transform(buf, in); 277 280 len -= 32; … … 284 287 285 288 case EXT4_HASH_VERSION_TEA_UNSIGNED: 286 unsigned_version = true;289 str2hashbuf = str2hashbuf_unsigned; 287 290 288 291 case EXT4_HASH_VERSION_TEA: 289 292 p = name; 290 293 while (len > 0) { 291 if (unsigned_version) { 292 str2hashbuf_unsigned(p, len, in, 4); 293 } else { 294 str2hashbuf_signed(p, len, in, 4); 295 } 294 (*str2hashbuf)(p, len, in, 4); 296 295 tea_transform(buf, in); 297 296 len -= 16; … … 311 310 hash = (EXT4_DIRECTORY_HTREE_EOF-1) << 1; 312 311 } 312 313 313 hinfo->hash = hash; 314 314 hinfo->minor_hash = minor_hash;
Note:
See TracChangeset
for help on using the changeset viewer.