Changeset e68c834 in mainline
- Timestamp:
- 2011-10-10T06:48:16Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7a68fe5
- Parents:
- 1114173
- Location:
- uspace
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_directory.c
r1114173 re68c834 142 142 } 143 143 144 EXT4FS_DBG("next_block_phys_idx: \%d", next_block_phys_idx); 145 144 146 rc = block_get(&it->current_block, it->fs->device, next_block_phys_idx, 145 147 BLOCK_FLAGS_NONE); … … 151 153 152 154 it->current_offset = pos; 155 153 156 return ext4_directory_iterator_set(it, block_size); 154 157 } -
uspace/lib/ext4/libext4_filesystem.c
r1114173 re68c834 41 41 #include "libext4.h" 42 42 43 /**44 * TODO doxy45 */46 43 int ext4_filesystem_init(ext4_filesystem_t *fs, service_id_t service_id) 47 44 { … … 86 83 } 87 84 88 /**89 * TODO doxy90 */91 85 void ext4_filesystem_fini(ext4_filesystem_t *fs) 92 86 { … … 95 89 } 96 90 97 /**98 * TODO doxy99 */100 91 int ext4_filesystem_check_sanity(ext4_filesystem_t *fs) 101 92 { … … 110 101 } 111 102 112 /**113 * TODO doxy114 */115 103 int ext4_filesystem_check_features(ext4_filesystem_t *fs, bool *o_read_only) 116 104 { … … 139 127 } 140 128 141 /**142 * TODO doxy143 */144 129 int ext4_filesystem_get_block_group_ref(ext4_filesystem_t *fs, uint32_t bgid, 145 130 ext4_block_group_ref_t **ref) 146 131 { 147 EXT4FS_DBG("");148 149 132 int rc; 150 133 aoff64_t block_id; … … 164 147 block_id = ext4_superblock_get_first_data_block(fs->superblock) + 1; 165 148 166 EXT4FS_DBG("block_size = \%d", ext4_superblock_get_block_size(fs->superblock));167 EXT4FS_DBG("descriptors_per_block = \%d", descriptors_per_block);168 EXT4FS_DBG("bgid = \%d", bgid);169 EXT4FS_DBG("first_data_block: \%d", (uint32_t)block_id);170 171 149 /* Find the block containing the descriptor we are looking for */ 172 150 block_id += bgid / descriptors_per_block; 173 151 offset = (bgid % descriptors_per_block) * EXT4_BLOCK_GROUP_DESCRIPTOR_SIZE; 174 152 175 EXT4FS_DBG("updated block_id: \%d", (uint32_t)block_id);176 177 153 rc = block_get(&newref->block, fs->device, block_id, 0); 178 154 if (rc != EOK) { 179 180 EXT4FS_DBG("block_get error: \%d", rc);181 182 155 free(newref); 183 156 return rc; 184 157 } 185 158 186 EXT4FS_DBG("block read");187 188 159 newref->block_group = newref->block->data + offset; 189 160 190 161 *ref = newref; 191 162 192 EXT4FS_DBG("finished"); 193 194 return EOK; 195 } 196 197 /** 198 * TODO doxy 199 */ 163 return EOK; 164 } 165 200 166 int ext4_filesystem_get_inode_ref(ext4_filesystem_t *fs, uint32_t index, 201 167 ext4_inode_ref_t **ref) 202 168 { 203 EXT4FS_DBG("");204 205 169 int rc; 206 170 aoff64_t block_id; … … 221 185 } 222 186 223 EXT4FS_DBG("allocated");224 225 187 inodes_per_group = ext4_superblock_get_inodes_per_group(fs->superblock); 226 227 EXT4FS_DBG("inodes_per_group_loaded");228 188 229 189 /* inode numbers are 1-based, but it is simpler to work with 0-based … … 234 194 offset_in_group = index % inodes_per_group; 235 195 236 EXT4FS_DBG("index: \%d", index);237 EXT4FS_DBG("inodes_per_group: \%d", inodes_per_group);238 EXT4FS_DBG("bg_id: \%d", block_group);239 240 196 rc = ext4_filesystem_get_block_group_ref(fs, block_group, &bg_ref); 241 197 if (rc != EOK) { … … 243 199 return rc; 244 200 } 245 246 EXT4FS_DBG("block_group_ref loaded");247 201 248 202 inode_table_start = ext4_block_group_get_inode_table_first_block( 249 203 bg_ref->block_group); 250 204 251 EXT4FS_DBG("inode_table block loaded");252 253 205 inode_size = ext4_superblock_get_inode_size(fs->superblock); 254 206 block_size = ext4_superblock_get_block_size(fs->superblock); … … 259 211 offset_in_block = byte_offset_in_group % block_size; 260 212 261 EXT4FS_DBG("superblock info loaded");262 263 213 rc = block_get(&newref->block, fs->device, block_id, 0); 264 214 if (rc != EOK) { … … 266 216 return rc; 267 217 } 268 269 EXT4FS_DBG("block got");270 218 271 219 newref->inode = newref->block->data + offset_in_block; … … 277 225 *ref = newref; 278 226 279 EXT4FS_DBG("finished"); 280 281 return EOK; 282 } 227 return EOK; 228 } 229 283 230 284 231 int ext4_filesystem_put_inode_ref(ext4_inode_ref_t *ref) … … 307 254 308 255 /* Handle simple case when we are dealing with direct reference */ 309 if (iblock < EXT4_INODE_DIRECT_BLOCK S) {256 if (iblock < EXT4_INODE_DIRECT_BLOCK_COUNT) { 310 257 current_block = ext4_inode_get_direct_block(inode, (uint32_t)iblock); 311 258 *fblock = current_block; … … 317 264 */ 318 265 block_ids_per_block = ext4_superblock_get_block_size(fs->superblock) / sizeof(uint32_t); 319 limits[0] = EXT4_INODE_DIRECT_BLOCK S;266 limits[0] = EXT4_INODE_DIRECT_BLOCK_COUNT; 320 267 blocks_per_level[0] = 1; 321 268 for (i = 1; i < 4; i++) { -
uspace/srv/fs/ext4fs/ext4fs_ops.c
r1114173 re68c834 147 147 int ext4fs_global_init(void) 148 148 { 149 EXT4FS_DBG("");150 151 149 if (!hash_table_create(&open_nodes, OPEN_NODES_BUCKETS, 152 150 OPEN_NODES_KEYS, &open_nodes_ops)) { … … 159 157 int ext4fs_global_fini(void) 160 158 { 161 EXT4FS_DBG("");162 163 159 hash_table_destroy(&open_nodes); 164 160 return EOK; … … 172 168 int ext4fs_instance_get(service_id_t service_id, ext4fs_instance_t **inst) 173 169 { 174 EXT4FS_DBG("");175 176 170 ext4fs_instance_t *tmp; 177 171 … … 200 194 int ext4fs_root_get(fs_node_t **rfn, service_id_t service_id) 201 195 { 202 EXT4FS_DBG("");203 204 196 return ext4fs_node_get(rfn, service_id, EXT4_INODE_ROOT_INDEX); 205 197 } … … 208 200 int ext4fs_match(fs_node_t **rfn, fs_node_t *pfn, const char *component) 209 201 { 210 EXT4FS_DBG("");211 212 202 ext4fs_node_t *eparent = EXT4FS_NODE(pfn); 213 203 ext4_filesystem_t *fs; … … 413 403 int ext4fs_create_node(fs_node_t **rfn, service_id_t service_id, int flags) 414 404 { 415 EXT4FS_DBG(" ");405 EXT4FS_DBG("not supported"); 416 406 417 407 // TODO … … 422 412 int ext4fs_destroy_node(fs_node_t *fn) 423 413 { 424 EXT4FS_DBG(" ");414 EXT4FS_DBG("not supported"); 425 415 426 416 // TODO … … 431 421 int ext4fs_link(fs_node_t *pfn, fs_node_t *cfn, const char *name) 432 422 { 433 EXT4FS_DBG(" ");423 EXT4FS_DBG("not supported"); 434 424 435 425 // TODO … … 440 430 int ext4fs_unlink(fs_node_t *pfn, fs_node_t *cfn, const char *nm) 441 431 { 442 EXT4FS_DBG(" ");432 EXT4FS_DBG("not supported"); 443 433 444 434 // TODO … … 449 439 int ext4fs_has_children(bool *has_children, fs_node_t *fn) 450 440 { 451 EXT4FS_DBG(""); 452 453 // TODO 441 ext4fs_node_t *enode = EXT4FS_NODE(fn); 442 ext4_directory_iterator_t it; 443 ext4_filesystem_t *fs; 444 int rc; 445 bool found = false; 446 size_t name_size; 447 448 fs = enode->instance->filesystem; 449 450 if (!ext4_inode_is_type(fs->superblock, enode->inode_ref->inode, 451 EXT4_INODE_MODE_DIRECTORY)) { 452 *has_children = false; 453 return EOK; 454 } 455 456 rc = ext4_directory_iterator_init(&it, fs, enode->inode_ref, 0); 457 if (rc != EOK) { 458 return rc; 459 } 460 461 /* Find a non-empty directory entry */ 462 while (it.current != NULL) { 463 if (it.current->inode != 0) { 464 name_size = ext4_directory_entry_ll_get_name_length(fs->superblock, 465 it.current); 466 if (!ext4fs_is_dots(&it.current->name, name_size)) { 467 found = true; 468 break; 469 } 470 } 471 472 rc = ext4_directory_iterator_next(&it); 473 if (rc != EOK) { 474 ext4_directory_iterator_fini(&it); 475 return rc; 476 } 477 } 478 479 rc = ext4_directory_iterator_fini(&it); 480 if (rc != EOK) { 481 return rc; 482 } 483 484 *has_children = found; 485 454 486 return EOK; 455 487 } … … 482 514 bool ext4fs_is_directory(fs_node_t *fn) 483 515 { 484 EXT4FS_DBG("");485 486 // TODO487 return false;516 ext4fs_node_t *enode = EXT4FS_NODE(fn); 517 bool is_dir = ext4_inode_is_type(enode->instance->filesystem->superblock, 518 enode->inode_ref->inode, EXT4_INODE_MODE_DIRECTORY); 519 return is_dir; 488 520 } 489 521 … … 500 532 service_id_t ext4fs_service_get(fs_node_t *fn) 501 533 { 502 EXT4FS_DBG(""); 503 504 // TODO 505 return 0; 534 ext4fs_node_t *enode = EXT4FS_NODE(fn); 535 return enode->instance->service_id; 506 536 } 507 537 … … 536 566 fs_index_t *index, aoff64_t *size, unsigned *lnkcnt) 537 567 { 538 EXT4FS_DBG("");539 540 568 int rc; 541 569 ext4_filesystem_t *fs; … … 616 644 static int ext4fs_unmounted(service_id_t service_id) 617 645 { 618 EXT4FS_DBG("");619 620 646 int rc; 621 647 ext4fs_instance_t *inst; … … 651 677 size_t *rbytes) 652 678 { 653 EXT4FS_DBG("");654 655 679 ext4fs_instance_t *inst; 656 680 ext4_inode_ref_t *inode_ref; … … 712 736 ext4fs_instance_t *inst, ext4_inode_ref_t *inode_ref, size_t *rbytes) 713 737 { 714 EXT4FS_DBG("");715 738 716 739 ext4_directory_iterator_t it; … … 720 743 int rc; 721 744 bool found = false; 745 746 EXT4FS_DBG("inode = \%d", inode_ref->index); 722 747 723 748 rc = ext4_directory_iterator_init(&it, inst->filesystem, inode_ref, pos); … … 732 757 */ 733 758 while (it.current != NULL) { 759 734 760 if (it.current->inode == 0) { 735 761 goto skip; … … 738 764 name_size = ext4_directory_entry_ll_get_name_length( 739 765 inst->filesystem->superblock, it.current); 766 767 768 char* name = (char *)(&it.current->name); 769 770 EXT4FS_DBG("name: \%s", name); 771 EXT4FS_DBG("inode-number: \%d", it.current->inode); 740 772 741 773 /* skip . and .. */ … … 878 910 size_t *wbytes, aoff64_t *nsize) 879 911 { 912 EXT4FS_DBG("not supported"); 913 880 914 // TODO 881 915 return ENOTSUP; … … 886 920 ext4fs_truncate(service_id_t service_id, fs_index_t index, aoff64_t size) 887 921 { 922 EXT4FS_DBG("not supported"); 923 888 924 // TODO 889 925 return ENOTSUP; … … 900 936 static int ext4fs_destroy(service_id_t service_id, fs_index_t index) 901 937 { 938 EXT4FS_DBG("not supported"); 939 902 940 //TODO 903 941 return ENOTSUP; … … 907 945 static int ext4fs_sync(service_id_t service_id, fs_index_t index) 908 946 { 947 EXT4FS_DBG("not supported"); 948 909 949 // TODO 910 950 return ENOTSUP;
Note:
See TracChangeset
for help on using the changeset viewer.