Changeset 36d2c6f in mainline
- Timestamp:
- 2011-10-20T09:53:35Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e3ca824
- Parents:
- 246a5af
- Location:
- uspace
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_directory.c
r246a5af r36d2c6f 312 312 ext4_directory_dx_entry_t *entries; 313 313 block_t *tmp_block = NULL; 314 uint32_t fblock ;314 uint32_t fblock, next_block; 315 315 316 316 root = (ext4_directory_dx_root_t *)root_block->data; … … 341 341 at = p - 1; 342 342 343 next_block = ext4_directory_dx_entry_get_block(at); 344 345 if (tmp_block) { 346 block_put(tmp_block); 347 } 348 343 349 if (indirect_level == 0) { 344 *leaf_block_idx = ext4_directory_dx_entry_get_block(at); 345 return EOK; 350 return ext4_filesystem_get_inode_data_block_index(fs, inode, next_block, leaf_block_idx); 346 351 } 347 352 348 353 indirect_level--; 349 354 350 rc = ext4_filesystem_get_inode_data_block_index(fs, inode, ext4_directory_dx_entry_get_block(at), &fblock);355 rc = ext4_filesystem_get_inode_data_block_index(fs, inode, next_block, &fblock); 351 356 if (rc != EOK) { 352 357 return rc; 353 358 } 354 359 355 if (tmp_block) {356 block_put(tmp_block);357 }358 359 360 rc = block_get(&tmp_block, fs->device, fblock, BLOCK_FLAGS_NONE); 360 361 if (rc != EOK) { 361 // TODO362 362 return rc; 363 363 } … … 376 376 } 377 377 378 if (tmp_block) { 379 block_put(tmp_block); 380 } 381 378 // Unreachable 382 379 return EOK; 380 } 381 382 383 static int ext4_dirextory_dx_find_dir_entry(block_t *block, 384 ext4_superblock_t *sb, size_t name_len, const char *name, 385 ext4_directory_entry_ll_t **res_entry, aoff64_t *block_offset) 386 { 387 ext4_directory_entry_ll_t *dentry; 388 uint16_t dentry_len; 389 uint8_t *addr_limit; 390 aoff64_t offset = 0; 391 392 dentry = (ext4_directory_entry_ll_t *)block->data; 393 addr_limit = block->data + ext4_superblock_get_block_size(sb); 394 395 while ((uint8_t *)dentry < addr_limit) { 396 397 if ((uint8_t*) dentry + name_len > addr_limit) { 398 break; 399 } 400 401 if (name_len == ext4_directory_entry_ll_get_name_length(sb, dentry)) { 402 403 if (bcmp((uint8_t *)name, dentry->name, name_len)) { 404 // TODO check entry ?? 405 *block_offset = offset; 406 *res_entry = dentry; 407 return EOK; 408 } 409 } 410 411 // Goto next entry 412 dentry_len = ext4_directory_entry_ll_get_entry_length(dentry); 413 if (dentry_len <= 0) { 414 // TODO 415 return -1; 416 } 417 418 offset += dentry_len; 419 dentry = (ext4_directory_entry_ll_t *)((uint8_t *)dentry + dentry_len); 420 } 421 422 return ENOENT; 383 423 } 384 424 … … 389 429 int rc; 390 430 uint32_t root_block_addr, leaf_block_addr; 391 block_t *root_block; 431 aoff64_t block_offset; 432 block_t *root_block, *leaf_block; 392 433 ext4_hash_info_t hinfo; 434 ext4_directory_entry_ll_t *res_dentry; 393 435 394 436 // get direct block 0 (index root) … … 406 448 rc = ext4_directory_hinfo_init(&hinfo, root_block, fs->superblock, len, name); 407 449 if (rc != EOK) { 408 EXT4FS_DBG("ERR: leaf block not found");409 450 block_put(root_block); 410 451 return EXT4_ERR_BAD_DX_DIR; … … 416 457 } 417 458 418 // TODO now having block - do directory entry search 459 rc = block_get(&leaf_block, fs->device, leaf_block_addr, BLOCK_FLAGS_NONE); 460 if (rc != EOK) { 461 return EXT4_ERR_BAD_DX_DIR; 462 } 463 464 rc = ext4_dirextory_dx_find_dir_entry(leaf_block, fs->superblock, len, name, 465 &res_dentry, &block_offset); 466 467 // Found = return it 468 if (rc == EOK) { 469 it->fs = fs; 470 it->inode_ref = inode_ref; 471 it->current_block = leaf_block; 472 it->current_offset = block_offset; 473 it->current = res_dentry; 474 return EOK; 475 } 419 476 420 477 // TODO delete it !!! -
uspace/srv/fs/ext4fs/ext4fs_ops.c
r246a5af r36d2c6f 238 238 239 239 inode = ext4_directory_entry_ll_get_inode(it.current); 240 return ext4fs_node_get_core(rfn, eparent->instance, inode); 240 241 rc = ext4fs_node_get_core(rfn, eparent->instance, inode); 242 ext4_directory_iterator_fini(&it); 243 return rc; 241 244 } 242 245
Note:
See TracChangeset
for help on using the changeset viewer.