Changeset d9bbe45 in mainline for uspace/lib/ext4/libext4_directory_index.c
- Timestamp:
- 2012-01-22T13:22:56Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fcae007
- Parents:
- b7e0260
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_directory_index.c
rb7e0260 rd9bbe45 130 130 ext4_superblock_t *sb, size_t name_len, const char *name) 131 131 { 132 uint32_t block_size, entry_space; 133 uint16_t limit; 134 ext4_directory_dx_root_t *root; 135 136 root = (ext4_directory_dx_root_t *)root_block->data; 132 133 ext4_directory_dx_root_t *root = (ext4_directory_dx_root_t *)root_block->data; 137 134 138 135 if (root->info.hash_version != EXT4_HASH_VERSION_TEA && … … 154 151 } 155 152 156 block_size = ext4_superblock_get_block_size(sb);157 158 entry_space = block_size;153 uint32_t block_size = ext4_superblock_get_block_size(sb); 154 155 uint32_t entry_space = block_size; 159 156 entry_space -= 2 * sizeof(ext4_directory_dx_dot_entry_t); 160 157 entry_space -= sizeof(ext4_directory_dx_root_info_t); 161 158 entry_space = entry_space / sizeof(ext4_directory_dx_entry_t); 162 159 163 limit = ext4_directory_dx_countlimit_get_limit((ext4_directory_dx_countlimit_t *)&root->entries);160 uint16_t limit = ext4_directory_dx_countlimit_get_limit((ext4_directory_dx_countlimit_t *)&root->entries); 164 161 if (limit != entry_space) { 165 162 return EXT4_ERR_BAD_DX_DIR; … … 187 184 { 188 185 int rc; 189 uint16_t count, limit, entry_space; 190 uint8_t indirect_level; 191 ext4_directory_dx_root_t *root; 186 187 ext4_directory_dx_block_t *tmp_dx_block = dx_blocks; 188 189 ext4_directory_dx_root_t *root = (ext4_directory_dx_root_t *)root_block->data; 190 ext4_directory_dx_entry_t *entries = (ext4_directory_dx_entry_t *)&root->entries; 191 192 uint16_t limit = ext4_directory_dx_countlimit_get_limit((ext4_directory_dx_countlimit_t *)entries); 193 uint8_t indirect_level = ext4_directory_dx_root_info_get_indirect_levels(&root->info); 194 195 block_t *tmp_block = root_block; 192 196 ext4_directory_dx_entry_t *p, *q, *m, *at; 193 ext4_directory_dx_entry_t *entries;194 block_t *tmp_block = root_block;195 uint32_t fblock, next_block;196 ext4_directory_dx_block_t *tmp_dx_block = dx_blocks;197 198 root = (ext4_directory_dx_root_t *)root_block->data;199 entries = (ext4_directory_dx_entry_t *)&root->entries;200 201 limit = ext4_directory_dx_countlimit_get_limit((ext4_directory_dx_countlimit_t *)entries);202 indirect_level = ext4_directory_dx_root_info_get_indirect_levels(&root->info);203 204 197 while (true) { 205 198 206 count = ext4_directory_dx_countlimit_get_count((ext4_directory_dx_countlimit_t *)entries);199 uint16_t count = ext4_directory_dx_countlimit_get_count((ext4_directory_dx_countlimit_t *)entries); 207 200 if ((count == 0) || (count > limit)) { 208 201 return EXT4_ERR_BAD_DX_DIR; … … 232 225 } 233 226 234 next_block = ext4_directory_dx_entry_get_block(at);227 uint32_t next_block = ext4_directory_dx_entry_get_block(at); 235 228 236 229 indirect_level--; 237 230 231 uint32_t fblock; 238 232 rc = ext4_filesystem_get_inode_data_block_index(fs, inode, next_block, &fblock); 239 233 if (rc != EOK) { … … 249 243 limit = ext4_directory_dx_countlimit_get_limit((ext4_directory_dx_countlimit_t *)entries); 250 244 251 entry_space = ext4_superblock_get_block_size(fs->superblock) - sizeof(ext4_directory_dx_dot_entry_t); 245 uint16_t entry_space = ext4_superblock_get_block_size(fs->superblock) 246 - sizeof(ext4_directory_dx_dot_entry_t); 252 247 entry_space = entry_space / sizeof(ext4_directory_dx_entry_t); 253 248 … … 266 261 267 262 268 static int ext4_dire xtory_dx_find_dir_entry(block_t *block,263 static int ext4_directory_dx_find_dir_entry(block_t *block, 269 264 ext4_superblock_t *sb, size_t name_len, const char *name, 270 265 ext4_directory_entry_ll_t **res_entry, aoff64_t *block_offset) 271 266 { 272 ext4_directory_entry_ll_t *dentry; 273 uint16_t dentry_len; 274 uint8_t *addr_limit; 267 275 268 aoff64_t offset = 0; 276 277 dentry = (ext4_directory_entry_ll_t *)block->data; 278 addr_limit = block->data + ext4_superblock_get_block_size(sb); 269 ext4_directory_entry_ll_t *dentry = (ext4_directory_entry_ll_t *)block->data; 270 uint8_t *addr_limit = block->data + ext4_superblock_get_block_size(sb); 279 271 280 272 while ((uint8_t *)dentry < addr_limit) { … … 297 289 298 290 // Goto next entry 299 dentry_len = ext4_directory_entry_ll_get_entry_length(dentry);291 uint16_t dentry_len = ext4_directory_entry_ll_get_entry_length(dentry); 300 292 301 293 if (dentry_len == 0) { … … 314 306 ext4_directory_dx_block_t *handle, ext4_directory_dx_block_t *handles) 315 307 { 316 ext4_directory_dx_block_t *p; 317 uint16_t count; 318 uint32_t num_handles; 319 uint32_t current_hash; 320 block_t *block; 321 uint32_t block_addr, block_idx; 322 int rc; 323 324 num_handles = 0; 325 p = handle; 308 int rc; 309 310 311 uint32_t num_handles = 0; 312 ext4_directory_dx_block_t *p = handle; 326 313 327 314 while (1) { 328 315 329 316 p->position++; 330 count = ext4_directory_dx_countlimit_get_count((ext4_directory_dx_countlimit_t *)p->entries);317 uint16_t count = ext4_directory_dx_countlimit_get_count((ext4_directory_dx_countlimit_t *)p->entries); 331 318 332 319 if (p->position < p->entries + count) { … … 342 329 } 343 330 344 current_hash = ext4_directory_dx_entry_get_hash(p->position);331 uint32_t current_hash = ext4_directory_dx_entry_get_hash(p->position); 345 332 346 333 if ((hash & 1) == 0) { … … 350 337 } 351 338 339 352 340 while (num_handles--) { 353 341 354 block_idx = ext4_directory_dx_entry_get_block(p->position); 342 uint32_t block_idx = ext4_directory_dx_entry_get_block(p->position); 343 uint32_t block_addr; 355 344 rc = ext4_filesystem_get_inode_data_block_index(fs, inode, block_idx, &block_addr); 356 345 if (rc != EOK) { … … 358 347 } 359 348 349 block_t *block; 360 350 rc = block_get(&block, fs->device, block_addr, BLOCK_FLAGS_NONE); 361 351 if (rc != EOK) { … … 379 369 { 380 370 int rc; 381 uint32_t root_block_addr, leaf_block_addr, leaf_block_idx;382 aoff64_t block_offset;383 block_t *root_block, *leaf_block;384 ext4_hash_info_t hinfo;385 ext4_directory_entry_ll_t *res_dentry;386 ext4_directory_dx_block_t dx_blocks[2], *dx_block;387 371 388 372 // get direct block 0 (index root) 373 uint32_t root_block_addr; 389 374 rc = ext4_filesystem_get_inode_data_block_index(fs, inode_ref->inode, 0, &root_block_addr); 390 375 if (rc != EOK) { … … 392 377 } 393 378 379 block_t *root_block; 394 380 rc = block_get(&root_block, fs->device, root_block_addr, BLOCK_FLAGS_NONE); 395 381 if (rc != EOK) { … … 398 384 } 399 385 386 ext4_hash_info_t hinfo; 400 387 rc = ext4_directory_hinfo_init(&hinfo, root_block, fs->superblock, len, name); 401 388 if (rc != EOK) { … … 404 391 } 405 392 393 ext4_directory_dx_block_t dx_blocks[2]; 394 ext4_directory_dx_block_t *dx_block; 406 395 rc = ext4_directory_dx_get_leaf(&hinfo, fs, inode_ref->inode, root_block, &dx_block, dx_blocks); 407 396 if (rc != EOK) { … … 410 399 } 411 400 401 412 402 do { 413 403 414 leaf_block_idx = ext4_directory_dx_entry_get_block(dx_block->position);415 404 uint32_t leaf_block_idx = ext4_directory_dx_entry_get_block(dx_block->position); 405 uint32_t leaf_block_addr; 416 406 rc = ext4_filesystem_get_inode_data_block_index(fs, inode_ref->inode, leaf_block_idx, &leaf_block_addr); 417 407 if (rc != EOK) { … … 419 409 } 420 410 411 block_t *leaf_block; 421 412 rc = block_get(&leaf_block, fs->device, leaf_block_addr, BLOCK_FLAGS_NONE); 422 413 if (rc != EOK) { … … 424 415 } 425 416 426 rc = ext4_dirextory_dx_find_dir_entry(leaf_block, fs->superblock, len, name, 417 aoff64_t block_offset; 418 ext4_directory_entry_ll_t *res_dentry; 419 rc = ext4_directory_dx_find_dir_entry(leaf_block, fs->superblock, len, name, 427 420 &res_dentry, &block_offset); 428 421
Note:
See TracChangeset
for help on using the changeset viewer.