Changes in / [6a7e497:18626b3] in mainline
- Location:
- uspace
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/blkdump/blkdump.c
r6a7e497 r18626b3 202 202 } 203 203 204 / * Print hexadecimal values */204 // 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 bytes */212 // 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 characters */220 // Print printable characters 221 221 for (pos = 0; pos < length; pos++) { 222 222 if (pos == length/2) { -
uspace/app/bnchmark/bnchmark.c
r6a7e497 r18626b3 210 210 static void syntax_print(void) 211 211 { 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");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"); 219 219 } 220 220 -
uspace/app/ext2info/ext2info.c
r6a7e497 r18626b3 95 95 } 96 96 97 / * Skip program name */97 // Skip program name 98 98 --argc; ++argv; 99 99 … … 171 171 assert(argc == 1); 172 172 173 / * Display common things by default */173 // Display common things by default 174 174 if ((arg_flags & ARG_ALL) == 0) { 175 175 arg_flags = ARG_COMMON; -
uspace/app/testread/testread.c
r6a7e497 r18626b3 84 84 } 85 85 86 / * Skip program name */86 // Skip program name 87 87 --argc; ++argv; 88 88 -
uspace/lib/ext2/libext2_directory.c
r6a7e497 r18626b3 93 93 it->fs = fs; 94 94 95 / * Get the first data block, so we can get the first entry */95 // Get the first data block, so we can get 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 154 */ 152 // If we are moving accross block boundary, 153 // we need to get another block 155 154 if (current_block_idx != next_block_idx) { 156 155 rc = block_put(it->current_block); … … 177 176 offset_in_block = (it->current_offset + skip) % block_size; 178 177 179 / * Ensure proper alignment */178 // Ensure proper alignment 180 179 if ((offset_in_block % 4) != 0) { 181 180 it->current = NULL; … … 183 182 } 184 183 185 / * Ensure that the core of the entry does not overflow the block */184 // Ensure that the core of the entry does not overflow the block 186 185 if (offset_in_block > block_size - 8) { 187 186 it->current = NULL; … … 192 191 it->current_offset += skip; 193 192 194 / * Ensure that the whole entry does not overflow the block */193 // Ensure that the whole entry does not overflow the block 195 194 skip = ext2_directory_entry_ll_get_entry_length(it->current); 196 195 if (offset_in_block + skip > block_size) { … … 199 198 } 200 199 201 / * Ensure the name length is not too large */200 // Ensure the name length is not too large 202 201 if (ext2_directory_entry_ll_get_name_length(it->fs->superblock, 203 202 it->current) > skip-8) { -
uspace/lib/ext2/libext2_filesystem.c
r6a7e497 r18626b3 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 later */119 // 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 EOK;122 return 0; 123 123 } 124 124 … … 129 129 read_only = ext2_superblock_get_features_read_only(fs->superblock); 130 130 131 /* check whether we support all features 132 * first unset any supported feature flags 133 * and see whether any unspported feature remains */ 131 // unset any supported features 134 132 incompatible &= ~EXT2_SUPPORTED_INCOMPATIBLE_FEATURES; 135 133 read_only &= ~EXT2_SUPPORTED_READ_ONLY_FEATURES; … … 173 171 / EXT2_BLOCK_GROUP_DESCRIPTOR_SIZE; 174 172 175 / * Block group descriptor table starts at the next block after superblock */173 // Block group descriptor table starts at the next block after superblock 176 174 block_id = ext2_superblock_get_first_block(fs->superblock) + 1; 177 175 178 / * Find the block containing the descriptor we are looking for */176 // Find the block containing the descriptor we are looking for 179 177 block_id += bgid / descriptors_per_block; 180 178 offset = (bgid % descriptors_per_block) * EXT2_BLOCK_GROUP_DESCRIPTOR_SIZE; … … 242 240 inodes_per_group = ext2_superblock_get_inodes_per_group(fs->superblock); 243 241 244 /* inode numbers are 1-based, but it is simpler to work with 0-based 245 * when computing indices 246 */ 242 // inode numbers are 1-based 247 243 index -= 1; 248 244 block_group = index / inodes_per_group; … … 273 269 274 270 newref->inode = newref->block->data + offset_in_block; 275 /* we decremented index above, but need to store the original value 276 * in the reference 277 */ 278 newref->index = index+1; 271 newref->index = index+1; // we decremented index above 279 272 280 273 *ref = newref; … … 322 315 block_t *block; 323 316 324 /* Handle simple case when we are dealing with direct reference */325 317 if (iblock < EXT2_INODE_DIRECT_BLOCKS) { 326 318 current_block = ext2_inode_get_direct_block(inode, (uint32_t)iblock); … … 329 321 } 330 322 331 /* Compute limits for indirect block levels 332 * TODO: compute this once when loading filesystem and store in ext2_filesystem_t 333 */ 323 // Compute limits for indirect block levels 324 // TODO: compute this once when loading filesystem and store in ext2_filesystem_t 334 325 block_ids_per_block = ext2_superblock_get_block_size(fs->superblock) / sizeof(uint32_t); 335 326 limits[0] = EXT2_INODE_DIRECT_BLOCKS; … … 341 332 } 342 333 343 / * Determine the indirection level needed to get the desired block */334 // Determine the indirection level needed to get the desired block 344 335 level = -1; 345 336 for (i = 1; i < 4; i++) { … … 354 345 } 355 346 356 /* Compute offsets for the topmost level */357 347 block_offset_in_level = iblock - limits[level-1]; 358 348 current_block = ext2_inode_get_indirect_block(inode, level-1); 359 349 offset_in_block = block_offset_in_level / blocks_per_level[level-1]; 360 350 361 /* Navigate through other levels, until we find the block number362 * or find null reference meaning we are dealing with sparse file363 */364 351 while (level > 0) { 365 352 rc = block_get(&block, fs->device, current_block, 0); … … 377 364 378 365 if (current_block == 0) { 379 /* This is a sparse file */380 366 *fblock = 0; 381 367 return EOK; … … 384 370 level -= 1; 385 371 386 /* If we are on the last level, break here as387 * there is no next level to visit388 */389 372 if (level == 0) { 390 373 break; 391 374 } 392 375 393 /* Visit the next level */394 376 block_offset_in_level %= blocks_per_level[level]; 395 377 offset_in_block = block_offset_in_level / blocks_per_level[level-1]; … … 403 385 /** 404 386 * 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 been407 * used (and tested) yet408 387 * 409 388 * @param fs pointer to filesystem … … 441 420 idx = 0; 442 421 443 / * Read the block group descriptor */422 // Read the block group descriptor 444 423 rc = ext2_filesystem_get_block_group_ref(fs, block_group, &bg); 445 424 if (rc != EOK) { … … 465 444 } 466 445 467 / * We found a block group with free block, let's look at the block bitmap */446 // We found a block group with free block, let's look at the block bitmap 468 447 bb_block = ext2_block_group_get_block_bitmap_block(bg->block_group); 469 448 … … 473 452 } 474 453 475 / * Use all blocks from this block group */454 // Use all blocks from this block group 476 455 for (bb_idx = 0; bb_idx < block_size && idx < count; bb_idx++) { 477 456 uint8_t *data = (uint8_t *) block->data; … … 479 458 continue; 480 459 } 481 / * find an empty bit */460 // find an empty bit 482 461 uint8_t mask; 483 462 for (mask = 1, bb_bit = 0; -
uspace/srv/fs/ext2fs/ext2fs.c
r6a7e497 r18626b3 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 }167 163 168 164 printf(NAME ": Accepting connections\n"); -
uspace/srv/fs/ext2fs/ext2fs_ops.c
r6a7e497 r18626b3 245 245 } 246 246 247 /* Find length of component in bytes 248 * TODO: check for library function call that does this 249 */ 247 // Find length of component in bytes 248 // TODO: check for library function call that does this 250 249 component_size = 0; 251 250 while (*(component+component_size) != 0) { … … 254 253 255 254 while (it.current != NULL) { 256 / * ignore empty directory entries */255 // ignore empty directory entries 257 256 if (it.current->inode != 0) { 258 257 name_size = ext2_directory_entry_ll_get_name_length(fs->superblock, … … 482 481 } 483 482 484 / * Find a non-empty directory entry */483 // Find a non-empty directory entry 485 484 while (it.current != NULL) { 486 485 if (it.current->inode != 0) { … … 718 717 } 719 718 720 / * Remove the instance from the list */719 // Remove the instance from list 721 720 fibril_mutex_lock(&instance_list_mutex); 722 721 list_remove(&inst->link); … … 788 787 } 789 788 else { 790 / * Other inode types not supported */789 // Other inode types not supported 791 790 async_answer_0(callid, ENOTSUP); 792 791 async_answer_0(rid, ENOTSUP); … … 829 828 } 830 829 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 */ 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 837 835 cur = 0; 838 836 while (it.current != NULL) { … … 844 842 inst->filesystem->superblock, it.current); 845 843 846 / * skip . and .. */844 // skip . and .. 847 845 if (ext2fs_is_dots(&it.current->name, name_size)) { 848 846 goto skip; 849 847 } 850 848 851 / * Is this the dir entry we want to read? */849 // Is this the dir entry we want to read? 852 850 if (cur == pos) { 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 */ 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 857 854 buf = malloc(name_size+1); 858 855 if (buf == NULL) { … … 913 910 914 911 if (pos >= file_size) { 915 / * Read 0 bytes successfully */912 // Read 0 bytes successfully 916 913 async_data_read_finalize(callid, NULL, 0); 917 914 async_answer_1(rid, EOK, 0); … … 919 916 } 920 917 921 / * For now, we only read data from one block at a time */918 // For now, we only read data from one block at a time 922 919 block_size = ext2_superblock_get_block_size(inst->filesystem->superblock); 923 920 file_block = pos / block_size; … … 925 922 bytes = min(block_size - offset_in_block, size); 926 923 927 / * Handle end of file */924 // Handle end of file 928 925 if (pos + bytes > file_size) { 929 926 bytes = file_size - pos; 930 927 } 931 928 932 /* Get the real block number */933 929 rc = ext2_filesystem_get_inode_data_block_index(inst->filesystem, 934 930 inode_ref->inode, file_block, &fs_block); … … 939 935 } 940 936 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 */ 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 946 941 if (fs_block == 0) { 947 942 buffer = malloc(bytes); … … 962 957 } 963 958 964 / * Usual case - we need to read a block from device */959 // Usual case - we need to read a block from device 965 960 rc = block_get(&block, inst->devmap_handle, fs_block, BLOCK_FLAGS_NONE); 966 961 if (rc != EOK) {
Note:
See TracChangeset
for help on using the changeset viewer.