Changeset ab77928 in mainline for uspace/lib/ext4/libext4_directory.c


Ignore:
Timestamp:
2011-10-26T09:27:01Z (13 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0dc91833
Parents:
aaedaba
Message:

complete directory index reading (it runs) - many TODOs remaining

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext4/libext4_directory.c

    raaedaba rab77928  
    328328                }
    329329
    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 
    334330                p = entries + 1;
    335331                q = entries + count - 1;
    336332
    337                 EXT4FS_DBG("hash = \%u", hinfo->hash);
    338 
    339333                while (p <= q) {
    340334                        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));
    343335                        if (ext4_directory_dx_entry_get_hash(m) > hinfo->hash) {
    344336                                q = m - 1;
     
    411403                }
    412404
    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                                }
    421413                        }
    422414                }
     415
    423416
    424417                // Goto next entry
    425418                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);
    432419
    433420        if (dentry_len == 0) {
     
    475462
    476463    current_hash = ext4_directory_dx_entry_get_hash(p->position);
    477 
    478     EXT4FS_DBG("hash = \%u, curr = \%u", hash, current_hash);
    479464
    480465    if ((hash & 1) == 0) {
     
    521506        ext4_directory_dx_handle_t handles[2], *handle;
    522507
    523 
    524508        // get direct block 0 (index root)
    525509        rc = ext4_filesystem_get_inode_data_block_index(fs, inode_ref->inode, 0, &root_block_addr);
     
    548532        do {
    549533
    550                 EXT4FS_DBG("pos = \%u", (uint32_t)handle->position);
    551 
    552534                leaf_block_idx = ext4_directory_dx_entry_get_block(handle->position);
    553535
     
    557539        }
    558540
    559         EXT4FS_DBG("bloxk = \%u", leaf_block_idx);
    560 
    561541                rc = block_get(&leaf_block, fs->device, leaf_block_addr, BLOCK_FLAGS_NONE);
    562542                if (rc != EOK) {
     
    566546                rc = ext4_dirextory_dx_find_dir_entry(leaf_block, fs->superblock, len, name,
    567547                                &res_dentry, &block_offset);
    568 
    569                 EXT4FS_DBG("entry \%s", rc == 1 ? "found" : "not found");
    570548
    571549                // Found => return it
     
    593571                }
    594572
    595                 EXT4FS_DBG("can\%s continue", rc == 1 ? "" : "not");
    596 
    597573        } while (rc == 1);
    598574
    599         // TODO return ENOENT;
    600         return EXT4_ERR_BAD_DX_DIR;
     575        return ENOENT;
    601576}
    602577
Note: See TracChangeset for help on using the changeset viewer.