Changeset 6a7e497 in mainline
- Timestamp:
- 2011-06-02T19:05:17Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 16b2ea8
- Parents:
- 18626b3 (diff), d030e0c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- uspace
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/blkdump/blkdump.c
r18626b3 r6a7e497 202 202 } 203 203 204 / / Print hexadecimal values204 /* Print hexadecimal values */ 205 205 for (pos = 0; pos < length; pos++) { 206 206 if (pos == length/2) { … … 210 210 } 211 211 212 / / pad with spaces if we have less than 16 bytes212 /* Pad with spaces if we have less than 16 bytes */ 213 213 for (pos = length; pos < bytes_per_row; pos++) { 214 214 if (pos == length/2) { … … 218 218 } 219 219 220 / / Print printable characters220 /* Print printable characters */ 221 221 for (pos = 0; pos < length; pos++) { 222 222 if (pos == length/2) { -
uspace/app/bnchmark/bnchmark.c
r18626b3 r6a7e497 210 210 static void syntax_print(void) 211 211 { 212 fprintf(stderr, "syntax: bnchmark<iterations> <test type> <log-str> <path>\n");213 fprintf(stderr, " <iterations> number of times to run a given test ");214 fprintf(stderr, " <test-type> one of: ");215 fprintf(stderr, " sequential-file-read ");216 fprintf(stderr, " sequential-dir-read ");217 fprintf(stderr, " <log-str> a string to attach to results ");218 fprintf(stderr, " <path> file/directory to use for testing ");212 fprintf(stderr, "syntax: " NAME " <iterations> <test type> <log-str> <path>\n"); 213 fprintf(stderr, " <iterations> number of times to run a given test\n"); 214 fprintf(stderr, " <test-type> one of:\n"); 215 fprintf(stderr, " sequential-file-read\n"); 216 fprintf(stderr, " sequential-dir-read\n"); 217 fprintf(stderr, " <log-str> a string to attach to results\n"); 218 fprintf(stderr, " <path> file/directory to use for testing\n"); 219 219 } 220 220 -
uspace/app/ext2info/ext2info.c
r18626b3 r6a7e497 95 95 } 96 96 97 / / Skip program name97 /* Skip program name */ 98 98 --argc; ++argv; 99 99 … … 171 171 assert(argc == 1); 172 172 173 / / Display common things by default173 /* Display common things by default */ 174 174 if ((arg_flags & ARG_ALL) == 0) { 175 175 arg_flags = ARG_COMMON; -
uspace/app/testread/testread.c
r18626b3 r6a7e497 84 84 } 85 85 86 / / Skip program name86 /* Skip program name */ 87 87 --argc; ++argv; 88 88 -
uspace/lib/ext2/libext2_directory.c
r18626b3 r6a7e497 93 93 it->fs = fs; 94 94 95 / / Get the first data block, so we can get first entry95 /* Get the first data block, so we can get the first entry */ 96 96 rc = ext2_filesystem_get_inode_data_block_index(fs, inode_ref->inode, 0, 97 97 &block_id); … … 133 133 size = ext2_inode_get_size(it->fs->superblock, it->inode_ref->inode); 134 134 135 / / Are we at the end?135 /* Are we at the end? */ 136 136 if (it->current_offset + skip >= size) { 137 137 rc = block_put(it->current_block); … … 150 150 next_block_idx = (it->current_offset + skip) / block_size; 151 151 152 // If we are moving accross block boundary, 153 // we need to get another block 152 /* If we are moving accross block boundary, 153 * we need to get another block 154 */ 154 155 if (current_block_idx != next_block_idx) { 155 156 rc = block_put(it->current_block); … … 176 177 offset_in_block = (it->current_offset + skip) % block_size; 177 178 178 / / Ensure proper alignment179 /* Ensure proper alignment */ 179 180 if ((offset_in_block % 4) != 0) { 180 181 it->current = NULL; … … 182 183 } 183 184 184 / / Ensure that the core of the entry does not overflow the block185 /* Ensure that the core of the entry does not overflow the block */ 185 186 if (offset_in_block > block_size - 8) { 186 187 it->current = NULL; … … 191 192 it->current_offset += skip; 192 193 193 / / Ensure that the whole entry does not overflow the block194 /* Ensure that the whole entry does not overflow the block */ 194 195 skip = ext2_directory_entry_ll_get_entry_length(it->current); 195 196 if (offset_in_block + skip > block_size) { … … 198 199 } 199 200 200 / / Ensure the name length is not too large201 /* Ensure the name length is not too large */ 201 202 if (ext2_directory_entry_ll_get_name_length(it->fs->superblock, 202 203 it->current) > skip-8) { -
uspace/lib/ext2/libext2_filesystem.c
r18626b3 r6a7e497 117 117 int ext2_filesystem_check_flags(ext2_filesystem_t *fs, bool *o_read_only) 118 118 { 119 / / feature flags are present in rev 1 and later119 /* feature flags are present in rev 1 and later */ 120 120 if (ext2_superblock_get_rev_major(fs->superblock) == 0) { 121 121 *o_read_only = false; 122 return 0;122 return EOK; 123 123 } 124 124 … … 129 129 read_only = ext2_superblock_get_features_read_only(fs->superblock); 130 130 131 // unset any supported features 131 /* check whether we support all features 132 * first unset any supported feature flags 133 * and see whether any unspported feature remains */ 132 134 incompatible &= ~EXT2_SUPPORTED_INCOMPATIBLE_FEATURES; 133 135 read_only &= ~EXT2_SUPPORTED_READ_ONLY_FEATURES; … … 171 173 / EXT2_BLOCK_GROUP_DESCRIPTOR_SIZE; 172 174 173 / / Block group descriptor table starts at the next block after superblock175 /* Block group descriptor table starts at the next block after superblock */ 174 176 block_id = ext2_superblock_get_first_block(fs->superblock) + 1; 175 177 176 / / Find the block containing the descriptor we are looking for178 /* Find the block containing the descriptor we are looking for */ 177 179 block_id += bgid / descriptors_per_block; 178 180 offset = (bgid % descriptors_per_block) * EXT2_BLOCK_GROUP_DESCRIPTOR_SIZE; … … 240 242 inodes_per_group = ext2_superblock_get_inodes_per_group(fs->superblock); 241 243 242 // inode numbers are 1-based 244 /* inode numbers are 1-based, but it is simpler to work with 0-based 245 * when computing indices 246 */ 243 247 index -= 1; 244 248 block_group = index / inodes_per_group; … … 269 273 270 274 newref->inode = newref->block->data + offset_in_block; 271 newref->index = index+1; // we decremented index above 275 /* we decremented index above, but need to store the original value 276 * in the reference 277 */ 278 newref->index = index+1; 272 279 273 280 *ref = newref; … … 315 322 block_t *block; 316 323 324 /* Handle simple case when we are dealing with direct reference */ 317 325 if (iblock < EXT2_INODE_DIRECT_BLOCKS) { 318 326 current_block = ext2_inode_get_direct_block(inode, (uint32_t)iblock); … … 321 329 } 322 330 323 // Compute limits for indirect block levels 324 // TODO: compute this once when loading filesystem and store in ext2_filesystem_t 331 /* Compute limits for indirect block levels 332 * TODO: compute this once when loading filesystem and store in ext2_filesystem_t 333 */ 325 334 block_ids_per_block = ext2_superblock_get_block_size(fs->superblock) / sizeof(uint32_t); 326 335 limits[0] = EXT2_INODE_DIRECT_BLOCKS; … … 332 341 } 333 342 334 / / Determine the indirection level needed to get the desired block343 /* Determine the indirection level needed to get the desired block */ 335 344 level = -1; 336 345 for (i = 1; i < 4; i++) { … … 345 354 } 346 355 356 /* Compute offsets for the topmost level */ 347 357 block_offset_in_level = iblock - limits[level-1]; 348 358 current_block = ext2_inode_get_indirect_block(inode, level-1); 349 359 offset_in_block = block_offset_in_level / blocks_per_level[level-1]; 350 360 361 /* Navigate through other levels, until we find the block number 362 * or find null reference meaning we are dealing with sparse file 363 */ 351 364 while (level > 0) { 352 365 rc = block_get(&block, fs->device, current_block, 0); … … 364 377 365 378 if (current_block == 0) { 379 /* This is a sparse file */ 366 380 *fblock = 0; 367 381 return EOK; … … 370 384 level -= 1; 371 385 386 /* If we are on the last level, break here as 387 * there is no next level to visit 388 */ 372 389 if (level == 0) { 373 390 break; 374 391 } 375 392 393 /* Visit the next level */ 376 394 block_offset_in_level %= blocks_per_level[level]; 377 395 offset_in_block = block_offset_in_level / blocks_per_level[level-1]; … … 385 403 /** 386 404 * Allocate a given number of blocks and store their ids in blocks 405 * 406 * @todo TODO: This function is not finished and really has never been 407 * used (and tested) yet 387 408 * 388 409 * @param fs pointer to filesystem … … 420 441 idx = 0; 421 442 422 / / Read the block group descriptor443 /* Read the block group descriptor */ 423 444 rc = ext2_filesystem_get_block_group_ref(fs, block_group, &bg); 424 445 if (rc != EOK) { … … 444 465 } 445 466 446 / / We found a block group with free block, let's look at the block bitmap467 /* We found a block group with free block, let's look at the block bitmap */ 447 468 bb_block = ext2_block_group_get_block_bitmap_block(bg->block_group); 448 469 … … 452 473 } 453 474 454 / / Use all blocks from this block group475 /* Use all blocks from this block group */ 455 476 for (bb_idx = 0; bb_idx < block_size && idx < count; bb_idx++) { 456 477 uint8_t *data = (uint8_t *) block->data; … … 458 479 continue; 459 480 } 460 / / find an empty bit481 /* find an empty bit */ 461 482 uint8_t mask; 462 483 for (mask = 1, bb_bit = 0; -
uspace/srv/fs/ext2fs/ext2fs.c
r18626b3 r6a7e497 161 161 162 162 rc = fs_register(vfs_phone, &ext2fs_reg, &ext2fs_vfs_info, ext2fs_connection); 163 if (rc != EOK) { 164 fprintf(stdout, NAME ": Failed to register fs (%d)\n", rc); 165 return 1; 166 } 163 167 164 168 printf(NAME ": Accepting connections\n"); -
uspace/srv/fs/ext2fs/ext2fs_ops.c
r18626b3 r6a7e497 245 245 } 246 246 247 // Find length of component in bytes 248 // TODO: check for library function call that does this 247 /* Find length of component in bytes 248 * TODO: check for library function call that does this 249 */ 249 250 component_size = 0; 250 251 while (*(component+component_size) != 0) { … … 253 254 254 255 while (it.current != NULL) { 255 / / ignore empty directory entries256 /* ignore empty directory entries */ 256 257 if (it.current->inode != 0) { 257 258 name_size = ext2_directory_entry_ll_get_name_length(fs->superblock, … … 481 482 } 482 483 483 / / Find a non-empty directory entry484 /* Find a non-empty directory entry */ 484 485 while (it.current != NULL) { 485 486 if (it.current->inode != 0) { … … 717 718 } 718 719 719 / / Remove the instance from list720 /* Remove the instance from the list */ 720 721 fibril_mutex_lock(&instance_list_mutex); 721 722 list_remove(&inst->link); … … 787 788 } 788 789 else { 789 / / Other inode types not supported790 /* Other inode types not supported */ 790 791 async_answer_0(callid, ENOTSUP); 791 792 async_answer_0(rid, ENOTSUP); … … 828 829 } 829 830 830 // Find the index we want to read 831 // Note that we need to iterate and count as 832 // the underlying structure is a linked list 833 // Moreover, we want to skip . and .. entries 834 // as these are not used in HelenOS 831 /* Find the index we want to read 832 * Note that we need to iterate and count as 833 * the underlying structure is a linked list 834 * Moreover, we want to skip . and .. entries 835 * as these are not used in HelenOS 836 */ 835 837 cur = 0; 836 838 while (it.current != NULL) { … … 842 844 inst->filesystem->superblock, it.current); 843 845 844 / / skip . and ..846 /* skip . and .. */ 845 847 if (ext2fs_is_dots(&it.current->name, name_size)) { 846 848 goto skip; 847 849 } 848 850 849 / / Is this the dir entry we want to read?851 /* Is this the dir entry we want to read? */ 850 852 if (cur == pos) { 851 // The on-disk entry does not contain \0 at the end 852 // end of entry name, so we copy it to new buffer 853 // and add the \0 at the end 853 /* The on-disk entry does not contain \0 at the end 854 * end of entry name, so we copy it to new buffer 855 * and add the \0 at the end 856 */ 854 857 buf = malloc(name_size+1); 855 858 if (buf == NULL) { … … 910 913 911 914 if (pos >= file_size) { 912 / / Read 0 bytes successfully915 /* Read 0 bytes successfully */ 913 916 async_data_read_finalize(callid, NULL, 0); 914 917 async_answer_1(rid, EOK, 0); … … 916 919 } 917 920 918 / / For now, we only read data from one block at a time921 /* For now, we only read data from one block at a time */ 919 922 block_size = ext2_superblock_get_block_size(inst->filesystem->superblock); 920 923 file_block = pos / block_size; … … 922 925 bytes = min(block_size - offset_in_block, size); 923 926 924 / / Handle end of file927 /* Handle end of file */ 925 928 if (pos + bytes > file_size) { 926 929 bytes = file_size - pos; 927 930 } 928 931 932 /* Get the real block number */ 929 933 rc = ext2_filesystem_get_inode_data_block_index(inst->filesystem, 930 934 inode_ref->inode, file_block, &fs_block); … … 935 939 } 936 940 937 // Check for sparse file 938 // If ext2_filesystem_get_inode_data_block_index returned 939 // fs_block == 0, it means that the given block is not allocated for the 940 // file and we need to return a buffer of zeros 941 /* Check for sparse file 942 * If ext2_filesystem_get_inode_data_block_index returned 943 * fs_block == 0, it means that the given block is not allocated for the 944 * file and we need to return a buffer of zeros 945 */ 941 946 if (fs_block == 0) { 942 947 buffer = malloc(bytes); … … 957 962 } 958 963 959 / / Usual case - we need to read a block from device964 /* Usual case - we need to read a block from device */ 960 965 rc = block_get(&block, inst->devmap_handle, fs_block, BLOCK_FLAGS_NONE); 961 966 if (rc != EOK) {
Note:
See TracChangeset
for help on using the changeset viewer.